Merge branch 'tests-cleanup' into 'master'

Tests cleanup

See merge request GNOME/gtk!1884
This commit is contained in:
Matthias Clasen 2020-05-12 21:17:29 +00:00
commit a4debecfb1
14 changed files with 161 additions and 1105 deletions

View File

@ -125,49 +125,164 @@ drag_end (GtkGestureDrag *gesture,
}
static void
checkerboard_draw (GtkDrawingArea *da,
cairo_t *cr,
int width,
int height,
gpointer data)
oval_path (cairo_t *cr,
double xc, double yc,
double xr, double yr)
{
gint i, j, xcount, ycount;
cairo_save (cr);
#define CHECK_SIZE 10
#define SPACING 2
cairo_translate (cr, xc, yc);
cairo_scale (cr, 1.0, yr / xr);
cairo_move_to (cr, xr, 0.0);
cairo_arc (cr,
0, 0,
xr,
0, 2 * G_PI);
cairo_close_path (cr);
/* At the start of a draw handler, a clip region has been set on
* the Cairo context, and the contents have been cleared to the
* widget's background color. The docs for
* gdk_surface_begin_paint_region() give more details on how this
* works.
*/
cairo_restore (cr);
}
xcount = 0;
i = SPACING;
while (i < width)
/* Fill the given area with checks in the standard style
* for showing compositing effects.
*
* It would make sense to do this as a repeating surface,
* but most implementations of RENDER currently have broken
* implementations of repeat + transform, even when the
* transform is a translation.
*/
static void
fill_checks (cairo_t *cr,
int x, int y,
int width, int height)
{
int i, j;
#define CHECK_SIZE 16
cairo_rectangle (cr, x, y, width, height);
cairo_set_source_rgb (cr, 0.4, 0.4, 0.4);
cairo_fill (cr);
/* Only works for CHECK_SIZE a power of 2 */
j = x & (-CHECK_SIZE);
for (; j < height; j += CHECK_SIZE)
{
j = SPACING;
ycount = xcount % 2; /* start with even/odd depending on row */
while (j < height)
{
if (ycount % 2)
cairo_set_source_rgb (cr, 0.45777, 0, 0.45777);
else
cairo_set_source_rgb (cr, 1, 1, 1);
/* If we're outside the clip, this will do nothing.
*/
i = y & (-CHECK_SIZE);
for (; i < width; i += CHECK_SIZE)
if ((i / CHECK_SIZE + j / CHECK_SIZE) % 2 == 0)
cairo_rectangle (cr, i, j, CHECK_SIZE, CHECK_SIZE);
cairo_fill (cr);
j += CHECK_SIZE + SPACING;
++ycount;
}
i += CHECK_SIZE + SPACING;
++xcount;
}
cairo_set_source_rgb (cr, 0.7, 0.7, 0.7);
cairo_fill (cr);
#undef CHECK_SIZE
}
/* Draw a red, green, and blue circle equally spaced inside
* the larger circle of radius r at (xc, yc)
*/
static void
draw_3circles (cairo_t *cr,
double xc, double yc,
double radius,
double alpha)
{
double subradius = radius * (2 / 3. - 0.1);
cairo_set_source_rgba (cr, 1., 0., 0., alpha);
oval_path (cr,
xc + radius / 3. * cos (G_PI * (0.5)),
yc - radius / 3. * sin (G_PI * (0.5)),
subradius, subradius);
cairo_fill (cr);
cairo_set_source_rgba (cr, 0., 1., 0., alpha);
oval_path (cr,
xc + radius / 3. * cos (G_PI * (0.5 + 2/.3)),
yc - radius / 3. * sin (G_PI * (0.5 + 2/.3)),
subradius, subradius);
cairo_fill (cr);
cairo_set_source_rgba (cr, 0., 0., 1., alpha);
oval_path (cr,
xc + radius / 3. * cos (G_PI * (0.5 + 4/.3)),
yc - radius / 3. * sin (G_PI * (0.5 + 4/.3)),
subradius, subradius);
cairo_fill (cr);
}
static void
groups_draw (GtkDrawingArea *darea,
cairo_t *cr,
int width,
int height,
gpointer data)
{
cairo_surface_t *overlay, *punch, *circles;
cairo_t *overlay_cr, *punch_cr, *circles_cr;
/* Fill the background */
double radius = 0.5 * (width < height ? width : height) - 10;
double xc = width / 2.;
double yc = height / 2.;
overlay = cairo_surface_create_similar (cairo_get_target (cr),
CAIRO_CONTENT_COLOR_ALPHA,
width, height);
punch = cairo_surface_create_similar (cairo_get_target (cr),
CAIRO_CONTENT_ALPHA,
width, height);
circles = cairo_surface_create_similar (cairo_get_target (cr),
CAIRO_CONTENT_COLOR_ALPHA,
width, height);
fill_checks (cr, 0, 0, width, height);
/* Draw a black circle on the overlay
*/
overlay_cr = cairo_create (overlay);
cairo_set_source_rgb (overlay_cr, 0., 0., 0.);
oval_path (overlay_cr, xc, yc, radius, radius);
cairo_fill (overlay_cr);
/* Draw 3 circles to the punch surface, then cut
* that out of the main circle in the overlay
*/
punch_cr = cairo_create (punch);
draw_3circles (punch_cr, xc, yc, radius, 1.0);
cairo_destroy (punch_cr);
cairo_set_operator (overlay_cr, CAIRO_OPERATOR_DEST_OUT);
cairo_set_source_surface (overlay_cr, punch, 0, 0);
cairo_paint (overlay_cr);
/* Now draw the 3 circles in a subgroup again
* at half intensity, and use OperatorAdd to join up
* without seams.
*/
circles_cr = cairo_create (circles);
cairo_set_operator (circles_cr, CAIRO_OPERATOR_OVER);
draw_3circles (circles_cr, xc, yc, radius, 0.5);
cairo_destroy (circles_cr);
cairo_set_operator (overlay_cr, CAIRO_OPERATOR_ADD);
cairo_set_source_surface (overlay_cr, circles, 0, 0);
cairo_paint (overlay_cr);
cairo_destroy (overlay_cr);
cairo_set_source_surface (cr, overlay, 0, 0);
cairo_paint (cr);
cairo_surface_destroy (overlay);
cairo_surface_destroy (punch);
cairo_surface_destroy (circles);
}
static void
@ -207,12 +322,11 @@ do_drawingarea (GtkWidget *do_widget)
gtk_window_set_child (GTK_WINDOW (window), vbox);
/*
* Create the checkerboard area
* Create the groups area
*/
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label),
"<u>Checkerboard pattern</u>");
"<u>Knockout groups</u>");
gtk_box_append (GTK_BOX (vbox), label);
frame = gtk_frame_new (NULL);
@ -222,7 +336,7 @@ do_drawingarea (GtkWidget *do_widget)
da = gtk_drawing_area_new ();
gtk_drawing_area_set_content_width (GTK_DRAWING_AREA (da), 100);
gtk_drawing_area_set_content_height (GTK_DRAWING_AREA (da), 100);
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (da), checkerboard_draw, NULL, NULL);
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (da), groups_draw, NULL, NULL);
gtk_frame_set_child (GTK_FRAME (frame), da);
/*

View File

@ -3,3 +3,4 @@ subdir('gtk-demo')
subdir('icon-browser')
subdir('node-editor')
subdir('widget-factory')
subdir('print-editor')

View File

@ -0,0 +1,6 @@
executable('print-editor',
['print-editor.c'],
c_args: common_cflags,
dependencies: libgtk_dep,
include_directories: confinc,
gui_app: true)

View File

@ -1,243 +0,0 @@
#include <stdlib.h>
#include <gtk/gtk.h>
#include "gtkgears.h"
/************************************************************************
* DEMO CODE *
************************************************************************/
static void
toggle_overlay (GtkWidget *checkbutton,
GtkWidget *revealer)
{
gtk_revealer_set_reveal_child (GTK_REVEALER (revealer),
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(checkbutton)));
}
static void
toggle_spin (GtkWidget *checkbutton,
GtkWidget *spinner)
{
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(checkbutton)))
gtk_spinner_start (GTK_SPINNER (spinner));
else
gtk_spinner_stop (GTK_SPINNER (spinner));
}
static void
on_axis_value_change (GtkAdjustment *adjustment,
gpointer data)
{
GtkGears *gears = GTK_GEARS (data);
int axis = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (adjustment), "axis"));
gtk_gears_set_axis (gears, axis, gtk_adjustment_get_value (adjustment));
}
static GtkWidget *
create_axis_slider (GtkGears *gears,
int axis)
{
GtkWidget *box, *label, *slider;
GtkAdjustment *adj;
const char *text;
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE);
switch (axis)
{
case GTK_GEARS_X_AXIS:
text = "X";
break;
case GTK_GEARS_Y_AXIS:
text = "Y";
break;
case GTK_GEARS_Z_AXIS:
text = "Z";
break;
default:
g_assert_not_reached ();
}
label = gtk_label_new (text);
gtk_box_append (GTK_BOX (box), label);
adj = gtk_adjustment_new (gtk_gears_get_axis (gears, axis), 0.0, 360.0, 1.0, 12.0, 0.0);
g_object_set_data (G_OBJECT (adj), "axis", GINT_TO_POINTER (axis));
g_signal_connect (adj, "value-changed",
G_CALLBACK (on_axis_value_change),
gears);
slider = gtk_scale_new (GTK_ORIENTATION_VERTICAL, adj);
gtk_scale_set_draw_value (GTK_SCALE (slider), FALSE);
gtk_box_append (GTK_BOX (box), slider);
gtk_widget_set_vexpand (slider, TRUE);
return box;
}
static void
moar_gears (GtkButton *button, gpointer data)
{
GtkWidget *gears;
gears = gtk_gears_new ();
gtk_widget_set_size_request (gears, 100, 100);
gtk_box_append (GTK_BOX (data), gears);
}
static void
less_gears (GtkButton *button, gpointer data)
{
GtkWidget *gears;
gears = gtk_widget_get_last_child (GTK_WIDGET (data));
if (gears)
gtk_box_remove (GTK_BOX (data), gears);
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char *argv[])
{
GtkWidget *window, *box, *hbox, *button, *spinner, *check,
*fps_label, *gears, *extra_hbox, *bbox, *overlay,
*revealer, *frame, *label, *scrolled, *popover;
int i;
gboolean done = FALSE;
gtk_init ();
window = gtk_window_new ();
gtk_window_set_titlebar (GTK_WINDOW (window), gtk_header_bar_new ());
gtk_window_set_title (GTK_WINDOW (window), "GdkGears");
gtk_window_set_default_size (GTK_WINDOW (window), 640, 640);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
overlay = gtk_overlay_new ();
gtk_widget_set_margin_start (overlay, 12);
gtk_widget_set_margin_end (overlay, 12);
gtk_widget_set_margin_top (overlay, 12);
gtk_widget_set_margin_bottom (overlay, 12);
gtk_window_set_child (GTK_WINDOW (window), overlay);
revealer = gtk_revealer_new ();
gtk_widget_set_halign (revealer, GTK_ALIGN_END);
gtk_widget_set_valign (revealer, GTK_ALIGN_START);
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), revealer);
frame = gtk_frame_new (NULL);
gtk_widget_add_css_class (frame, "app-notification");
gtk_revealer_set_child (GTK_REVEALER (revealer), frame);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE);
gtk_box_set_spacing (GTK_BOX (hbox), 6);
gtk_frame_set_child (GTK_FRAME (frame), hbox);
label = gtk_label_new ("This is a transparent overlay widget!!!!\nAmazing, eh?");
gtk_box_append (GTK_BOX (hbox), label);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE);
gtk_box_set_spacing (GTK_BOX (box), 6);
gtk_overlay_set_child (GTK_OVERLAY (overlay), box);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE);
gtk_box_set_spacing (GTK_BOX (box), 6);
gtk_box_append (GTK_BOX (box), hbox);
gears = gtk_gears_new ();
gtk_widget_set_hexpand (gears, TRUE);
gtk_widget_set_vexpand (gears, TRUE);
gtk_box_append (GTK_BOX (hbox), gears);
for (i = 0; i < GTK_GEARS_N_AXIS; i++)
gtk_box_append (GTK_BOX (hbox), create_axis_slider (GTK_GEARS (gears), i));
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE);
gtk_box_set_spacing (GTK_BOX (hbox), 6);
gtk_box_append (GTK_BOX (box), hbox);
fps_label = gtk_label_new ("");
gtk_widget_set_hexpand (fps_label, TRUE);
gtk_widget_set_halign (fps_label, GTK_ALIGN_START);
gtk_box_append (GTK_BOX (hbox), fps_label);
gtk_gears_set_fps_label (GTK_GEARS (gears), GTK_LABEL (fps_label));
button = gtk_menu_button_new ();
gtk_menu_button_set_direction (GTK_MENU_BUTTON (button), GTK_ARROW_UP);
popover = gtk_popover_new ();
label = gtk_label_new ("Popovers work too!");
gtk_popover_set_child (GTK_POPOVER (popover), label);
gtk_menu_button_set_popover (GTK_MENU_BUTTON (button), popover);
gtk_box_append (GTK_BOX (hbox), button);
check = gtk_check_button_new_with_label ("Overlay");
gtk_box_append (GTK_BOX (hbox), check);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), FALSE);
g_signal_connect (check, "toggled",
G_CALLBACK (toggle_overlay), revealer);
check = gtk_check_button_new_with_label ("Animate spinner");
gtk_box_append (GTK_BOX (hbox), check);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), TRUE);
spinner = gtk_spinner_new ();
gtk_box_append (GTK_BOX (hbox), spinner);
gtk_spinner_start (GTK_SPINNER (spinner));
g_signal_connect (check, "toggled",
G_CALLBACK (toggle_spin), spinner);
scrolled = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_NEVER);
gtk_box_append (GTK_BOX (box), scrolled);
extra_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE);
gtk_box_set_spacing (GTK_BOX (extra_hbox), 6);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolled), extra_hbox);
bbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_set_spacing (GTK_BOX (bbox), 6);
gtk_box_append (GTK_BOX (box), bbox);
button = gtk_button_new_with_label ("Moar gears!");
gtk_box_append (GTK_BOX (bbox), button);
g_signal_connect (button, "clicked", G_CALLBACK (moar_gears), extra_hbox);
button = gtk_button_new_with_label ("Less gears!");
gtk_box_append (GTK_BOX (bbox), button);
g_signal_connect (button, "clicked", G_CALLBACK (less_gears), extra_hbox);
button = gtk_button_new_with_label ("Quit");
gtk_widget_set_hexpand (button, TRUE);
gtk_box_append (GTK_BOX (bbox), button);
g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_window_destroy), window);
gtk_widget_show (window);
while (!done)
g_main_context_iteration (NULL, TRUE);
return EXIT_SUCCESS;
}

