comparison main.c @ 46:aa5d3752091d

Make the update viewer command configurable Make the update viewer command configurable at copile time through the UPDATE_VIEWER_COMMAND macro. Make the update viewer command configurable at run time through the -c/--command command line option. Treat the update viewer command as a shell command and parse it via g_shell_parse_argv(), this allows for running the update viewer via xdg-su, gnomesu, pkexec etc. Disable install action in the notification and on the status icon in case no update viewer command has been provided.
author Guido Berhoerster <gber@opensuse.org>
date Thu, 18 Jun 2015 14:10:57 +0200
parents f549b75c3c22
children 7de92a24e86c
comparison
equal deleted inserted replaced
45:a29fbf0a7f6c 46:aa5d3752091d
30 { 30 {
31 PkuiIcon *icon; 31 PkuiIcon *icon;
32 UniqueApp *app = NULL; 32 UniqueApp *app = NULL;
33 int exitval = 0; 33 int exitval = 0;
34 gboolean version = FALSE; 34 gboolean version = FALSE;
35 gchar *update_viewer_command = NULL;
35 gint startup_delay = 300; 36 gint startup_delay = 300;
36 gint check_interval = 86400; 37 gint check_interval = 86400;
37 GOptionContext *context; 38 GOptionContext *context;
38 GError *error = NULL; 39 GError *error = NULL;
39 const GOptionEntry options[] = { 40 const GOptionEntry options[] = {
41 { "command", 'c', 0, G_OPTION_ARG_STRING,
42 &update_viewer_command, N_("Command for starting the "
43 "software update viewer"), "command" },
40 { "delay", 'd', 0, G_OPTION_ARG_INT, &startup_delay, 44 { "delay", 'd', 0, G_OPTION_ARG_INT, &startup_delay,
41 N_("Set the delay in seconds before the first check for " 45 N_("Set the delay in seconds before the first check for "
42 "updates"), "delay" }, 46 "updates"), "delay" },
43 { "interval", 'i', 0, G_OPTION_ARG_INT, &check_interval, 47 { "interval", 'i', 0, G_OPTION_ARG_INT, &check_interval,
44 N_("Set the interval in seconds between checks for " 48 N_("Set the interval in seconds between checks for "
96 goto out; 100 goto out;
97 } 101 }
98 102
99 notify_init(PACKAGE); 103 notify_init(PACKAGE);
100 104
101 icon = pkui_icon_new(startup_delay, check_interval); 105 icon = pkui_icon_new(startup_delay, check_interval,
106 update_viewer_command);
102 107
103 gtk_main(); 108 gtk_main();
104 109
105 g_object_unref(icon); 110 g_object_unref(icon);
106 out: 111 out:
107 if (app != NULL) 112 if (app != NULL)
108 g_object_unref(app); 113 g_object_unref(app);
109 if (notify_is_initted()) 114 if (notify_is_initted())
110 notify_uninit (); 115 notify_uninit ();
116 g_free(update_viewer_command);
111 117
112 return (exitval); 118 return (exitval);
113 } 119 }