Merge branch 'matthiasc/for-master' into 'master'
gtk-demo polish See merge request GNOME/gtk!2773
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* Constraints/Simple
|
||||
/* Constraints/Simple Constraints
|
||||
* #Keywords: GtkLayoutManager
|
||||
*
|
||||
* GtkConstraintLayout provides a layout manager that uses relations
|
||||
@@ -263,7 +263,8 @@ do_constraints (GtkWidget *do_widget)
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Constraints");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Simple Constraints");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 260, -1);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkWindow" id="window1">
|
||||
<property name="title" translatable="yes">Constraints</property>
|
||||
<property name="title" translatable="yes">Constraints — Builder</property>
|
||||
<property name="default-width">260</property>
|
||||
<child>
|
||||
<object class="ConstraintsGrid">
|
||||
<property name="layout-manager">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Constraints/Interactive
|
||||
/* Constraints/Interactive Constraints
|
||||
* #Keywords: GtkConstraintLayout
|
||||
*
|
||||
* This example shows how constraints can be updated during user interaction.
|
||||
@@ -215,7 +215,8 @@ do_constraints2 (GtkWidget *do_widget)
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Constraints");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Interactive Constraints");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 260, -1);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
||||
|
||||
@@ -138,7 +138,8 @@ do_constraints3 (GtkWidget *do_widget)
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Constraints");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Constraints — VFL");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 260, -1);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
||||
|
||||
@@ -44,11 +44,23 @@ G_DEFINE_TYPE_WITH_CODE (DemoTaggedEntry, demo_tagged_entry, GTK_TYPE_WIDGET,
|
||||
static void
|
||||
demo_tagged_entry_init (DemoTaggedEntry *entry)
|
||||
{
|
||||
GtkCssProvider *provider;
|
||||
|
||||
entry->text = gtk_text_new ();
|
||||
gtk_widget_set_hexpand (entry->text, TRUE);
|
||||
gtk_widget_set_vexpand (entry->text, TRUE);
|
||||
gtk_widget_set_parent (entry->text, GTK_WIDGET (entry));
|
||||
gtk_editable_init_delegate (GTK_EDITABLE (entry));
|
||||
gtk_editable_set_width_chars (GTK_EDITABLE (entry->text), 6);
|
||||
gtk_editable_set_max_width_chars (GTK_EDITABLE (entry->text), 6);
|
||||
gtk_widget_add_css_class (GTK_WIDGET (entry), "tagged");
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_resource (provider, "/tagged_entry/tagstyle.css");
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
800);
|
||||
g_object_unref (provider);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -212,7 +224,6 @@ static void
|
||||
demo_tagged_entry_tag_init (DemoTaggedEntryTag *tag)
|
||||
{
|
||||
GtkGesture *gesture;
|
||||
GtkCssProvider *provider;
|
||||
|
||||
tag->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_widget_set_parent (tag->box, GTK_WIDGET (tag));
|
||||
@@ -222,13 +233,6 @@ demo_tagged_entry_tag_init (DemoTaggedEntryTag *tag)
|
||||
gesture = gtk_gesture_click_new ();
|
||||
g_signal_connect (gesture, "released", G_CALLBACK (on_released), tag);
|
||||
gtk_widget_add_controller (GTK_WIDGET (tag), GTK_EVENT_CONTROLLER (gesture));
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_resource (provider, "/tagged_entry/tagstyle.css");
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
800);
|
||||
g_object_unref (provider);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -325,9 +325,8 @@ do_drawingarea (GtkWidget *do_widget)
|
||||
/*
|
||||
* Create the groups area
|
||||
*/
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"<u>Knockout groups</u>");
|
||||
label = gtk_label_new ("Knockout groups");
|
||||
gtk_widget_add_css_class (label, "heading");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
@@ -344,9 +343,8 @@ do_drawingarea (GtkWidget *do_widget)
|
||||
* Create the scribble area
|
||||
*/
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"<u>Scribble area</u>");
|
||||
label = gtk_label_new ("Scribble area");
|
||||
gtk_widget_add_css_class (label, "heading");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
|
||||
@@ -78,11 +78,11 @@ do_entry_completion (GtkWidget *do_widget)
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
|
||||
gtk_widget_set_margin_start (vbox, 5);
|
||||
gtk_widget_set_margin_end (vbox, 5);
|
||||
gtk_widget_set_margin_top (vbox, 5);
|
||||
gtk_widget_set_margin_bottom (vbox, 5);
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
||||
gtk_widget_set_margin_start (vbox, 18);
|
||||
gtk_widget_set_margin_end (vbox, 18);
|
||||
gtk_widget_set_margin_top (vbox, 18);
|
||||
gtk_widget_set_margin_bottom (vbox, 18);
|
||||
gtk_window_set_child (GTK_WINDOW (window), vbox);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
|
||||
@@ -27,16 +27,16 @@ do_entry_undo (GtkWidget *do_widget)
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
|
||||
gtk_widget_set_margin_start (vbox, 5);
|
||||
gtk_widget_set_margin_end (vbox, 5);
|
||||
gtk_widget_set_margin_top (vbox, 5);
|
||||
gtk_widget_set_margin_bottom (vbox, 5);
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
||||
gtk_widget_set_margin_start (vbox, 18);
|
||||
gtk_widget_set_margin_end (vbox, 18);
|
||||
gtk_widget_set_margin_top (vbox, 18);
|
||||
gtk_widget_set_margin_bottom (vbox, 18);
|
||||
gtk_window_set_child (GTK_WINDOW (window), vbox);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"Use Primary+z or Primary+Shift+z to undo or redo changes");
|
||||
"Use Control+z or Control+Shift+z to undo or redo changes");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
/* Create our entry */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Error states
|
||||
/* Error States
|
||||
*
|
||||
* GtkLabel and GtkEntry can indicate errors if you set the .error
|
||||
* style class on them.
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<property name="modal">1</property>
|
||||
<property name="resizable">0</property>
|
||||
<property name="use-header-bar">1</property>
|
||||
<property name="title" translatable="yes">Settings</property>
|
||||
<property name="title" translatable="yes">Error States</property>
|
||||
<property name="hide-on-close">1</property>
|
||||
<child internal-child="content_area">
|
||||
<object class="GtkBox">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Pango/Font rendering
|
||||
/* Pango/Font Rendering
|
||||
*
|
||||
* Demonstrates various aspects of font rendering.
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* OpenGL/Transitions
|
||||
/* OpenGL/Transitions and Effects
|
||||
* #Keywords: OpenGL, shader, effect
|
||||
*
|
||||
* Create transitions between pages using a custom fragment shader.
|
||||
@@ -282,11 +282,12 @@ create_gltransition_window (GtkWidget *do_widget)
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Transitions");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Transitions and Effects");
|
||||
headerbar = gtk_header_bar_new ();
|
||||
scale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, NULL);
|
||||
gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
|
||||
gtk_widget_set_size_request (scale, 100, -1);
|
||||
gtk_widget_set_tooltip_text (scale, "Transition duration");
|
||||
gtk_header_bar_pack_end (GTK_HEADER_BAR (headerbar), scale);
|
||||
gtk_window_set_titlebar (GTK_WINDOW (window), headerbar);
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 800, 600);
|
||||
|
||||
@@ -346,9 +346,8 @@ do_images (GtkWidget *do_widget)
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
|
||||
gtk_box_append (GTK_BOX (hbox), vbox);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"<u>Image loaded from a file</u>");
|
||||
label = gtk_label_new ("Image loaded from a file");
|
||||
gtk_widget_add_css_class (label, "heading");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
@@ -364,9 +363,8 @@ do_images (GtkWidget *do_widget)
|
||||
|
||||
/* Animation */
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"<u>Animation loaded from a file</u>");
|
||||
label = gtk_label_new ("Animation loaded from a file");
|
||||
gtk_widget_add_css_class (label, "heading");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
@@ -380,9 +378,8 @@ do_images (GtkWidget *do_widget)
|
||||
|
||||
/* Symbolic icon */
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"<u>Symbolic themed icon</u>");
|
||||
label = gtk_label_new ("Symbolic themed icon");
|
||||
gtk_widget_add_css_class (label, "heading");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
@@ -401,9 +398,8 @@ do_images (GtkWidget *do_widget)
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
|
||||
gtk_box_append (GTK_BOX (hbox), vbox);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"<u>Progressive image loading</u>");
|
||||
label = gtk_label_new ("Progressive image loading");
|
||||
gtk_widget_add_css_class (label, "heading");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
@@ -424,9 +420,8 @@ do_images (GtkWidget *do_widget)
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
|
||||
gtk_box_append (GTK_BOX (hbox), vbox);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"<u>Displaying video</u>");
|
||||
label = gtk_label_new ("Displaying video");
|
||||
gtk_widget_add_css_class (label, "heading");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
@@ -442,9 +437,8 @@ do_images (GtkWidget *do_widget)
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
|
||||
gtk_box_append (GTK_BOX (hbox), vbox);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"<u>GtkWidgetPaintable</u>");
|
||||
label = gtk_label_new ("GtkWidgetPaintable");
|
||||
gtk_widget_add_css_class (label, "heading");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
paintable = gtk_widget_paintable_new (do_widget);
|
||||
|
||||
@@ -34,7 +34,7 @@ do_layoutmanager (GtkWidget *parent)
|
||||
int i;
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Layout Manager—Transition");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Layout Manager — Transition");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 600, 600);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ do_layoutmanager2 (GtkWidget *parent)
|
||||
int i;
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Layout Manager—Transformation");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Layout Manager — Transformation");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 600, 620);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* List Box/Complex list
|
||||
/* List Box/Complex
|
||||
*
|
||||
* GtkListBox allows lists with complicated layouts, using
|
||||
* regular widgets supporting sorting and filtering.
|
||||
@@ -349,7 +349,7 @@ do_listbox (GtkWidget *do_widget)
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "List Box");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "List Box — Complex");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 400, 600);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Paintable/A simple paintable
|
||||
/* Paintable/Simple Paintable
|
||||
*
|
||||
* GdkPaintable is an interface used by GTK for drawings of any sort
|
||||
* that do not require layouting or positioning.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Paintable/An animated paintable
|
||||
/* Paintable/Animated Paintable
|
||||
*
|
||||
* GdkPaintable also allows paintables to change.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Paintable/A media stream
|
||||
/* Paintable/Media Stream
|
||||
*
|
||||
* GdkPaintable is also used by the GtkMediaStream class.
|
||||
*
|
||||
|
||||
@@ -3,100 +3,16 @@
|
||||
* The GtkPaned Widget divides its content area into two panes
|
||||
* with a divider in between that the user can adjust. A separate
|
||||
* child is placed into each pane. GtkPaned widgets can be split
|
||||
* horizontally or vertially.
|
||||
* horizontally or vertically. This test contains both a horizontal
|
||||
* and a vertical GtkPaned widget.
|
||||
*
|
||||
* There are a number of options that can be set for each pane.
|
||||
* This test contains both a horizontal and a vertical GtkPaned
|
||||
* widget, and allows you to adjust the options for each side of
|
||||
* each widget.
|
||||
* You can use the Inspector to adjust the options for each side
|
||||
* of each widget.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static void
|
||||
toggle_resize (GtkWidget *widget,
|
||||
GtkWidget *child)
|
||||
{
|
||||
GtkWidget *parent;
|
||||
GtkPaned *paned;
|
||||
|
||||
parent = gtk_widget_get_parent (child);
|
||||
paned = GTK_PANED (parent);
|
||||
|
||||
if (child == gtk_paned_get_start_child (paned))
|
||||
gtk_paned_set_resize_start_child (paned, !gtk_paned_get_resize_start_child (paned));
|
||||
else
|
||||
gtk_paned_set_resize_end_child (paned, !gtk_paned_get_resize_end_child (paned));
|
||||
}
|
||||
|
||||
static void
|
||||
toggle_shrink (GtkWidget *widget,
|
||||
GtkWidget *child)
|
||||
{
|
||||
GtkWidget *parent;
|
||||
GtkPaned *paned;
|
||||
|
||||
parent = gtk_widget_get_parent (child);
|
||||
paned = GTK_PANED (parent);
|
||||
|
||||
if (child == gtk_paned_get_start_child (paned))
|
||||
gtk_paned_set_shrink_start_child (paned, !gtk_paned_get_shrink_start_child (paned));
|
||||
else
|
||||
gtk_paned_set_shrink_end_child (paned, !gtk_paned_get_shrink_end_child (paned));
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
create_pane_options (GtkPaned *paned,
|
||||
const char *frame_label,
|
||||
const char *label1,
|
||||
const char *label2)
|
||||
{
|
||||
GtkWidget *child1, *child2;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *table;
|
||||
GtkWidget *label;
|
||||
GtkWidget *check_button;
|
||||
|
||||
child1 = gtk_paned_get_start_child (paned);
|
||||
child2 = gtk_paned_get_end_child (paned);
|
||||
|
||||
frame = gtk_frame_new (frame_label);
|
||||
|
||||
table = gtk_grid_new ();
|
||||
gtk_frame_set_child (GTK_FRAME (frame), table);
|
||||
|
||||
label = gtk_label_new (label1);
|
||||
gtk_grid_attach (GTK_GRID (table), label, 0, 0, 1, 1);
|
||||
|
||||
check_button = gtk_check_button_new_with_mnemonic ("_Resize");
|
||||
gtk_grid_attach (GTK_GRID (table), check_button, 0, 1, 1, 1);
|
||||
g_signal_connect (check_button, "toggled",
|
||||
G_CALLBACK (toggle_resize), child1);
|
||||
|
||||
check_button = gtk_check_button_new_with_mnemonic ("_Shrink");
|
||||
gtk_grid_attach (GTK_GRID (table), check_button, 0, 2, 1, 1);
|
||||
gtk_check_button_set_active (GTK_CHECK_BUTTON (check_button), TRUE);
|
||||
g_signal_connect (check_button, "toggled",
|
||||
G_CALLBACK (toggle_shrink), child1);
|
||||
|
||||
label = gtk_label_new (label2);
|
||||
gtk_grid_attach (GTK_GRID (table), label, 1, 0, 1, 1);
|
||||
|
||||
check_button = gtk_check_button_new_with_mnemonic ("_Resize");
|
||||
gtk_grid_attach (GTK_GRID (table), check_button, 1, 1, 1, 1);
|
||||
gtk_check_button_set_active (GTK_CHECK_BUTTON (check_button), TRUE);
|
||||
g_signal_connect (check_button, "toggled",
|
||||
G_CALLBACK (toggle_resize), child2);
|
||||
|
||||
check_button = gtk_check_button_new_with_mnemonic ("_Shrink");
|
||||
gtk_grid_attach (GTK_GRID (table), check_button, 1, 2, 1, 1);
|
||||
gtk_check_button_set_active (GTK_CHECK_BUTTON (check_button), TRUE);
|
||||
g_signal_connect (check_button, "toggled",
|
||||
G_CALLBACK (toggle_shrink), child2);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_panes (GtkWidget *do_widget)
|
||||
{
|
||||
@@ -104,19 +20,19 @@ do_panes (GtkWidget *do_widget)
|
||||
GtkWidget *frame;
|
||||
GtkWidget *hpaned;
|
||||
GtkWidget *vpaned;
|
||||
GtkWidget *button;
|
||||
GtkWidget *label;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *box;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Paned Widgets");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 330, 250);
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Paned Widgets");
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
|
||||
gtk_widget_set_margin_start (vbox, 8);
|
||||
gtk_widget_set_margin_end (vbox, 8);
|
||||
@@ -132,41 +48,37 @@ do_panes (GtkWidget *do_widget)
|
||||
|
||||
hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
|
||||
gtk_paned_set_start_child (GTK_PANED (vpaned), hpaned);
|
||||
gtk_paned_set_shrink_start_child (GTK_PANED (vpaned), FALSE);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_widget_set_size_request (box, 60, 60);
|
||||
gtk_paned_set_start_child (GTK_PANED (hpaned), box);
|
||||
label = gtk_label_new ("Hi there");
|
||||
gtk_widget_set_margin_start (label, 4);
|
||||
gtk_widget_set_margin_end (label, 4);
|
||||
gtk_widget_set_margin_top (label, 4);
|
||||
gtk_widget_set_margin_bottom (label, 4);
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
gtk_widget_set_vexpand (label, TRUE);
|
||||
gtk_paned_set_start_child (GTK_PANED (hpaned), label);
|
||||
gtk_paned_set_shrink_start_child (GTK_PANED (hpaned), FALSE);
|
||||
|
||||
button = gtk_button_new_with_mnemonic ("_Hi there");
|
||||
gtk_widget_set_margin_start (button, 4);
|
||||
gtk_widget_set_margin_end (button, 4);
|
||||
gtk_widget_set_margin_top (button, 4);
|
||||
gtk_widget_set_margin_bottom (button, 4);
|
||||
gtk_widget_set_hexpand (button, TRUE);
|
||||
gtk_widget_set_vexpand (button, TRUE);
|
||||
gtk_box_append (GTK_BOX (box), button);
|
||||
label = gtk_label_new ("Hello");
|
||||
gtk_widget_set_margin_start (label, 4);
|
||||
gtk_widget_set_margin_end (label, 4);
|
||||
gtk_widget_set_margin_top (label, 4);
|
||||
gtk_widget_set_margin_bottom (label, 4);
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
gtk_widget_set_vexpand (label, TRUE);
|
||||
gtk_paned_set_end_child (GTK_PANED (hpaned), label);
|
||||
gtk_paned_set_shrink_end_child (GTK_PANED (hpaned), FALSE);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_widget_set_size_request (box, 80, 60);
|
||||
gtk_paned_set_end_child (GTK_PANED (hpaned), box);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_widget_set_size_request (box, 60, 80);
|
||||
gtk_paned_set_end_child (GTK_PANED (vpaned), box);
|
||||
|
||||
/* Now create toggle buttons to control sizing */
|
||||
|
||||
gtk_box_append (GTK_BOX (vbox),
|
||||
create_pane_options (GTK_PANED (hpaned),
|
||||
"Horizontal",
|
||||
"Left",
|
||||
"Right"));
|
||||
|
||||
gtk_box_append (GTK_BOX (vbox),
|
||||
create_pane_options (GTK_PANED (vpaned),
|
||||
"Vertical",
|
||||
"Top",
|
||||
"Bottom"));
|
||||
label = gtk_label_new ("Goodbye");
|
||||
gtk_widget_set_margin_start (label, 4);
|
||||
gtk_widget_set_margin_end (label, 4);
|
||||
gtk_widget_set_margin_top (label, 4);
|
||||
gtk_widget_set_margin_bottom (label, 4);
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
gtk_widget_set_vexpand (label, TRUE);
|
||||
gtk_paned_set_end_child (GTK_PANED (vpaned), label);
|
||||
gtk_paned_set_shrink_end_child (GTK_PANED (vpaned), FALSE);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
|
||||
@@ -110,17 +110,17 @@ set_search_by (GSimpleAction *action,
|
||||
if (g_str_equal (term, "name"))
|
||||
{
|
||||
gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, "Search by name");
|
||||
gtk_entry_set_placeholder_text (entry, "name");
|
||||
gtk_entry_set_placeholder_text (entry, "Name…");
|
||||
}
|
||||
else if (g_str_equal (term, "description"))
|
||||
{
|
||||
gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, "Search by description");
|
||||
gtk_entry_set_placeholder_text (entry, "description");
|
||||
gtk_entry_set_placeholder_text (entry, "Description…");
|
||||
}
|
||||
else if (g_str_equal (term, "filename"))
|
||||
{
|
||||
gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, "Search by file name");
|
||||
gtk_entry_set_placeholder_text (entry, "file name");
|
||||
gtk_entry_set_placeholder_text (entry, "File name…");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,7 +254,6 @@ do_search_entry (GtkWidget *do_widget)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *label;
|
||||
GtkWidget *entry;
|
||||
GtkWidget *find_button;
|
||||
GtkWidget *cancel_button;
|
||||
@@ -268,18 +267,14 @@ do_search_entry (GtkWidget *do_widget)
|
||||
|
||||
g_object_weak_ref (G_OBJECT (window), search_entry_destroyed, &window);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
|
||||
gtk_widget_set_margin_start (vbox, 5);
|
||||
gtk_widget_set_margin_end (vbox, 5);
|
||||
gtk_widget_set_margin_top (vbox, 5);
|
||||
gtk_widget_set_margin_bottom (vbox, 5);
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
||||
gtk_widget_set_margin_start (vbox, 18);
|
||||
gtk_widget_set_margin_end (vbox, 18);
|
||||
gtk_widget_set_margin_top (vbox, 18);
|
||||
gtk_widget_set_margin_bottom (vbox, 18);
|
||||
gtk_window_set_child (GTK_WINDOW (window), vbox);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label), "Search entry demo");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
|
||||
gtk_box_append (GTK_BOX (vbox), hbox);
|
||||
|
||||
/* Create our entry */
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/* Entry/Delayed Search Entry
|
||||
/* Entry/Type to Search
|
||||
*
|
||||
* GtkSearchEntry provides an entry that is ready for search.
|
||||
*
|
||||
* Search entries have their "changed" signal delayed and should
|
||||
* be used when the searched operation is slow such as loads of
|
||||
* entries to search, or online searches.
|
||||
* Search entries have their "search-changed" signal delayed and
|
||||
* should be used when the search operation is slow, such as big
|
||||
* datasets to search, or online searches.
|
||||
*
|
||||
* GtkSearchBar allows have a hidden search entry that 'springs
|
||||
* into action' upon keyboard input.
|
||||
@@ -18,101 +18,69 @@ search_changed_cb (GtkSearchEntry *entry,
|
||||
{
|
||||
const char *text;
|
||||
text = gtk_editable_get_text (GTK_EDITABLE (entry));
|
||||
g_message ("search changed: %s", text);
|
||||
gtk_label_set_text (result_label, text ? text : "");
|
||||
}
|
||||
|
||||
static void
|
||||
changed_cb (GtkEditable *editable)
|
||||
{
|
||||
const char *text;
|
||||
text = gtk_editable_get_text (GTK_EDITABLE (editable));
|
||||
g_message ("changed: %s", text);
|
||||
}
|
||||
|
||||
static void
|
||||
search_changed (GtkSearchEntry *entry,
|
||||
GtkLabel *label)
|
||||
{
|
||||
gtk_label_set_text (label, "search-changed");
|
||||
}
|
||||
|
||||
static void
|
||||
next_match (GtkSearchEntry *entry,
|
||||
GtkLabel *label)
|
||||
{
|
||||
gtk_label_set_text (label, "next-match");
|
||||
}
|
||||
|
||||
static void
|
||||
previous_match (GtkSearchEntry *entry,
|
||||
GtkLabel *label)
|
||||
{
|
||||
gtk_label_set_text (label, "previous-match");
|
||||
}
|
||||
|
||||
static void
|
||||
stop_search (GtkSearchEntry *entry,
|
||||
GtkLabel *label)
|
||||
{
|
||||
gtk_label_set_text (label, "stop-search");
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_search_entry2 (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *box;
|
||||
GtkWidget *label;
|
||||
GtkWidget *entry;
|
||||
GtkWidget *container;
|
||||
GtkWidget *searchbar;
|
||||
GtkWidget *button;
|
||||
GtkWidget *header;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Delayed Search Entry");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Type to Search");
|
||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
gtk_widget_set_size_request (window, 200, -1);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
header = gtk_header_bar_new ();
|
||||
gtk_window_set_titlebar (GTK_WINDOW (window), header);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_window_set_child (GTK_WINDOW (window), vbox);
|
||||
|
||||
entry = gtk_search_entry_new ();
|
||||
container = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
||||
gtk_widget_set_halign (container, GTK_ALIGN_CENTER);
|
||||
gtk_box_append (GTK_BOX (container), entry);
|
||||
gtk_widget_set_halign (entry, GTK_ALIGN_CENTER);
|
||||
searchbar = gtk_search_bar_new ();
|
||||
gtk_search_bar_connect_entry (GTK_SEARCH_BAR (searchbar), GTK_EDITABLE (entry));
|
||||
gtk_search_bar_set_show_close_button (GTK_SEARCH_BAR (searchbar), FALSE);
|
||||
gtk_search_bar_set_child (GTK_SEARCH_BAR (searchbar), container);
|
||||
gtk_search_bar_set_child (GTK_SEARCH_BAR (searchbar), entry);
|
||||
gtk_box_append (GTK_BOX (vbox), searchbar);
|
||||
|
||||
/* Hook the search bar to key presses */
|
||||
gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (searchbar), window);
|
||||
|
||||
/* Help */
|
||||
label = gtk_label_new ("Start Typing to search");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);
|
||||
gtk_widget_set_margin_start (box, 18);
|
||||
gtk_widget_set_margin_end (box, 18);
|
||||
gtk_widget_set_margin_top (box, 18);
|
||||
gtk_widget_set_margin_bottom (box, 18);
|
||||
gtk_box_append (GTK_BOX (vbox), box);
|
||||
|
||||
/* Toggle button */
|
||||
button = gtk_toggle_button_new_with_label ("Search");
|
||||
button = gtk_toggle_button_new ();
|
||||
gtk_button_set_icon_name (GTK_BUTTON (button), "system-search-symbolic");
|
||||
g_object_bind_property (button, "active",
|
||||
searchbar, "search-mode-enabled",
|
||||
G_BINDING_BIDIRECTIONAL);
|
||||
gtk_box_append (GTK_BOX (vbox), button);
|
||||
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
|
||||
|
||||
/* Result */
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
||||
gtk_box_append (GTK_BOX (vbox), hbox);
|
||||
gtk_box_append (GTK_BOX (box), hbox);
|
||||
|
||||
label = gtk_label_new ("Result:");
|
||||
label = gtk_label_new ("Searching for:");
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
||||
gtk_widget_set_margin_start (label, 6);
|
||||
gtk_box_append (GTK_BOX (hbox), label);
|
||||
|
||||
label = gtk_label_new ("");
|
||||
@@ -120,28 +88,6 @@ do_search_entry2 (GtkWidget *do_widget)
|
||||
|
||||
g_signal_connect (entry, "search-changed",
|
||||
G_CALLBACK (search_changed_cb), label);
|
||||
g_signal_connect (entry, "changed",
|
||||
G_CALLBACK (changed_cb), label);
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
||||
gtk_box_append (GTK_BOX (vbox), hbox);
|
||||
|
||||
label = gtk_label_new ("Signal:");
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
||||
gtk_widget_set_margin_start (label, 6);
|
||||
gtk_box_append (GTK_BOX (hbox), label);
|
||||
|
||||
label = gtk_label_new ("");
|
||||
gtk_box_append (GTK_BOX (hbox), label);
|
||||
|
||||
g_signal_connect (entry, "search-changed",
|
||||
G_CALLBACK (search_changed), label);
|
||||
g_signal_connect (entry, "next-match",
|
||||
G_CALLBACK (next_match), label);
|
||||
g_signal_connect (entry, "previous-match",
|
||||
G_CALLBACK (previous_match), label);
|
||||
g_signal_connect (entry, "stop-search",
|
||||
G_CALLBACK (stop_search), label);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
|
||||
@@ -66,6 +66,7 @@ do_tagged_entry (GtkWidget *do_widget)
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Tagged Entry");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 260, -1);
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
tag {
|
||||
margin: 4px;
|
||||
margin: 4px 0px;
|
||||
padding: 4px;
|
||||
border-radius: 4px;
|
||||
background: lightskyblue;
|
||||
@@ -17,3 +17,7 @@ tag button {
|
||||
padding: 0;
|
||||
border: 1px solid white;
|
||||
}
|
||||
|
||||
entry.tagged {
|
||||
border-spacing: 4px;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
</object>
|
||||
<object class="GtkWindow" id="window">
|
||||
<property name="resizable">0</property>
|
||||
<property name="title">Themes</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="header">
|
||||
<child type="start">
|
||||
|
||||
Reference in New Issue
Block a user