View File

@ -10,7 +10,6 @@ gtk_tests = [
['scrolling-performance', ['frame-stats.c', 'variable.c']],
['blur-performance', ['../gsk/gskcairoblur.c']],
['simple'],
['print-editor'],
['video-timer', ['variable.c']],
['testaccel'],
['testadjustsize'],
@ -20,7 +19,6 @@ gtk_tests = [
['testbaseline'],
['testbox'],
['testbuttons'],
['testcairo'],
['testcalendar'],
['testclipboard2'],
['testcolorchooser'],
@ -114,7 +112,6 @@ gtk_tests = [
['teststackedheaders'],
['testwindowsize'],
['testpopover'],
['gdkgears', ['gtkgears.c']],
['listmodel'],
['testgaction'],
['testwidgetfocus'],
@ -156,5 +153,3 @@ if get_option('profiler')
executable('testperf', 'testperf.c',
dependencies: [profiler_dep, platform_gio_dep, libm])
endif
subdir('visuals')

View File

@ -1,223 +0,0 @@
/* testimage.c
* Copyright (C) 2005 Red Hat, Inc.
* Based on cairo-demo/X11/cairo-knockout.c
*
* Author: Owen Taylor
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include <math.h>
#include <gtk/gtk.h>
static void
oval_path (cairo_t *cr,
double xc, double yc,
double xr, double yr)
{
cairo_save (cr);
cairo_translate (cr, xc, yc);
cairo_scale (cr, 1.0, yr / xr);
cairo_move_to (cr, xr, 0.0);
cairo_arc (cr,
0, 0,
xr,
0, 2 * G_PI);
cairo_close_path (cr);
cairo_restore (cr);
}
/* Create a path that is a circular oval with radii xr, yr at xc,
* yc.
*/
/* Fill the given area with checks in the standard style
* for showing compositing effects.
*
* It would make sense to do this as a repeating surface,
* but most implementations of RENDER currently have broken
* implementations of repeat + transform, even when the
* transform is a translation.
*/
static void
fill_checks (cairo_t *cr,
int x, int y,
int width, int height)
{
int i, j;
#define CHECK_SIZE 32
cairo_rectangle (cr, x, y, width, height);
cairo_set_source_rgb (cr, 0.4, 0.4, 0.4);
cairo_fill (cr);
/* Only works for CHECK_SIZE a power of 2 */
j = x & (-CHECK_SIZE);
for (; j < height; j += CHECK_SIZE)
{
i = y & (-CHECK_SIZE);
for (; i < width; i += CHECK_SIZE)
if ((i / CHECK_SIZE + j / CHECK_SIZE) % 2 == 0)
cairo_rectangle (cr, i, j, CHECK_SIZE, CHECK_SIZE);
}
cairo_set_source_rgb (cr, 0.7, 0.7, 0.7);
cairo_fill (cr);
}
/* Draw a red, green, and blue circle equally spaced inside
* the larger circle of radius r at (xc, yc)
*/
static void
draw_3circles (cairo_t *cr,
double xc, double yc,
double radius,
double alpha)
{
double subradius = radius * (2 / 3. - 0.1);
cairo_set_source_rgba (cr, 1., 0., 0., alpha);
oval_path (cr,
xc + radius / 3. * cos (G_PI * (0.5)),
yc - radius / 3. * sin (G_PI * (0.5)),
subradius, subradius);
cairo_fill (cr);
cairo_set_source_rgba (cr, 0., 1., 0., alpha);
oval_path (cr,
xc + radius / 3. * cos (G_PI * (0.5 + 2/.3)),
yc - radius / 3. * sin (G_PI * (0.5 + 2/.3)),
subradius, subradius);
cairo_fill (cr);
cairo_set_source_rgba (cr, 0., 0., 1., alpha);
oval_path (cr,
xc + radius / 3. * cos (G_PI * (0.5 + 4/.3)),
yc - radius / 3. * sin (G_PI * (0.5 + 4/.3)),
subradius, subradius);
cairo_fill (cr);
}
static void
on_draw (GtkDrawingArea *darea,
cairo_t *cr,
int width,
int height,
gpointer data)
{
cairo_surface_t *overlay, *punch, *circles;
cairo_t *overlay_cr, *punch_cr, *circles_cr;
/* Fill the background */
double radius = 0.5 * (width < height ? width : height) - 10;
double xc = width / 2.;
double yc = height / 2.;
overlay = cairo_surface_create_similar (cairo_get_target (cr),
CAIRO_CONTENT_COLOR_ALPHA,
width, height);
punch = cairo_surface_create_similar (cairo_get_target (cr),
CAIRO_CONTENT_ALPHA,
width, height);
circles = cairo_surface_create_similar (cairo_get_target (cr),
CAIRO_CONTENT_COLOR_ALPHA,
width, height);
fill_checks (cr, 0, 0, width, height);
/* Draw a black circle on the overlay
*/
overlay_cr = cairo_create (overlay);
cairo_set_source_rgb (overlay_cr, 0., 0., 0.);
oval_path (overlay_cr, xc, yc, radius, radius);
cairo_fill (overlay_cr);
/* Draw 3 circles to the punch surface, then cut
* that out of the main circle in the overlay
*/
punch_cr = cairo_create (punch);
draw_3circles (punch_cr, xc, yc, radius, 1.0);
cairo_destroy (punch_cr);
cairo_set_operator (overlay_cr, CAIRO_OPERATOR_DEST_OUT);
cairo_set_source_surface (overlay_cr, punch, 0, 0);
cairo_paint (overlay_cr);
/* Now draw the 3 circles in a subgroup again
* at half intensity, and use OperatorAdd to join up
* without seams.
*/
circles_cr = cairo_create (circles);
cairo_set_operator (circles_cr, CAIRO_OPERATOR_OVER);
draw_3circles (circles_cr, xc, yc, radius, 0.5);
cairo_destroy (circles_cr);
cairo_set_operator (overlay_cr, CAIRO_OPERATOR_ADD);
cairo_set_source_surface (overlay_cr, circles, 0, 0);
cairo_paint (overlay_cr);
cairo_destroy (overlay_cr);
cairo_set_source_surface (cr, overlay, 0, 0);
cairo_paint (cr);
cairo_surface_destroy (overlay);
cairo_surface_destroy (punch);
cairo_surface_destroy (circles);
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char **argv)
{
GtkWidget *window, *darea;
gboolean done = FALSE;
gtk_init ();
window = gtk_window_new ();
gtk_window_set_default_size (GTK_WINDOW (window), 400, 400);
gtk_window_set_title (GTK_WINDOW (window), "cairo: Knockout Groups");
darea = gtk_drawing_area_new ();
gtk_window_set_child (GTK_WINDOW (window), darea);
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (darea), on_draw, NULL, NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -1,148 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<property name="default_width">600</property>
<property name="default_height">600</property>
<child>
<object class="GtkBox" id="box1">
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<property name="visible">True</property>
<property name="vexpand">True</property>
<property name="hexpand">True</property>
<child>
<object class="GtkGrid" id="grid1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="row_spacing">12</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="label">Continuous values</property>
</object>
</child>
<child>
<object class="GtkLevelBar" id="str1">
<property name="visible">True</property>
<property name="hexpand">true</property>
<property name="value">0.09</property>
<offsets>
<offset name="low" value="0.09"/>
<offset name="high" value="0.65"/>
</offsets>
</object>
</child>
<child>
<object class="GtkLevelBar" id="str2">
<property name="visible">True</property>
<property name="hexpand">true</property>
<property name="value">0.20</property>
</object>
</child>
<child>
<object class="GtkLevelBar" id="str3">
<property name="visible">True</property>
<property name="hexpand">true</property>
<property name="value">0.5</property>
</object>
</child>
<child>
<object class="GtkLevelBar" id="str4">
<property name="visible">True</property>
<property name="hexpand">true</property>
<property name="value">1.0</property>
</object>
</child>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="label">Discrete values</property>
</object>
</child>
<child>
<object class="GtkLevelBar" id="str1d">
<property name="visible">True</property>
<property name="hexpand">true</property>
<property name="value">2.8</property>
<property name="min_value">0.0</property>
<property name="max_value">5.0</property>
<property name="mode">discrete</property>
<offsets>
<offset name="low" value="1.0"/>
<offset name="high" value="4.0"/>
</offsets>
</object>
</child>
</object>
</child>
<child>
<object class="GtkGrid" id="grid2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">horizontal</property>
<property name="column_spacing">12</property>
<property name="halign">center</property>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="label">Continuous values</property>
</object>
</child>
<child>
<object class="GtkLevelBar" id="str5">
<property name="visible">True</property>
<property name="vexpand">true</property>
<property name="orientation">vertical</property>
<property name="value">0.09</property>
</object>
</child>
<child>
<object class="GtkLevelBar" id="str6">
<property name="visible">True</property>
<property name="vexpand">true</property>
<property name="orientation">vertical</property>
<property name="value">0.2</property>
</object>
</child>
<child>
<object class="GtkLevelBar" id="str7">
<property name="visible">True</property>
<property name="vexpand">true</property>
<property name="orientation">vertical</property>
<property name="value">0.5</property>
</object>
</child>
<child>
<object class="GtkLevelBar" id="str8">
<property name="visible">True</property>
<property name="vexpand">true</property>
<property name="orientation">vertical</property>
<property name="value">1.0</property>
</object>
</child>
<child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="label">Discrete values</property>
</object>
</child>
<child>
<object class="GtkLevelBar" id="str2d">
<property name="visible">True</property>
<property name="vexpand">true</property>
<property name="orientation">vertical</property>
<property name="value">15.0</property>
<property name="min_value">10.0</property>
<property name="max_value">15.0</property>
<property name="mode">discrete</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>

View File

@ -1,51 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<property name="default_width">600</property>
<property name="default_height">600</property>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">horizontal</property>
<property name="valign">center</property>
<property name="halign">center</property>
<style>
<class name="linked"/>
</style>
<child>
<object class="GtkButton" id="button1">
<property name="label" translatable="yes">Hi, I am a button</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
</object>
</child>
<child>
<object class="GtkButton" id="button2">
<property name="label" translatable="yes">And I'm another button</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
</object>
</child>
<child>
<object class="GtkButton" id="button3">
<property name="label" translatable="yes">This is a button party!</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
</object>
</child>
</object>
</child>
</object>
</interface>

View File

@ -1,51 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<property name="default_width">600</property>
<property name="default_height">600</property>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="valign">center</property>
<property name="halign">center</property>
<style>
<class name="linked"/>
</style>
<child>
<object class="GtkButton" id="button1">
<property name="label" translatable="yes">Hi, I am a button</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
</object>
</child>
<child>
<object class="GtkButton" id="button2">
<property name="label" translatable="yes">And I'm another button</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
</object>
</child>
<child>
<object class="GtkButton" id="button3">
<property name="label" translatable="yes">This is a button party!</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
</object>
</child>
</object>
</child>
</object>
</interface>

View File

@ -1 +0,0 @@
executable('visuals', 'visuals.c', dependencies: libgtk_dep)

View File

@ -1,168 +0,0 @@
<interface>
<object class="GtkWindow" id="window1">
<property name="default_width">600</property>
<property name="default_height">600</property>
<child>
<object class="GtkOverlay" id="overlay1">
<child>
<object class="GtkDrawingArea" id="filler"/>
</child>
<child type="overlay">
<object class="GtkToolbar" id="bottom_toolbar">
<property name="show_arrow">0</property>
<property name="halign">center</property>
<property name="valign">end</property>
<property name="margin_bottom">24</property>
<style>
<class name="osd"/>
</style>
<child>
<object class="GtkToolItem" id="left_item">
<child>
<object class="GtkBox" id="left_box">
<child>
<object class="GtkToggleButton" id="camera">
<child>
<object class="GtkImage" id="camera_icon">
<property name="icon_name">camera-web-symbolic</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkToggleButton" id="volume">
<property name="active">1</property>
<child>
<object class="GtkImage" id="volume_icon">
<property name="icon_name">audio-volume-medium-symbolic</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkToggleButton" id="microphone">
<property name="sensitive">0</property>
<child>
<object class="GtkImage" id="microphone_icon">
<property name="icon_name">audio-input-microphone-symbolic</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkToggleButton" id="bt">
<property name="sensitive">0</property>
<property name="active">1</property>
<child>
<object class="GtkImage" id="bt_icon">
<property name="icon_name">bluetooth-active-symbolic</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkSeparatorToolItem" id="toolbutton2">
<property name="expand-item">True</property>
<property name="draw">0</property>
</object>
</child>
<child>
<object class="GtkToolItem" id="toolitem4">
<child>
<object class="GtkLabel" id="status_label">
<property name="label">OSD Toolbar</property>
<property name="margin_start">10</property>
<property name="margin_end">10</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkToolItem" id="right_item">
<child>
<object class="GtkBox" id="right_box">
<child>
<object class="GtkToggleButton" id="opt">
<child>
<object class="GtkImage" id="opt_icon">
<property name="icon_name">media-optical-symbolic</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkToggleButton" id="hdd">
<property name="active">1</property>
<child>
<object class="GtkImage" id="hdd_icon">
<property name="icon_name">drive-harddisk-symbolic</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkToggleButton" id="joy">
<property name="sensitive">0</property>
<child>
<object class="GtkImage" id="joy_icon">
<property name="icon_name">input-gaming-symbolic</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child type="overlay">
<object class="GtkToolbar" id="top_toolbar">
<property name="show_arrow">0</property>
<property name="halign">center</property>
<property name="valign">start</property>
<property name="margin_top">24</property>
<style>
<class name="osd"/>
</style>
<child>
<object class="GtkToggleToolButton" id="tb1">
<property name="icon_name">edit-undo-symbolic</property>
</object>
</child>
<child>
<object class="GtkToggleToolButton" id="tb2">
<property name="icon_name">edit-redo-symbolic</property>
</object>
</child>
<child>
<object class="GtkToggleToolButton" id="tb3">
<property name="icon_name">start-here-symbolic</property>
</object>
</child>
<child>
<object class="GtkToggleToolButton" id="tb4">
<property name="icon_name">applications-science-symbolic</property>
</object>
</child>
<child>
<object class="GtkToolItem" id="tb5">
<child>
<object class="GtkLabel" id="tb5_label">
<property name="label">Another kind of OSD toolbar</property>
<property name="margin_start">10</property>
<property name="margin_end">10</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>

View File

@ -1,80 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<property name="default_width">600</property>
<property name="default_height">600</property>
<child>
<object class="GtkBox" id="containerbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="valign">center</property>
<property name="halign">center</property>
<property name="spacing">6</property>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">horizontal</property>
<property name="valign">center</property>
<property name="halign">center</property>
<property name="spacing">6</property>
<child>
<object class="GtkButton" id="button1">
<property name="label" translatable="yes">Hi, I am a button</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
</object>
</child>
<child>
<object class="GtkToggleButton" id="button2">
<property name="label" translatable="yes">And I'm the suggested action</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<style>
<class name="suggested-action"/>
</style>
</object>
</child>
</object>
</child>
<child>
<object class="GtkToolbar" id="toolbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">horizontal</property>
<style>
<class name="selection-mode"/>
<class name="menubar"/>
</style>
<child>
<object class="GtkToggleToolButton" id="toolbutton7">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Inside selection mode</property>
<property name="use_underline">True</property>
<property name="is_important">True</property>
<style>
<class name="suggested-action"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>

View File

@ -1,95 +0,0 @@
/* visuals: UI runner for visual GtkBuilder files
*
* Copyright (C) 2012 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free
*
* Author: Cosimo Cecchi <cosimoc@gnome.org>
*
*/
#include <gtk/gtk.h>
static void
dark_button_toggled_cb (GtkToggleButton *button,
gpointer user_data)
{
gboolean active = gtk_toggle_button_get_active (button);
GtkSettings *settings = gtk_settings_get_default ();
g_object_set (settings,
"gtk-application-prefer-dark-theme", active,
NULL);
}
static void
create_dark_popup (GtkWidget *parent)
{
GtkWidget *popup = gtk_window_new ();
GtkWidget *button = gtk_toggle_button_new_with_label ("Dark");
gtk_window_set_decorated (GTK_WINDOW (popup), FALSE);
gtk_widget_set_size_request (popup, 100, 100);
gtk_window_set_resizable (GTK_WINDOW (popup), FALSE);
gtk_window_set_hide_on_close (GTK_WINDOW (popup), TRUE);
gtk_window_set_child (GTK_WINDOW (popup), button);
g_signal_connect (button, "toggled",
G_CALLBACK (dark_button_toggled_cb), NULL);
gtk_window_set_transient_for (GTK_WINDOW (popup), GTK_WINDOW (parent));
gtk_widget_show (popup);
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char *argv[])
{
GtkBuilder *builder;
GtkWidget *window;
const gchar *filename;
gboolean done = FALSE;
gtk_init ();
if (argc < 2)
return 1;
filename = argv[1];
builder = gtk_builder_new ();
gtk_builder_add_from_file (builder, filename, NULL);
window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
g_object_unref (G_OBJECT (builder));
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
create_dark_popup (window);
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}