summaryrefslogtreecommitdiff
path: root/src/capplet
diff options
context:
space:
mode:
authorJason Conti <[email protected]>2019-08-31 22:10:46 -0400
committerlukefromdc <[email protected]>2019-09-02 04:05:21 +0000
commit975184923121ac2047020922c144763bb3ddb842 (patch)
treeb06180f508fb15f60153fdc24895c4189b362735 /src/capplet
parent5a7637ab6edb537ec341779dad3282616cd72ca7 (diff)
downloadmate-notification-daemon-975184923121ac2047020922c144763bb3ddb842.tar.bz2
mate-notification-daemon-975184923121ac2047020922c144763bb3ddb842.tar.xz
mate-notification-properties: Add do-not-disturb checkbox
Diffstat (limited to 'src/capplet')
-rw-r--r--src/capplet/mate-notification-properties.c40
-rw-r--r--src/capplet/mate-notification-properties.ui18
2 files changed, 57 insertions, 1 deletions
diff --git a/src/capplet/mate-notification-properties.c b/src/capplet/mate-notification-properties.c
index f74897e..758aa11 100644
--- a/src/capplet/mate-notification-properties.c
+++ b/src/capplet/mate-notification-properties.c
@@ -37,6 +37,7 @@
#define GSETTINGS_KEY_POPUP_LOCATION "popup-location"
#define GSETTINGS_KEY_MONITOR_NUMBER "monitor-number"
#define GSETTINGS_KEY_USE_ACTIVE_MONITOR "use-active-monitor"
+#define GSETTINGS_KEY_DO_NOT_DISTURB "do-not-disturb"
#define NOTIFICATION_UI_FILE "mate-notification-properties.ui"
@@ -49,6 +50,7 @@ typedef struct {
GtkWidget* theme_combo;
GtkWidget* preview_button;
GtkWidget* active_checkbox;
+ GtkWidget* dnd_checkbox;
GtkWidget* monitor_label;
NotifyNotification* preview;
@@ -434,6 +436,38 @@ static void notification_properties_checkbox_notify(GSettings *settings, gchar *
}
}
+static void notification_properties_dnd_toggled(GtkWidget* widget, NotificationAppletDialog* dialog)
+{
+ gboolean is_active;
+
+ is_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (widget));
+
+ // This was called as a result of notification_properties_dnd_notify being called.
+ // Stop here instead of doing redundant work.
+ if (is_active == g_settings_get_boolean(dialog->gsettings, GSETTINGS_KEY_DO_NOT_DISTURB))
+ {
+ return;
+ }
+
+ g_settings_set_boolean(dialog->gsettings, GSETTINGS_KEY_DO_NOT_DISTURB, is_active);
+}
+
+static void notification_properties_dnd_notify(GSettings *settings, gchar *key, NotificationAppletDialog* dialog)
+{
+ gboolean is_set;
+
+ is_set = g_settings_get_boolean(settings, key);
+
+ // This was called as a result of notification_properties_dnd_toggled being called.
+ // Stop here instead of doing redundant work.
+ if(is_set == gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (dialog->dnd_checkbox)))
+ {
+ return;
+ }
+
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (dialog->dnd_checkbox), is_set);
+}
+
static void show_message(NotificationAppletDialog* dialog, const gchar* message)
{
GtkWidget* d = gtk_message_dialog_new(GTK_WINDOW(dialog->dialog), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", message);
@@ -543,6 +577,9 @@ static gboolean notification_properties_dialog_init(NotificationAppletDialog* di
dialog->active_checkbox = GTK_WIDGET(gtk_builder_get_object(builder, "use_active_check"));
g_assert(dialog->active_checkbox != NULL);
+ dialog->dnd_checkbox = GTK_WIDGET(gtk_builder_get_object(builder, "do_not_disturb_check"));
+ g_assert(dialog->dnd_checkbox != NULL);
+
dialog->monitor_label = GTK_WIDGET(gtk_builder_get_object(builder, "monitor_label"));
g_assert(dialog->monitor_label != NULL);
@@ -556,6 +593,9 @@ static gboolean notification_properties_dialog_init(NotificationAppletDialog* di
g_signal_connect(dialog->gsettings, "changed::" GSETTINGS_KEY_USE_ACTIVE_MONITOR, G_CALLBACK (notification_properties_checkbox_notify), dialog);
g_signal_connect(dialog->active_checkbox, "toggled", G_CALLBACK(notification_properties_checkbox_toggled), dialog);
+ g_signal_connect(dialog->gsettings, "changed::" GSETTINGS_KEY_DO_NOT_DISTURB, G_CALLBACK (notification_properties_dnd_notify), dialog);
+ g_signal_connect(dialog->dnd_checkbox, "toggled", G_CALLBACK(notification_properties_dnd_toggled), dialog);
+
notification_properties_dialog_setup_themes(dialog);
notification_properties_dialog_setup_positions(dialog);
notification_properties_dialog_setup_monitors(dialog);
diff --git a/src/capplet/mate-notification-properties.ui b/src/capplet/mate-notification-properties.ui
index 280fb8d..30e39d4 100644
--- a/src/capplet/mate-notification-properties.ui
+++ b/src/capplet/mate-notification-properties.ui
@@ -127,7 +127,7 @@
<object class="GtkTable" id="table3">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="n_rows">4</property>
+ <property name="n_rows">5</property>
<property name="n_columns">2</property>
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
@@ -248,6 +248,22 @@
<property name="bottom_attach">4</property>
</packing>
</child>
+ <child>
+ <object class="GtkCheckButton" id="do_not_disturb_check">
+ <property name="label" translatable="yes">Enable Do Not Disturb</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="right_attach">2</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">True</property>