diff pui-application.c @ 2:7172a0db97af

Use GtkBuilder for all widgets
author Guido Berhoerster <guido+pui@berhoerster.name>
date Wed, 13 Jun 2018 20:06:00 +0200
parents 2f04ec9e0506
children 2fa34d6272c6
line wrap: on
line diff
--- a/pui-application.c	Fri Jun 08 08:38:42 2018 +0200
+++ b/pui-application.c	Wed Jun 13 20:06:00 2018 +0200
@@ -111,27 +111,18 @@
     gpointer user_data)
 {
 	PuiApplication	*self = user_data;
-	const gchar	*translators;
+	GtkBuilder	*builder;
 
 	if (self->about_dialog == NULL) {
-		translators = _("Translators");
-		if (strcmp(translators, "Translators") == 0) {
-			translators = NULL;
-		}
+		/* get dialog from builder */
+		builder = gtk_builder_new_from_resource("/org"
+		    "/guido-berhoerster/code/package-update-indicator"
+		    "/pui-about-dialog.ui");
 
-		self->about_dialog = gtk_about_dialog_new();
-		g_object_set(G_OBJECT(self->about_dialog),
-		    "authors", (gchar *[]){ "Guido Berhoerster", NULL },
-		    "comments", _("Notify about available software updates"),
-		    "copyright", "Copyright \xc2\xa9 2018 Guido Berhoerster",
-		    "license-type", GTK_LICENSE_MIT_X11,
-		    "logo-icon-name", "system-software-update",
-		    "translator-credits", translators,
-		    "version", VERSION,
-		    "website", "https://code.guido-berhoerster.org/projects/"
-		    "package-update-indicator/",
-		    "wrap-license", TRUE,
-		    NULL);
+		self->about_dialog = GTK_WIDGET(gtk_builder_get_object(builder,
+		    "about-dialog"));
+
+		g_object_unref(builder);
 	}
 
 	gtk_dialog_run(GTK_DIALOG(self->about_dialog));
@@ -405,8 +396,8 @@
 {
 	PuiApplication	*self = PUI_APPLICATION(application);
 	gsize		i;
+	GtkBuilder	*builder;
 	GtkWidget	*menu;
-	GtkWidget	*menu_item;
 
 	G_APPLICATION_CLASS(pui_application_parent_class)->startup(application);
 
@@ -433,22 +424,11 @@
 	    "system-software-update",
 	    APP_INDICATOR_CATEGORY_APPLICATION_STATUS);
 
-	/* build menu */
-	menu = gtk_menu_new();
-	gtk_widget_insert_action_group(GTK_WIDGET(menu), "app",
-	    G_ACTION_GROUP(self));
-
-	menu_item = gtk_menu_item_new_with_label(_("Install "
-	    "Updates\342\200\246"));
-	gtk_actionable_set_action_name(GTK_ACTIONABLE(menu_item),
-	    "app.install-updates");
-	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
-
-	menu_item = gtk_menu_item_new_with_label(_("About\342\200\246"));
-	gtk_actionable_set_action_name(GTK_ACTIONABLE(menu_item),
-	    "app.about");
-	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
-
+	/* get menu from builder and add it to the indicator */
+	builder = gtk_builder_new_from_resource("/org/guido-berhoerster/code/"
+	    "package-update-indicator/pui-menu.ui");
+	menu = GTK_WIDGET(gtk_builder_get_object(builder, "menu"));
+	gtk_widget_insert_action_group(menu, "app", G_ACTION_GROUP(self));
 	gtk_widget_show_all(menu);
 	app_indicator_set_menu(self->indicator, GTK_MENU(menu));
 
@@ -456,6 +436,8 @@
 
 	/* keep GApplication running */
 	g_application_hold(application);
+
+	g_object_unref(builder);
 }
 
 static void