comparison pui-application.c @ 3:2fa34d6272c6

Add menu item to launch the preferences application
author Guido Berhoerster <guido+pui@berhoerster.name>
date Wed, 13 Jun 2018 23:25:09 +0200
parents 7172a0db97af
children 3d72ca76538d
comparison
equal deleted inserted replaced
2:7172a0db97af 3:2fa34d6272c6
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */ 22 */
23 23
24 #include <gio/gdesktopappinfo.h>
24 #include <glib/gi18n.h> 25 #include <glib/gi18n.h>
25 #include <libappindicator/app-indicator.h> 26 #include <libappindicator/app-indicator.h>
26 #include <stdlib.h> 27 #include <stdlib.h>
27 #include <string.h> 28 #include <string.h>
28 29
76 { NULL } 77 { NULL }
77 }; 78 };
78 79
79 static void pui_application_show_about_dialog(GSimpleAction *, GVariant *, 80 static void pui_application_show_about_dialog(GSimpleAction *, GVariant *,
80 gpointer); 81 gpointer);
82 static void pui_application_open_preferences(GSimpleAction *, GVariant *,
83 gpointer);
81 static void pui_application_quit(GSimpleAction *, GVariant *, gpointer); 84 static void pui_application_quit(GSimpleAction *, GVariant *, gpointer);
82 static void pui_application_install_updates(GSimpleAction *, GVariant *, 85 static void pui_application_install_updates(GSimpleAction *, GVariant *,
83 gpointer); 86 gpointer);
84 87
85 static const GActionEntry pui_application_actions[] = { 88 static const GActionEntry pui_application_actions[] = {
86 { "about", pui_application_show_about_dialog }, 89 { "about", pui_application_show_about_dialog },
90 { "preferences", pui_application_open_preferences },
87 { "quit", pui_application_quit }, 91 { "quit", pui_application_quit },
88 { "install-updates", pui_application_install_updates } 92 { "install-updates", pui_application_install_updates }
89 }; 93 };
90 94
91 static gboolean 95 static gboolean
125 g_object_unref(builder); 129 g_object_unref(builder);
126 } 130 }
127 131
128 gtk_dialog_run(GTK_DIALOG(self->about_dialog)); 132 gtk_dialog_run(GTK_DIALOG(self->about_dialog));
129 gtk_widget_hide(self->about_dialog); 133 gtk_widget_hide(self->about_dialog);
134 }
135
136 static void
137 pui_application_open_preferences(GSimpleAction *simple, GVariant *parameter,
138 gpointer user_data)
139 {
140 GDesktopAppInfo *prefs_app_info;
141 GError *error = NULL;
142
143 prefs_app_info = g_desktop_app_info_new("org.guido-berhoerster.code."
144 "package-update-indicator.preferences.desktop");
145 if (prefs_app_info == NULL) {
146 g_warning("desktop file \"org.guido-berhoerster.code."
147 "package-update-indicator.preferences.desktop\" not found");
148 return;
149 }
150
151 if (!g_app_info_launch(G_APP_INFO(prefs_app_info), NULL, NULL,
152 &error)) {
153 g_warning("failed to launch preferences: %s", error->message);
154 g_error_free(error);
155 }
130 } 156 }
131 157
132 static void 158 static void
133 pui_application_quit(GSimpleAction *simple, GVariant *parameter, 159 pui_application_quit(GSimpleAction *simple, GVariant *parameter,
134 gpointer user_data) 160 gpointer user_data)