diff options
author | Logan Rathbone <poprocks@gmail.com> | 2021-02-15 15:14:51 -0500 |
---|---|---|
committer | Logan Rathbone <poprocks@gmail.com> | 2021-02-15 15:14:51 -0500 |
commit | 3b9f5f9cfb697814c45cbad7347420811aab8002 (patch) | |
tree | 84c181c14f6e9d4711178c87885c0993a7fbbded | |
parent | 592e2555c352fdd85643b94030473f7dcd6095c4 (diff) | |
download | zenity-3b9f5f9cfb697814c45cbad7347420811aab8002.tar.gz |
Make icon notification-only.
s/--window-icon/--icon, now only for the notification component.
Update manpage accordingly.
-rw-r--r-- | data/zenity.1 | 7 | ||||
-rw-r--r-- | src/notification.c | 12 | ||||
-rw-r--r-- | src/option.c | 24 | ||||
-rw-r--r-- | src/util.c | 60 | ||||
-rw-r--r-- | src/util.h | 7 | ||||
-rw-r--r-- | src/zenity.h | 70 |
6 files changed, 55 insertions, 125 deletions
diff --git a/data/zenity.1 b/data/zenity.1 index 06a1aba..465b580 100644 --- a/data/zenity.1 +++ b/data/zenity.1 @@ -76,9 +76,6 @@ General options .B \-\-title=TITLE Set the dialog title .TP -.B \-\-window-icon=ICONPATH -Set the window icon with the path to an image. Alternatively, one of the four stock icons can be used: 'error', 'info', 'question' or 'warning' -.TP .B \-\-width=WIDTH Set the dialog width .TP @@ -211,7 +208,7 @@ Notification options Set the notification text .TP .B \-\-listen -Listen for commands on stdin. Commands include 'message', 'tooltip', 'icon', and 'visible' separated by a colon. For example, 'message: Hello world', 'visible: false', or 'icon: /path/to/icon'. The icon command also accepts the four stock icon: 'error', 'info', 'question', and 'warning' +Listen for commands on stdin. Commands include 'message', 'tooltip', 'icon', and 'visible' separated by a colon. For example, 'message: Hello world', or 'visible: false'. .PP Progress options @@ -400,7 +397,7 @@ find . \-name '*.h' | zenity \-\-list \-\-title "Search Results" \-\-text "Findi .PP Show a notification in the message tray .IP -zenity \-\-notification \-\-window-icon=update.png \-\-text "System update necessary!" +zenity \-\-notification \-\-icon=update.png \-\-text "System update necessary!" .PP Display a weekly shopping list in a check list dialog with \fIApples\fP and \fIOranges\fP pre selected .IP diff --git a/src/notification.c b/src/notification.c index e5cfe27..a813c1e 100644 --- a/src/notification.c +++ b/src/notification.c @@ -44,7 +44,7 @@ static char *icon_file; static GHashTable *notification_hints; static NotifyNotification * -zenity_notification_new (gchar *message, gchar *icon_file) +zenity_notification_new (char *message, char *icon_file) { NotifyNotification *notif; char **text; @@ -79,10 +79,10 @@ on_notification_default_action (NotifyNotification *n, } static GHashTable * -zenity_notification_parse_hints_array (gchar **hints) +zenity_notification_parse_hints_array (char **hints) { GHashTable *result; - gchar **pair; + char **pair; int i; result = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); @@ -103,10 +103,10 @@ zenity_notification_parse_hints_array (gchar **hints) } static GHashTable * -zenity_notification_parse_hints (gchar *hints) +zenity_notification_parse_hints (char *hints) { GHashTable *result; - gchar **hint_array; + char **hint_array; hint_array = g_strsplit (g_strcompress (hints), "\n", MAX_HINTS); result = zenity_notification_parse_hints_array (hint_array); @@ -387,7 +387,7 @@ zenity_notification (ZenityData *data, notification = zenity_notification_new (notification_data->notification_text, - data->window_icon); + notification_data->icon); if (notification == NULL) exit (1); diff --git a/src/option.c b/src/option.c index ff78e69..087c15e 100644 --- a/src/option.c +++ b/src/option.c @@ -35,7 +35,6 @@ /* General Options */ static char *zenity_general_dialog_title; -static char *zenity_general_window_icon; static int zenity_general_width; static int zenity_general_height; static char *zenity_general_dialog_text; @@ -92,6 +91,7 @@ static gboolean zenity_list_mid_search; /* Notification Dialog Options */ static gboolean zenity_notification_active; static gboolean zenity_notification_listen; +static char *zenity_notification_icon; static char **zenity_notification_hints; #endif @@ -165,13 +165,6 @@ static GOptionEntry general_options[] = &zenity_general_dialog_title, N_ ("Set the dialog title"), N_ ("TITLE")}, - {"window-icon", - '\0', - 0, - G_OPTION_ARG_FILENAME, - &zenity_general_window_icon, - N_ ("Set the window icon"), - N_ ("ICONPATH")}, {"width", '\0', 0, @@ -562,6 +555,13 @@ static GOptionEntry notification_options[] = &zenity_general_dialog_text, N_ ("Set the notification text"), N_ ("TEXT")}, + {"icon", + '\0', + 0, + G_OPTION_ARG_FILENAME, + &zenity_notification_icon, + N_ ("Set the notification icon"), + N_ ("ICONPATH")}, {"listen", '\0', 0, @@ -1073,8 +1073,6 @@ zenity_option_free (void) { if (zenity_general_dialog_title) g_free (zenity_general_dialog_title); - if (zenity_general_window_icon) - g_free (zenity_general_window_icon); if (zenity_general_dialog_text) g_free (zenity_general_dialog_text); if (zenity_general_uri) @@ -1114,6 +1112,8 @@ zenity_option_free (void) #ifdef HAVE_LIBNOTIFY if (zenity_notification_hints) g_strfreev (zenity_notification_hints); + if (zenity_notification_icon) + g_free (zenity_notification_icon); #endif if (zenity_text_font) @@ -1191,7 +1191,6 @@ zenity_general_pre_callback (GOptionContext *context, GOptionGroup *group, gpointer data, GError **error) { zenity_general_dialog_title = NULL; - zenity_general_window_icon = NULL; zenity_general_width = -1; zenity_general_height = -1; zenity_general_dialog_text = NULL; @@ -1288,6 +1287,7 @@ zenity_notification_pre_callback (GOptionContext *context, GOptionGroup *group, { zenity_notification_active = FALSE; zenity_notification_listen = FALSE; + zenity_notification_icon = NULL; return TRUE; } @@ -1410,7 +1410,6 @@ zenity_general_post_callback (GOptionContext *context, GOptionGroup *group, gpointer data, GError **error) { results->data->dialog_title = zenity_general_dialog_title; - results->data->window_icon = zenity_general_window_icon; results->data->width = zenity_general_width; results->data->height = zenity_general_height; results->data->timeout_delay = zenity_general_timeout_delay; @@ -1682,6 +1681,7 @@ zenity_notification_post_callback (GOptionContext *context, GOptionGroup *group, results->notification_data->notification_text = zenity_general_dialog_text; results->notification_data->listen = zenity_notification_listen; + results->notification_data->icon = zenity_notification_icon; results->notification_data->notification_hints = zenity_notification_hints; } @@ -178,66 +178,6 @@ zenity_util_fill_file_buffer (GtkTextBuffer *buffer, const char *filename) { return TRUE; } -#if 0 -const char * -zenity_util_icon_name_from_filename (const char *filename) { - if (!filename || !filename[0]) - return "dialog-warning"; /* default */ - - if (!g_ascii_strcasecmp (filename, "warning")) - return "dialog-warning"; - if (!g_ascii_strcasecmp (filename, "info")) - return "dialog-information"; - if (!g_ascii_strcasecmp (filename, "question")) - return "dialog-question"; - if (!g_ascii_strcasecmp (filename, "error")) - return "dialog-error"; - return NULL; -} -#endif - -#if 0 -void -zenity_util_set_window_icon_from_file (GtkWidget *widget, - const char *filename) -{ - const char *icon_name; - - icon_name = zenity_util_icon_name_from_filename (filename); - if (icon_name) { - gtk_window_set_icon_name (GTK_WINDOW (widget), icon_name); - } else { - g_debug ("%s: NOT IMPLEMENTED with icon name not existing.", - __func__); - } -} -#endif - -#if 0 -void -zenity_util_set_window_icon (GtkWidget *widget, const char *icon_name) -{ - if (filename != NULL) { - zenity_util_set_window_icon_from_file (widget, filename); - } else { - g_debug ("%s: setting icon where no filename: NOT IMPLEMENTED", - __func__); - } -} -#endif - -#if 0 -void -zenity_util_set_window_icon_from_icon_name (GtkWidget *widget, - const char *filename, const char *default_icon_name) -{ - if (filename != NULL) - zenity_util_set_window_icon_from_file (widget, filename); - else - gtk_window_set_icon_name (GTK_WINDOW (widget), default_icon_name); -} -#endif - void zenity_util_show_help (GError **error) { char *tmp; @@ -50,13 +50,6 @@ GtkBuilder *zenity_util_load_ui_file (const char *widget_root, char *zenity_util_strip_newline (char *string); gboolean zenity_util_fill_file_buffer (GtkTextBuffer *buffer, const char *filename); -const char *zenity_util_icon_name_from_filename (const char *filename); -void zenity_util_set_window_icon (GtkWidget *widget, - const char *filename, const char *default_file); -void zenity_util_set_window_icon_from_icon_name (GtkWidget *widget, - const char *filename, const char *default_icon_name); -void zenity_util_set_window_icon_from_file (GtkWidget *widget, - const char *filename); void zenity_util_show_help (GError **error); int zenity_util_return_exit_code (ZenityExitCode value); void zenity_util_exit_code_with_data (ZenityExitCode value, ZenityData *data); diff --git a/src/zenity.h b/src/zenity.h index 449d022..8eb8553 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -12,7 +12,6 @@ G_BEGIN_DECLS typedef struct { char *dialog_title; - char *window_icon; char *ok_label; char *cancel_label; char **extra_label; @@ -33,11 +32,11 @@ typedef enum { } ZenityExitCode; typedef struct { - gchar *dialog_text; - gint day; - gint month; - gint year; - gchar *date_format; + char *dialog_text; + int day; + int month; + int year; + char *date_format; } ZenityCalendarData; typedef enum { @@ -49,8 +48,8 @@ typedef enum { } MsgMode; typedef struct { - gchar *dialog_text; - gchar *dialog_icon; + char *dialog_text; + char *dialog_icon; MsgMode mode; gboolean no_wrap; gboolean no_markup; @@ -59,34 +58,34 @@ typedef struct { } ZenityMsgData; typedef struct { - gchar *dialog_text; - gint value; - gint min_value; - gint max_value; - gint step; + char *dialog_text; + int value; + int min_value; + int max_value; + int step; gboolean print_partial; gboolean hide_value; } ZenityScaleData; typedef struct { - gchar *uri; + char *uri; gboolean multi; gboolean directory; gboolean save; - gchar *separator; - gchar **filter; + char *separator; + char **filter; } ZenityFileData; typedef struct { - gchar *dialog_text; - gchar *entry_text; + char *dialog_text; + char *entry_text; gboolean hide_text; - const gchar **data; + const char **data; } ZenityEntryData; typedef struct { - gchar *dialog_text; - gchar *entry_text; + char *dialog_text; + char *entry_text; gboolean pulsate; gboolean autoclose; gboolean autokill; @@ -96,46 +95,47 @@ typedef struct { } ZenityProgressData; typedef struct { - gchar *uri; + char *uri; gboolean editable; gboolean no_wrap; gboolean auto_scroll; - gchar *font; + char *font; GtkTextBuffer *buffer; - gchar *checkbox; + char *checkbox; #ifdef HAVE_WEBKITGTK gboolean html; gboolean no_interaction; - gchar *url; + char *url; #endif } ZenityTextData; typedef struct { - gchar *dialog_text; + char *dialog_text; GSList *columns; gboolean checkbox; gboolean radiobox; gboolean hide_header; gboolean imagebox; - gchar *separator; + char *separator; gboolean multi; gboolean editable; gboolean mid_search; - gchar *print_column; - gchar *hide_column; - const gchar **data; + char *print_column; + char *hide_column; + const char **data; } ZenityTreeData; #ifdef HAVE_LIBNOTIFY typedef struct { - gchar *notification_text; + char *notification_text; gboolean listen; - gchar **notification_hints; + char *icon; + char **notification_hints; } ZenityNotificationData; #endif typedef struct { - gchar *color; + char *color; gboolean show_palette; } ZenityColorData; @@ -160,14 +160,14 @@ typedef enum { } ZenityFormsType; typedef struct { - gchar *option_value; + char *option_value; ZenityFormsType type; GtkWidget *forms_widget; } ZenityFormsValue; typedef struct { gboolean username; - gchar *password; + char *password; GtkWidget *entry_username; GtkWidget *entry_password; } ZenityPasswordData; |