gtk-demo: Minor cosmetic fixes

Some minor cosmetic fixes to some of the demos.
This commit is contained in:
Matthias Clasen 2020-04-25 23:33:33 -04:00
parent f6c8af6609
commit c6fc7d88c2
6 changed files with 29 additions and 20 deletions

View File

@ -44,7 +44,6 @@ do_infobar (GtkWidget *do_widget)
GtkWidget *frame; GtkWidget *frame;
GtkWidget *bar; GtkWidget *bar;
GtkWidget *vbox; GtkWidget *vbox;
GtkWidget *vbox2;
GtkWidget *label; GtkWidget *label;
GtkWidget *actions; GtkWidget *actions;
GtkWidget *button; GtkWidget *button;
@ -52,11 +51,13 @@ do_infobar (GtkWidget *do_widget)
if (!window) if (!window)
{ {
actions = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); actions = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_add_css_class (actions, "linked");
window = gtk_window_new (); window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window), gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget)); gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Info Bars"); gtk_window_set_title (GTK_WINDOW (window), "Info Bars");
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window); g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window);
@ -131,23 +132,18 @@ do_infobar (GtkWidget *do_widget)
g_object_bind_property (bar, "revealed", button, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); g_object_bind_property (bar, "revealed", button, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
gtk_container_add (GTK_CONTAINER (actions), button); gtk_container_add (GTK_CONTAINER (actions), button);
frame = gtk_frame_new ("Info bars"); frame = gtk_frame_new ("An example of different info bars");
gtk_widget_set_margin_top (frame, 8); gtk_widget_set_margin_top (frame, 8);
gtk_widget_set_margin_bottom (frame, 8); gtk_widget_set_margin_bottom (frame, 8);
gtk_container_add (GTK_CONTAINER (vbox), frame); gtk_container_add (GTK_CONTAINER (vbox), frame);
vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8); gtk_widget_set_halign (actions, GTK_ALIGN_CENTER);
gtk_widget_set_margin_start (vbox2, 8);
gtk_widget_set_margin_end (vbox2, 8);
gtk_widget_set_margin_top (vbox2, 8);
gtk_widget_set_margin_bottom (vbox2, 8);
gtk_container_add (GTK_CONTAINER (frame), vbox2);
/* Standard message dialog */ gtk_widget_set_margin_start (actions, 8);
label = gtk_label_new ("An example of different info bars"); gtk_widget_set_margin_end (actions, 8);
gtk_container_add (GTK_CONTAINER (vbox2), label); gtk_widget_set_margin_top (actions, 8);
gtk_widget_set_margin_bottom (actions, 8);
gtk_container_add (GTK_CONTAINER (vbox2), actions); gtk_container_add (GTK_CONTAINER (frame), actions);
} }
if (!gtk_widget_get_visible (window)) if (!gtk_widget_get_visible (window))

View File

