Last active
June 30, 2020 00:09
-
-
Save andreldm/83c9b99e7aa133c924fb4165acc8427a to your computer and use it in GitHub Desktop.
Revisions
-
andreldm revised this gist
Mar 24, 2020 . 1 changed file with 42 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ diff --git a/panel-plugin/sample.c b/panel-plugin/sample.c index 97a0cc6..8927da2 100644 --- a/panel-plugin/sample.c +++ b/panel-plugin/sample.c @@ -135,7 +135,7 @@ sample_new (XfcePanelPlugin *plugin) { SamplePlugin *sample; GtkOrientation orientation; - GtkWidget *label; + GtkWidget *button, *popover, *vbox; /* allocate memory for the plugin structure */ sample = g_slice_new0 (SamplePlugin); @@ -158,13 +158,22 @@ sample_new (XfcePanelPlugin *plugin) gtk_container_add (GTK_CONTAINER (sample->ebox), sample->hvbox); /* some sample widgets */ - label = gtk_label_new (_("Sample")); - gtk_widget_show (label); - gtk_box_pack_start (GTK_BOX (sample->hvbox), label, FALSE, FALSE, 0); + button = gtk_menu_button_new (); + gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_icon_name ("open-menu-symbolic", GTK_ICON_SIZE_BUTTON)); + gtk_box_pack_start (GTK_BOX (sample->hvbox), button, FALSE, FALSE, 0); + gtk_widget_show (button); - label = gtk_label_new (_("Plugin")); - gtk_widget_show (label); - gtk_box_pack_start (GTK_BOX (sample->hvbox), label, FALSE, FALSE, 0); + vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); + gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new ("Hello World 1"), FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new ("Hello World 2"), FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new ("Hello World 3"), FALSE, FALSE, 0); + + popover = gtk_popover_new (button); + gtk_container_add (GTK_CONTAINER (popover), vbox); + + gtk_widget_show_all (popover); + + gtk_menu_button_set_popover (GTK_MENU_BUTTON (button), popover); return sample; } -
andreldm revised this gist
Mar 24, 2020 . No changes.There are no files selected for viewing
-
andreldm created this gist
Mar 24, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ /* * Build: * gcc $(pkg-config --cflags gtk+-3.0) popover_sample.c -o popover_sample $(pkg-config --libs gtk+-3.0) */ #include <gtk/gtk.h> int main (int argc, char *argv[]) { GtkWidget *window; GtkWidget *button, *popover, *vbox; gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER); gtk_container_set_border_width (GTK_CONTAINER (window), 5); gtk_window_set_default_size (GTK_WINDOW (window), 640, 480); button = gtk_menu_button_new (); gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_icon_name ("open-menu-symbolic", GTK_ICON_SIZE_BUTTON)); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); gtk_widget_set_halign (button, GTK_ALIGN_CENTER); gtk_container_add (GTK_CONTAINER (window), button); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new ("Hello World 1"), FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new ("Hello World 2"), FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new ("Hello World 3"), FALSE, FALSE, 0); popover = gtk_popover_new (button); gtk_container_add (GTK_CONTAINER (popover), vbox); gtk_menu_button_set_popover (GTK_MENU_BUTTON (button), popover); gtk_widget_show_all (popover); g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL); gtk_widget_show_all (window); gtk_main (); return 0; }