[Xfce4-commits] [apps/xfce4-notifyd] 13/24: panel-plugin: Add basic configuration option "log display limit"
noreply at xfce.org
noreply at xfce.org
Fri Sep 8 23:27:44 CEST 2017
This is an automated email from the git hooks/post-receive script.
o c h o s i p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository apps/xfce4-notifyd.
commit 1d737619569adb68ee290bbe10bcaaed3f592dfd
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date: Thu Aug 24 01:44:53 2017 +0200
panel-plugin: Add basic configuration option "log display limit"
Also drop all rc-file related code as we use xfconf instead.
---
panel-plugin/notification-plugin-dialogs.c | 31 +++++++---
panel-plugin/notification-plugin-log.c | 7 ++-
panel-plugin/notification-plugin-log.h | 3 -
panel-plugin/notification-plugin.c | 99 +-----------------------------
panel-plugin/notification-plugin.h | 10 ++-
5 files changed, 33 insertions(+), 117 deletions(-)
diff --git a/panel-plugin/notification-plugin-dialogs.c b/panel-plugin/notification-plugin-dialogs.c
index 838d62d..fb41096 100644
--- a/panel-plugin/notification-plugin-dialogs.c
+++ b/panel-plugin/notification-plugin-dialogs.c
@@ -24,10 +24,12 @@
#include <string.h>
#include <gtk/gtk.h>
+#include <xfconf/xfconf.h>
#include <libxfce4ui/libxfce4ui.h>
#include <libxfce4panel/xfce-panel-plugin.h>
#include "notification-plugin.h"
+#include "notification-plugin-log.h"
#include "notification-plugin-dialogs.h"
/* the website url */
@@ -69,10 +71,13 @@ notification_plugin_configure_response (GtkWidget *dialog,
void
-notification_plugin_configure (XfcePanelPlugin *plugin,
- NotificationPlugin *notification_plugin)
+notification_plugin_configure (XfcePanelPlugin *plugin,
+ NotificationPlugin *notification_plugin)
{
GtkWidget *dialog;
+ GtkWidget *box, *spin, *label;
+ GtkAdjustment *adjustment;
+ gdouble log_display_limit;
/* block the plugin menu */
xfce_panel_plugin_block_menu (plugin);
@@ -84,12 +89,22 @@ notification_plugin_configure (XfcePanelPlugin *plugin,
"gtk-help", GTK_RESPONSE_HELP,
"gtk-close", GTK_RESPONSE_OK,
NULL);
-
- /* center dialog on the screen */
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
-
- /* set dialog icon */
gtk_window_set_icon_name (GTK_WINDOW (dialog), ICON_NAME);
+ gtk_widget_show (dialog);
+
+ log_display_limit = xfconf_channel_get_int (notification_plugin->channel,
+ SETTING_LOG_DISPLAY_LIMIT, DEFAULT_LOG_DISPLAY_LIMIT);
+ adjustment = gtk_adjustment_new (log_display_limit, 0.0, 100.0, 1.0, 5.0, 0.0);
+ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+ gtk_container_add_with_properties (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
+ box, "expand", TRUE, "fill", TRUE, NULL);
+ label = gtk_label_new (_("Number of notifications to show: "));
+ gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET (label), TRUE, FALSE, 0);
+ spin = gtk_spin_button_new (adjustment, 1.0, 0);
+ gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET (spin), FALSE, FALSE, 0);
+ xfconf_g_property_bind (notification_plugin->channel, "/plugin/log-display-limit", G_TYPE_INT,
+ G_OBJECT (spin), "value");
/* link the dialog to the plugin, so we can destroy it when the plugin
* is closed, but the dialog is still open */
@@ -98,9 +113,7 @@ notification_plugin_configure (XfcePanelPlugin *plugin,
/* connect the reponse signal to the dialog */
g_signal_connect (G_OBJECT (dialog), "response",
G_CALLBACK(notification_plugin_configure_response), notification_plugin);
-
- /* show the entire dialog */
- gtk_widget_show (dialog);
+ gtk_widget_show_all (box);
}
diff --git a/panel-plugin/notification-plugin-log.c b/panel-plugin/notification-plugin-log.c
index c25fe4f..520da60 100644
--- a/panel-plugin/notification-plugin-log.c
+++ b/panel-plugin/notification-plugin-log.c
@@ -95,9 +95,14 @@ notification_plugin_menu_populate (NotificationPlugin *notification_plugin)
if (notify_log) {
gchar **groups;
int log_length;
+ int log_display_limit;
groups = g_key_file_get_groups (notify_log, &num_groups);
- log_length = GPOINTER_TO_UINT(num_groups) - LOG_DISPLAY_LIMIT;
+ log_display_limit = xfconf_channel_get_int (notification_plugin->channel,
+ SETTING_LOG_DISPLAY_LIMIT, -1);
+ if (log_display_limit == -1)
+ log_display_limit = DEFAULT_LOG_DISPLAY_LIMIT;
+ log_length = GPOINTER_TO_UINT(num_groups) - log_display_limit;
if (log_length < 0)
log_length = 0;
diff --git a/panel-plugin/notification-plugin-log.h b/panel-plugin/notification-plugin-log.h
index c2061d6..bce79c0 100644
--- a/panel-plugin/notification-plugin-log.h
+++ b/panel-plugin/notification-plugin-log.h
@@ -23,9 +23,6 @@
#include <gtk/gtk.h>
#include "notification-plugin.h"
-#define XFCE_NOTIFY_LOG_FILE "xfce4/notifyd/log"
-#define LOG_DISPLAY_LIMIT 10
-
void notification_plugin_menu_populate (NotificationPlugin *notification_plugin);
#endif /* __NOTIFICATION_PLUGIN_LOG_H_ */
diff --git a/panel-plugin/notification-plugin.c b/panel-plugin/notification-plugin.c
index c657dec..365e1ed 100644
--- a/panel-plugin/notification-plugin.c
+++ b/panel-plugin/notification-plugin.c
@@ -30,109 +30,19 @@
#include <libxfce4panel/xfce-panel-plugin.h>
#include "notification-plugin.h"
-#include "notification-plugin-dialogs.h"
#include "notification-plugin-log.h"
-
-/* default settings */
-#define DEFAULT_SETTING1 NULL
-#define DEFAULT_SETTING2 1
-#define DEFAULT_SETTING3 FALSE
-
-
+#include "notification-plugin-dialogs.h"
/* prototypes */
static void
notification_plugin_construct (XfcePanelPlugin *panel_plugin);
-
/* register the plugin */
XFCE_PANEL_PLUGIN_REGISTER (notification_plugin_construct);
void
-notification_plugin_save (XfcePanelPlugin *plugin,
- NotificationPlugin *notification_plugin)
-{
- XfceRc *rc;
- gchar *file;
-
- /* get the config file location */
- file = xfce_panel_plugin_save_location (plugin, TRUE);
-
- if (G_UNLIKELY (file == NULL))
- {
- DBG ("Failed to open config file");
- return;
- }
-
- /* open the config file, read/write */
- rc = xfce_rc_simple_open (file, FALSE);
- g_free (file);
-
- if (G_LIKELY (rc != NULL))
- {
- /* save the settings */
- DBG(".");
- if (notification_plugin->setting1)
- xfce_rc_write_entry (rc, "setting1", notification_plugin->setting1);
-
- xfce_rc_write_int_entry (rc, "setting2", notification_plugin->setting2);
- xfce_rc_write_bool_entry (rc, "setting3", notification_plugin->setting3);
-
- /* close the rc file */
- xfce_rc_close (rc);
- }
-}
-
-
-
-static void
-notification_plugin_read (NotificationPlugin *notification_plugin)
-{
- XfceRc *rc;
- gchar *file;
- const gchar *value;
-
- /* get the plugin config file location */
- file = xfce_panel_plugin_save_location (notification_plugin->plugin, TRUE);
-
- if (G_LIKELY (file != NULL))
- {
- /* open the config file, readonly */
- rc = xfce_rc_simple_open (file, TRUE);
-
- /* cleanup */
- g_free (file);
-
- if (G_LIKELY (rc != NULL))
- {
- /* read the settings */
- value = xfce_rc_read_entry (rc, "setting1", DEFAULT_SETTING1);
- notification_plugin->setting1 = g_strdup (value);
-
- notification_plugin->setting2 = xfce_rc_read_int_entry (rc, "setting2", DEFAULT_SETTING2);
- notification_plugin->setting3 = xfce_rc_read_bool_entry (rc, "setting3", DEFAULT_SETTING3);
-
- /* cleanup */
- xfce_rc_close (rc);
-
- /* leave the function, everything went well */
- return;
- }
- }
-
- /* something went wrong, apply default values */
- DBG ("Applying default settings");
-
- notification_plugin->setting1 = g_strdup (DEFAULT_SETTING1);
- notification_plugin->setting2 = DEFAULT_SETTING2;
- notification_plugin->setting3 = DEFAULT_SETTING3;
-}
-
-
-
-void
dnd_toggled_cb (GtkCheckMenuItem *checkmenuitem,
gpointer user_data)
{
@@ -236,9 +146,6 @@ notification_plugin_new (XfcePanelPlugin *panel_plugin)
notification_plugin = panel_slice_new0 (NotificationPlugin);
notification_plugin->plugin = panel_plugin;
- /* read the user settings */
- notification_plugin_read (notification_plugin);
-
/* xfconf */
xfconf_init (NULL);
notification_plugin->channel = xfconf_channel_new ("xfce4-notifyd");
@@ -292,10 +199,6 @@ notification_plugin_free (XfcePanelPlugin *plugin,
/* destroy the panel widgets */
gtk_widget_destroy (notification_plugin->button);
- /* cleanup the settings */
- if (G_LIKELY (notification_plugin->setting1 != NULL))
- g_free (notification_plugin->setting1);
-
/* free the plugin structure */
panel_slice_free (NotificationPlugin, notification_plugin);
}
diff --git a/panel-plugin/notification-plugin.h b/panel-plugin/notification-plugin.h
index d23da76..aecb5c9 100644
--- a/panel-plugin/notification-plugin.h
+++ b/panel-plugin/notification-plugin.h
@@ -24,7 +24,10 @@ G_BEGIN_DECLS
#include <xfconf/xfconf.h>
-#define ICON_NAME "xfce4-notifyd"
+#define ICON_NAME "xfce4-notifyd"
+#define XFCE_NOTIFY_LOG_FILE "xfce4/notifyd/log"
+#define SETTING_LOG_DISPLAY_LIMIT "/plugin/log-display-limit"
+#define DEFAULT_LOG_DISPLAY_LIMIT 10
/* plugin structure */
typedef struct
@@ -36,11 +39,6 @@ typedef struct
GtkWidget *button;
GtkWidget *image;
GtkWidget *menu;
-
- /* sample settings */
- gchar *setting1;
- gint setting2;
- gboolean setting3;
}
NotificationPlugin;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list