Mercurial > projects > pk-update-icon
changeset 16:7af115023d5a
add CLI, make delay and interval configurable
author | Guido Berhoerster <guido@berhoerster.name> |
---|---|
date | Thu, 20 Oct 2011 12:06:42 +0200 |
parents | c7eac2574c76 |
children | a28d0d9b5410 |
files | Makefile main.c pk-update-icon.1 po/de.po |
diffstat | 4 files changed, 111 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Thu Oct 20 09:06:52 2011 +0200 +++ b/Makefile Thu Oct 20 12:06:42 2011 +0200 @@ -26,6 +26,7 @@ -DI_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE \ -DPACKAGE="\"$(PACKAGE)\"" \ -DAPP_NAME=\"$(APP_NAME)\" \ + -DVERSION=\"$(VERSION)\" \ -DLOCALEDIR="\"$(localedir)\"" LDLIBS := $(shell pkg-config --libs gtk+-2.0 unique-1.0 libnotify packagekit-glib2)
--- a/main.c Thu Oct 20 09:06:52 2011 +0200 +++ b/main.c Thu Oct 20 12:06:42 2011 +0200 @@ -29,8 +29,24 @@ main(int argc, char **argv) { PkuiIcon *icon; - UniqueApp *app; + UniqueApp *app = NULL; int exitval = 0; + gboolean version = FALSE; + gint startup_delay = 10; + gint check_interval = 2 * 3600; + GOptionContext *context; + GError *error = NULL; + const GOptionEntry options[] = { + { "delay", 'd', 0, G_OPTION_ARG_INT, &startup_delay, + N_("Set the delay in seconds before the first check for " + "updates"), "delay" }, + { "interval", 'i', 0, G_OPTION_ARG_INT, &check_interval, + N_("Set the interval in seconds between checks for " + "updates"), "interval" }, + { "version", 'v', 0, G_OPTION_ARG_NONE, &version, + N_("Print the version number and exit"), NULL }, + { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, 0 } + }; setlocale(LC_ALL, ""); @@ -40,23 +56,56 @@ gtk_init(&argc, &argv); + context = g_option_context_new(_("- display notifications about " + "software updates")); + g_option_context_add_main_entries(context, options, PACKAGE); + g_option_context_parse(context, &argc, &argv, &error); + g_option_context_free(context); + if (error) { + g_printerr("Error parsing command line options: %s\n", + error->message); + g_error_free(error); + exitval = 1; + goto out; + } + + if (startup_delay < 0) { + g_printerr("Error parsing command line options: delay must be " + "greater or equal to zero\n"); + exitval = 1; + goto out; + } + + if (check_interval < 0) { + g_printerr("Error parsing command line options: interval must " + "be greater or equal to zero\n"); + exitval = 1; + goto out; + } + + if (version) { + g_print("%s %s\n", PACKAGE, VERSION); + goto out; + } + app = unique_app_new(APP_NAME, NULL); if (unique_app_is_running(app)) { g_printerr("Another instance of pk-update-icon is already " - "running. Exiting.\n"); + "running, exiting\n"); exitval = 1; goto out; } notify_init(PACKAGE); - icon = pkui_icon_new(10, 2 * 3600); + icon = pkui_icon_new(startup_delay, check_interval); gtk_main(); g_object_unref(icon); out: - g_object_unref(app); + if (app != NULL) + g_object_unref(app); if (notify_is_initted()) notify_uninit ();
--- a/pk-update-icon.1 Thu Oct 20 09:06:52 2011 +0200 +++ b/pk-update-icon.1 Thu Oct 20 12:06:42 2011 +0200 @@ -16,11 +16,35 @@ .\" along with this program; if not, write to the Free Software .\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. .\" -.TH PK\-UPDATE\-ICON 1 "9 Oct 2011" +.TH PK\-UPDATE\-ICON 1 "20 Oct 2011" .SH NAME -pk\-update\-icon \- display notifications about package updates +pk\-update\-icon \- display notifications about software updates .SH SYNOPSIS -.B pk\-update\-icon +\fBpk\-update\-icon\fR +[\fB\-hv?\fR] +[\fB\-d\fR \fIdelay\fR | \fB\-\-delay\fR=\fIdelay\fR] +[\fB\-i\fR \fIinterval\fR | \fB\-\-interval\fR=\fIinterval\fR] .SH DESCRIPTION \fBpk\-update\-icon\fR displays notifications and an icon in the tray area of the panel when package updates are available. +.SH OPTIONS +The following options are supported: +.TP +.BR \-d ", " \-\-delay =\fIdelay\fR +Set the delay in seconds before the first check for updates. +.TP +.BR \-h ", " \-? ", " \-\-help +Print a summary of all command line options and exit. +.TP +.BR \-i ", " \-\-interval =\fIinterval\fR +Set the interval in seconds between checks for updates. +.TP +.BR \-v ", " \-\-version +Print the version number and exit. +.SH EXIT STATUS +.TP +.B 0 +The program has exited normally. +.TP +.B >0 +An Error has occurred.
--- a/po/de.po Thu Oct 20 09:06:52 2011 +0200 +++ b/po/de.po Thu Oct 20 12:06:42 2011 +0200 @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: pk-update-icon 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-10-19 23:05+0200\n" +"POT-Creation-Date: 2011-10-20 12:07+0200\n" "PO-Revision-Date: 2011-10-10 19:21+0200\n" "Last-Translator: Guido Berhoerster <gber@opensuse.org>\n" "Language-Team: German\n" @@ -17,40 +17,60 @@ "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#: ../pkui-icon.c:86 +#: ../main.c:41 +msgid "Set the delay in seconds before the first check for updates" +msgstr "Bestimme die Verzögerung in Sekunden vor dem ersten Überprüfen auf Aktualisierungen" + +#: ../main.c:44 +msgid "Set the interval in seconds between checks for updates" +msgstr "Bestimme das Intervall in Sekunden zwischen dem Überprüfen auf Aktualisierungen" + +#: ../main.c:47 +msgid "Print the version number and exit" +msgstr "Zeige die Versionsnummer und breche ab" + +#: ../main.c:59 +msgid "- display notifications about software updates" +msgstr "- zeige Benachrichtigungen über Softwareaktualisierungen" + +#: ../pkui-icon.c:88 msgid "Software Updates" msgstr "Softwareaktualisierungen" -#: ../pkui-icon.c:115 +#: ../pkui-icon.c:117 msgid "_Check for Updates" msgstr "Nach Aktualisierungen _Suchen" -#: ../pkui-icon.c:144 +#: ../pkui-icon.c:146 msgid "Important Software Update" msgid_plural "Important Software Updates" msgstr[0] "Wichtige Aktualisierung" msgstr[1] "Wichtige Aktualisierungen" -#: ../pkui-icon.c:146 +#: ../pkui-icon.c:148 msgid "Software Update" msgid_plural "Software Updates" msgstr[0] "Softwareaktualisierung" msgstr[1] "Softwareaktualisierungen" -#: ../pkui-icon.c:153 +#: ../pkui-icon.c:155 +#, c-format msgid "There are %d software updates available, %d of them is important." msgid_plural "" "There are %d software updates available, %d of them are important." -msgstr[0] "Es sind %d Softwareaktualisierungen verfügbar, davon ist %d wichtig." -msgstr[1] "Es sind %d Softwareaktualisierungen verfügbar, davon sind %d wichtig." +msgstr[0] "" +"Es sind %d Softwareaktualisierungen verfügbar, davon ist %d wichtig." +msgstr[1] "" +"Es sind %d Softwareaktualisierungen verfügbar, davon sind %d wichtig." -#: ../pkui-icon.c:161 +#: ../pkui-icon.c:163 +#, c-format msgid "There is an important software update available." msgid_plural "There are %d important software updates available." msgstr[0] "Es ist eine wichtige Softwareaktualisierung verfügbar." msgstr[1] "Es sind %d wichtige Softwareaktualisierungen verfügbar." -#: ../pkui-icon.c:166 +#: ../pkui-icon.c:168 #, c-format msgid "There is a software update available." msgid_plural "There are %d software updates available."