aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Conti <jason.conti@gmail.com>2019-06-07 18:33:06 -0400
committerJason Conti <jason.conti@gmail.com>2019-06-07 18:33:06 -0400
commit6311a70ec239ce9b118a419dfddc5279b49d246d (patch)
treee22edc83125894e44f4693b3b5853a9b0b6a5f66
parentb7793e65c04fc0d119d00980053a498c8337730e (diff)
downloadayatana-indicator-notifications-6311a70ec239ce9b118a419dfddc5279b49d246d.tar.gz
ayatana-indicator-notifications-6311a70ec239ce9b118a419dfddc5279b49d246d.tar.bz2
ayatana-indicator-notifications-6311a70ec239ce9b118a419dfddc5279b49d246d.zip
* Add a Settings... menu item to the indicator
* indicator-notifications-settings: check if a window already exists and present it to avoid multiple windows
-rw-r--r--.gitignore1
-rw-r--r--po/indicator-notifications.pot28
-rw-r--r--src/Makefile.am1
-rw-r--r--src/indicator-notifications-settings.c7
-rw-r--r--src/indicator-notifications.c54
5 files changed, 71 insertions, 20 deletions
diff --git a/.gitignore b/.gitignore
index e48476d..46cf8be 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,6 +26,7 @@ po/en@boldquot.header
po/en@quot.header
po/insert-header.sin
po/quot.sed
+po/remove-potcdate.sed
po/remove-potcdate.sin
po/stamp-po
src/.deps
diff --git a/po/indicator-notifications.pot b/po/indicator-notifications.pot
index 6aba2eb..98f9fd0 100644
--- a/po/indicator-notifications.pot
+++ b/po/indicator-notifications.pot
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: indicator-notifications 0.3.3\n"
"Report-Msgid-Bugs-To: jason.conti@gmail.com\n"
-"POT-Creation-Date: 2019-06-07 16:51-0400\n"
+"POT-Creation-Date: 2019-06-07 18:30-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -18,7 +18,7 @@ msgstr ""
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
#: data/net.launchpad.indicator.notifications.gschema.xml.in.in:5
-#: src/indicator-notifications-settings.c:267
+#: src/indicator-notifications-settings.c:274
msgid "Discard notifications by application name"
msgstr ""
@@ -29,7 +29,7 @@ msgid ""
msgstr ""
#: data/net.launchpad.indicator.notifications.gschema.xml.in.in:10
-#: src/indicator-notifications-settings.c:237
+#: src/indicator-notifications-settings.c:244
msgid "Clear notifications on middle click"
msgstr ""
@@ -58,36 +58,40 @@ msgid ""
"indicated by this value."
msgstr ""
-#: src/indicator-notifications.c:161
+#: src/indicator-notifications.c:163
msgid "Notifications"
msgstr ""
-#: src/indicator-notifications.c:461
+#: src/indicator-notifications.c:172
+msgid "Settings..."
+msgstr ""
+
+#: src/indicator-notifications.c:470
#, c-format
msgid "Clear <small>(%d Notification)</small>"
msgid_plural "Clear <small>(%d Notifications)</small>"
msgstr[0] ""
msgstr[1] ""
-#: src/indicator-notifications-settings.c:220
-#: src/indicator-notifications-settings.c:226
-#: src/indicator-notifications-settings.c:341
+#: src/indicator-notifications-settings.c:227
+#: src/indicator-notifications-settings.c:233
+#: src/indicator-notifications-settings.c:348
msgid "Indicator Notifications Settings"
msgstr ""
-#: src/indicator-notifications-settings.c:246
+#: src/indicator-notifications-settings.c:253
msgid "Hide indicator"
msgstr ""
-#: src/indicator-notifications-settings.c:256
+#: src/indicator-notifications-settings.c:263
msgid "Maximum number of visible notifications"
msgstr ""
-#: src/indicator-notifications-settings.c:292
+#: src/indicator-notifications-settings.c:299
msgid "Remove"
msgstr ""
-#: src/indicator-notifications-settings.c:297
+#: src/indicator-notifications-settings.c:304
msgid "Add"
msgstr ""
diff --git a/src/Makefile.am b/src/Makefile.am
index eda87c8..d5a786f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -15,6 +15,7 @@ libnotifications_la_SOURCES = \
notification.h
libnotifications_la_CFLAGS = \
+ -DSETTINGS_PATH=\""$(libexecdir)/indicator-notifications-settings"\" \
$(INDICATOR_CFLAGS) \
-Wall \
-DG_LOG_DOMAIN=\"Indicator-Notifications\"
diff --git a/src/indicator-notifications-settings.c b/src/indicator-notifications-settings.c
index 6a37491..6b9676c 100644
--- a/src/indicator-notifications-settings.c
+++ b/src/indicator-notifications-settings.c
@@ -212,6 +212,13 @@ indicator_notifications_settings_activate(GApplication *app)
IndicatorNotificationsSettings *self = (IndicatorNotificationsSettings *) app;
+ /* Check for a pre-existing window */
+ GtkWindow *old_window = gtk_application_get_active_window(GTK_APPLICATION(app));
+ if (old_window != NULL) {
+ gtk_window_present_with_time(old_window, GDK_CURRENT_TIME);
+ return;
+ }
+
/* GSettings */
self->settings = g_settings_new(NOTIFICATIONS_SCHEMA);
diff --git a/src/indicator-notifications.c b/src/indicator-notifications.c
index 8d64d9a..a7ced67 100644
--- a/src/indicator-notifications.c
+++ b/src/indicator-notifications.c
@@ -69,6 +69,7 @@ struct _IndicatorNotificationsPrivate {
GtkMenu *menu;
GtkWidget *clear_item;
GtkWidget *clear_item_label;
+ GtkWidget *settings_item;
gchar *accessible_desc;
@@ -106,13 +107,13 @@ static void indicator_notifications_middle_click(IndicatorObject *io,
gpointer user_data);
/* Utility Functions */
-static void clear_menuitems(IndicatorNotifications *self);
-static void insert_menuitem(IndicatorNotifications *self, GtkWidget *item);
-static void remove_menuitem(IndicatorNotifications *self, GtkWidget *item);
-static void set_unread(IndicatorNotifications *self, gboolean unread);
-static void update_blacklist(IndicatorNotifications *self);
-static void update_clear_item_markup(IndicatorNotifications *self);
-static void update_indicator_visibility(IndicatorNotifications *self);
+static void clear_menuitems(IndicatorNotifications *self);
+static void insert_menuitem(IndicatorNotifications *self, GtkWidget *item);
+static void remove_menuitem(IndicatorNotifications *self, GtkWidget *item);
+static void set_unread(IndicatorNotifications *self, gboolean unread);
+static void update_blacklist(IndicatorNotifications *self);
+static void update_clear_item_markup(IndicatorNotifications *self);
+static void update_indicator_visibility(IndicatorNotifications *self);
/* Callbacks */
static void clear_item_activated_cb(GtkMenuItem *menuitem, gpointer user_data);
@@ -120,12 +121,13 @@ static void menu_visible_notify_cb(GtkWidget *menu, GParamSpec *pspec, gpointer
static void message_received_cb(DBusSpy *spy, Notification *note, gpointer user_data);
static void notification_clicked_cb(NotificationMenuItem *menuitem, guint button, gpointer user_data);
static void setting_changed_cb(GSettings *settings, gchar *key, gpointer user_data);
+static void settings_item_activated_cb(GtkMenuItem *menuitem, gpointer user_data);
/* Indicator Module Config */
INDICATOR_SET_VERSION
INDICATOR_SET_TYPE(INDICATOR_NOTIFICATIONS_TYPE)
-G_DEFINE_TYPE (IndicatorNotifications, indicator_notifications, INDICATOR_OBJECT_TYPE);
+G_DEFINE_TYPE(IndicatorNotifications, indicator_notifications, INDICATOR_OBJECT_TYPE);
static void
indicator_notifications_class_init(IndicatorNotificationsClass *klass)
@@ -166,6 +168,13 @@ indicator_notifications_init(IndicatorNotifications *self)
self->priv->menu = GTK_MENU(gtk_menu_new());
g_signal_connect(self->priv->menu, "notify::visible", G_CALLBACK(menu_visible_notify_cb), self);
+ /* Create the settings menuitem */
+ self->priv->settings_item = gtk_menu_item_new_with_label(_("Settings..."));
+ g_signal_connect(self->priv->settings_item, "activate", G_CALLBACK(settings_item_activated_cb), NULL);
+ gtk_widget_show(self->priv->settings_item);
+
+ gtk_menu_shell_prepend(GTK_MENU_SHELL(self->priv->menu), self->priv->settings_item);
+
/* Create the clear menuitem */
self->priv->clear_item_label = gtk_label_new(NULL);
gtk_misc_set_alignment(GTK_MISC(self->priv->clear_item_label), 0, 0);
@@ -509,6 +518,35 @@ clear_item_activated_cb(GtkMenuItem *menuitem, gpointer user_data)
}
/**
+ * settings_item_activated_cb:
+ * @menuitem: the settings menuitem
+ * @user_data: the indicator object
+ *
+ * Called when the settings menuitem is activated.
+ **/
+static void
+settings_item_activated_cb(GtkMenuItem *menuitem, gpointer user_data)
+{
+ g_return_if_fail(GTK_IS_MENU_ITEM(menuitem));
+
+ GError *error = NULL;
+
+ gchar *argv[] = { SETTINGS_PATH, NULL };
+
+ GPid pid;
+
+ g_spawn_async(NULL, argv, NULL, G_SPAWN_DEFAULT, NULL, NULL, &pid, &error);
+
+ if (error != NULL) {
+ g_message("%s", error->message);
+ g_error_free(error);
+ }
+ else {
+ g_spawn_close_pid(pid);
+ }
+}
+
+/**
* setting_changed_cb:
* @settings: the GSettings object
* @key: the GSettings key