@ -1,7 +1,7 @@
/* Links /* Links
* *
* GtkLabel can show hyperlinks. The default action is to call * GtkLabel can show hyperlinks. The default action is to call
* gtk_show_uri_on_window() on their URI, but it is possible to override * gtk_show_uri() on their URI, but it is possible to override
* this with a custom handler. * this with a custom handler.
*/ */
@ -30,6 +30,8 @@ activate_link (GtkWidget *label,
GTK_DIALOG_DESTROY_WITH_PARENT, GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO, GTK_MESSAGE_INFO,
GTK_BUTTONS_OK, GTK_BUTTONS_OK,
"Keyboard navigation");
gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog),
"The term <i>keynav</i> is a shorthand for " "The term <i>keynav</i> is a shorthand for "
"keyboard navigation and refers to the process of using " "keyboard navigation and refers to the process of using "
"a program (exclusively) via keyboard input."); "a program (exclusively) via keyboard input.");
@ -56,21 +58,29 @@ do_links (GtkWidget *do_widget)
gtk_window_set_display (GTK_WINDOW (window), gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget)); gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Links"); gtk_window_set_title (GTK_WINDOW (window), "Links");
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
g_signal_connect (window, "destroy", g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed), &window); G_CALLBACK (gtk_widget_destroyed), &window);
label = gtk_label_new ("Some <a href=\"http://en.wikipedia.org/wiki/Text\"" label = gtk_label_new ("Some <a href=\"http://en.wikipedia.org/wiki/Text\""
"title=\"plain text\">text</a> may be marked up\n" "title=\"plain text\">text</a> may be marked up "
"as hyperlinks, which can be clicked\n" "as hyperlinks, which can be clicked "
"or activated via <a href=\"keynav\">keynav</a>\n" "or activated via <a href=\"keynav\">keynav</a> "
"and they work fine with other markup, like when\n" "and they work fine with other markup, like when "
"searching on <a href=\"http://www.google.com/\">" "searching on <a href=\"http://www.google.com/\">"
"<span color=\"#0266C8\">G</span><span color=\"#F90101\">o</span>" "<span color=\"#0266C8\">G</span><span color=\"#F90101\">o</span>"
"<span color=\"#F2B50F\">o</span><span color=\"#0266C8\">g</span>" "<span color=\"#F2B50F\">o</span><span color=\"#0266C8\">g</span>"
"<span color=\"#00933B\">l</span><span color=\"#F90101\">e</span>" "<span color=\"#00933B\">l</span><span color=\"#F90101\">e</span>"
"</a>."); "</a>.");
gtk_label_set_use_markup (GTK_LABEL (label), TRUE); gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
gtk_label_set_max_width_chars (GTK_LABEL (label), 40);
gtk_label_set_wrap (GTK_LABEL (label), TRUE);
gtk_label_set_wrap_mode (GTK_LABEL (label), PANGO_WRAP_WORD);
g_signal_connect (label, "activate-link", G_CALLBACK (activate_link), NULL); g_signal_connect (label, "activate-link", G_CALLBACK (activate_link), NULL);
gtk_widget_set_margin_start (label, 20);
gtk_widget_set_margin_end (label, 20);
gtk_widget_set_margin_top (label, 20);
gtk_widget_set_margin_bottom (label, 20);
gtk_container_add (GTK_CONTAINER (window), label); gtk_container_add (GTK_CONTAINER (window), label);
gtk_widget_show (label); gtk_widget_show (label);
} }

View File

@ -1,4 +1,4 @@
/* Scale /* Scales
* *
* GtkScale is a way to select a value from a range. * GtkScale is a way to select a value from a range.
* Scales can have marks to help pick special values, * Scales can have marks to help pick special values,

View File

@ -20,6 +20,7 @@
</object> </object>
<object class="GtkWindow" id="window1"> <object class="GtkWindow" id="window1">
<property name="title" translatable="yes">Scales</property> <property name="title" translatable="yes">Scales</property>
<property name="resizable">0</property>
<child> <child>
<object class="GtkGrid" id="grid1"> <object class="GtkGrid" id="grid1">
<property name="row-spacing">10</property> <property name="row-spacing">10</property>

View File

@ -1,4 +1,4 @@
/* Spin Button /* Spin Buttons
* *
* GtkSpinButton provides convenient ways to input data * GtkSpinButton provides convenient ways to input data
* that can be seen as a value in a range. The examples * that can be seen as a value in a range. The examples

View File

@ -2,6 +2,7 @@
<interface> <interface>
<object class="GtkWindow" id="window1"> <object class="GtkWindow" id="window1">
<property name="title" translatable="yes">Stack</property> <property name="title" translatable="yes">Stack</property>
<property name="resizable">0</property>
<child> <child>
<object class="GtkGrid"> <object class="GtkGrid">
<child> <child>
@ -25,6 +26,7 @@
<object class="GtkImage"> <object class="GtkImage">
<property name="margin-top">20</property> <property name="margin-top">20</property>
<property name="margin-bottom">20</property> <property name="margin-bottom">20</property>
<property name="pixel-size">100</property>
<property name="icon-name">org.gtk.Demo4</property> <property name="icon-name">org.gtk.Demo4</property>
</object> </object>
</property> </property>