projects/package-update-indicator
changeset 2:7172a0db97af
Use GtkBuilder for all widgets
author | Guido Berhoerster <guido+pui@berhoerster.name> |
---|---|
date | Wed Jun 13 20:06:00 2018 +0200 (2018-06-13) |
parents | 2f04ec9e0506 |
children | 2fa34d6272c6 |
files | Makefile po/POTFILES.in pui-about-dialog.ui pui-application.c pui-menu.ui pui.gresource.xml |
line diff
1.1 --- a/Makefile Fri Jun 08 08:38:42 2018 +0200 1.2 +++ b/Makefile Wed Jun 13 20:06:00 2018 +0200 1.3 @@ -103,7 +103,8 @@ 1.4 pui-backend.o \ 1.5 pui-get-updates.o \ 1.6 pui-settings.o \ 1.7 - pui-types.o 1.8 + pui-types.o \ 1.9 + pui-resources.o 1.10 1.11 $(PACKAGE)-prefs_OBJS = package-update-indicator-prefs.o \ 1.12 pui-prefs-application.o \
2.1 --- a/po/POTFILES.in Fri Jun 08 08:38:42 2018 +0200 2.2 +++ b/po/POTFILES.in Wed Jun 13 20:06:00 2018 +0200 2.3 @@ -3,9 +3,11 @@ 2.4 org.guido-berhoerster.code.package-update-indicator.preferences.desktop.in 2.5 package-update-indicator-prefs.c 2.6 package-update-indicator.c 2.7 +pui-about-dialog.ui 2.8 pui-application.c 2.9 pui-backend.c 2.10 pui-get-updates.c 2.11 +pui-menu.ui 2.12 pui-prefs-application.c 2.13 pui-prefs-window.ui 2.14 pui-settings.c
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/pui-about-dialog.ui Wed Jun 13 20:06:00 2018 +0200 3.3 @@ -0,0 +1,41 @@ 3.4 +<?xml version="1.0" encoding="UTF-8"?> 3.5 +<!-- Generated with glade 3.20.0 --> 3.6 +<interface> 3.7 + <requires lib="gtk+" version="3.20"/> 3.8 + <object class="GtkAboutDialog" id="about-dialog"> 3.9 + <property name="can_focus">False</property> 3.10 + <property name="title" translatable="yes">About Package Update Indicator</property> 3.11 + <property name="icon_name">system-software-update</property> 3.12 + <property name="type_hint">dialog</property> 3.13 + <property name="program_name">Package Update Indicator</property> 3.14 + <property name="copyright" translatable="yes">Copyright © 2018 Guido Berhörster</property> 3.15 + <property name="comments" translatable="yes">Notify about available software updates</property> 3.16 + <property name="website">http://code.guido-berhoerster.org/projects/package-update-indicator/</property> 3.17 + <property name="authors">Guido Berhörster</property> 3.18 + <property name="translator_credits" translatable="yes" comments="Place your name here.">Translator</property> 3.19 + <property name="logo_icon_name">system-software-update</property> 3.20 + <property name="wrap_license">True</property> 3.21 + <property name="license_type">mit-x11</property> 3.22 + <child internal-child="vbox"> 3.23 + <object class="GtkBox"> 3.24 + <property name="can_focus">False</property> 3.25 + <property name="orientation">vertical</property> 3.26 + <property name="spacing">2</property> 3.27 + <child internal-child="action_area"> 3.28 + <object class="GtkButtonBox"> 3.29 + <property name="can_focus">False</property> 3.30 + <property name="layout_style">end</property> 3.31 + </object> 3.32 + <packing> 3.33 + <property name="expand">False</property> 3.34 + <property name="fill">False</property> 3.35 + <property name="position">0</property> 3.36 + </packing> 3.37 + </child> 3.38 + <child> 3.39 + <placeholder/> 3.40 + </child> 3.41 + </object> 3.42 + </child> 3.43 + </object> 3.44 +</interface>
4.1 --- a/pui-application.c Fri Jun 08 08:38:42 2018 +0200 4.2 +++ b/pui-application.c Wed Jun 13 20:06:00 2018 +0200 4.3 @@ -111,27 +111,18 @@ 4.4 gpointer user_data) 4.5 { 4.6 PuiApplication *self = user_data; 4.7 - const gchar *translators; 4.8 + GtkBuilder *builder; 4.9 4.10 if (self->about_dialog == NULL) { 4.11 - translators = _("Translators"); 4.12 - if (strcmp(translators, "Translators") == 0) { 4.13 - translators = NULL; 4.14 - } 4.15 + /* get dialog from builder */ 4.16 + builder = gtk_builder_new_from_resource("/org" 4.17 + "/guido-berhoerster/code/package-update-indicator" 4.18 + "/pui-about-dialog.ui"); 4.19 4.20 - self->about_dialog = gtk_about_dialog_new(); 4.21 - g_object_set(G_OBJECT(self->about_dialog), 4.22 - "authors", (gchar *[]){ "Guido Berhoerster", NULL }, 4.23 - "comments", _("Notify about available software updates"), 4.24 - "copyright", "Copyright \xc2\xa9 2018 Guido Berhoerster", 4.25 - "license-type", GTK_LICENSE_MIT_X11, 4.26 - "logo-icon-name", "system-software-update", 4.27 - "translator-credits", translators, 4.28 - "version", VERSION, 4.29 - "website", "https://code.guido-berhoerster.org/projects/" 4.30 - "package-update-indicator/", 4.31 - "wrap-license", TRUE, 4.32 - NULL); 4.33 + self->about_dialog = GTK_WIDGET(gtk_builder_get_object(builder, 4.34 + "about-dialog")); 4.35 + 4.36 + g_object_unref(builder); 4.37 } 4.38 4.39 gtk_dialog_run(GTK_DIALOG(self->about_dialog)); 4.40 @@ -405,8 +396,8 @@ 4.41 { 4.42 PuiApplication *self = PUI_APPLICATION(application); 4.43 gsize i; 4.44 + GtkBuilder *builder; 4.45 GtkWidget *menu; 4.46 - GtkWidget *menu_item; 4.47 4.48 G_APPLICATION_CLASS(pui_application_parent_class)->startup(application); 4.49 4.50 @@ -433,22 +424,11 @@ 4.51 "system-software-update", 4.52 APP_INDICATOR_CATEGORY_APPLICATION_STATUS); 4.53 4.54 - /* build menu */ 4.55 - menu = gtk_menu_new(); 4.56 - gtk_widget_insert_action_group(GTK_WIDGET(menu), "app", 4.57 - G_ACTION_GROUP(self)); 4.58 - 4.59 - menu_item = gtk_menu_item_new_with_label(_("Install " 4.60 - "Updates\342\200\246")); 4.61 - gtk_actionable_set_action_name(GTK_ACTIONABLE(menu_item), 4.62 - "app.install-updates"); 4.63 - gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item); 4.64 - 4.65 - menu_item = gtk_menu_item_new_with_label(_("About\342\200\246")); 4.66 - gtk_actionable_set_action_name(GTK_ACTIONABLE(menu_item), 4.67 - "app.about"); 4.68 - gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item); 4.69 - 4.70 + /* get menu from builder and add it to the indicator */ 4.71 + builder = gtk_builder_new_from_resource("/org/guido-berhoerster/code/" 4.72 + "package-update-indicator/pui-menu.ui"); 4.73 + menu = GTK_WIDGET(gtk_builder_get_object(builder, "menu")); 4.74 + gtk_widget_insert_action_group(menu, "app", G_ACTION_GROUP(self)); 4.75 gtk_widget_show_all(menu); 4.76 app_indicator_set_menu(self->indicator, GTK_MENU(menu)); 4.77 4.78 @@ -456,6 +436,8 @@ 4.79 4.80 /* keep GApplication running */ 4.81 g_application_hold(application); 4.82 + 4.83 + g_object_unref(builder); 4.84 } 4.85 4.86 static void
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/pui-menu.ui Wed Jun 13 20:06:00 2018 +0200 5.3 @@ -0,0 +1,27 @@ 5.4 +<?xml version="1.0" encoding="UTF-8"?> 5.5 +<!-- Generated with glade 3.20.0 --> 5.6 +<interface> 5.7 + <requires lib="gtk+" version="3.20"/> 5.8 + <object class="GtkMenu" id="menu"> 5.9 + <property name="visible">True</property> 5.10 + <property name="can_focus">False</property> 5.11 + <child> 5.12 + <object class="GtkMenuItem"> 5.13 + <property name="visible">True</property> 5.14 + <property name="can_focus">False</property> 5.15 + <property name="action_name">app.install-updates</property> 5.16 + <property name="label" translatable="yes">_Install updates</property> 5.17 + <property name="use_underline">True</property> 5.18 + </object> 5.19 + </child> 5.20 + <child> 5.21 + <object class="GtkMenuItem"> 5.22 + <property name="visible">True</property> 5.23 + <property name="can_focus">False</property> 5.24 + <property name="action_name">app.about</property> 5.25 + <property name="label" translatable="yes">_About…</property> 5.26 + <property name="use_underline">True</property> 5.27 + </object> 5.28 + </child> 5.29 + </object> 5.30 +</interface>
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/pui.gresource.xml Wed Jun 13 20:06:00 2018 +0200 6.3 @@ -0,0 +1,7 @@ 6.4 +<?xml version="1.0" encoding="UTF-8"?> 6.5 +<gresources> 6.6 + <gresource prefix="/org/guido-berhoerster/code/package-update-indicator"> 6.7 + <file compressed="true">pui-menu.ui</file> 6.8 + <file compressed="true">pui-about-dialog.ui</file> 6.9 + </gresource> 6.10 +</gresources>