From e6b3c74e8dc73f098ce2b0f8e1ba57e5851e1db3 Mon Sep 17 00:00:00 2001 From: rbuj Date: Mon, 16 Mar 2020 20:36:25 +0100 Subject: Rewrite mate-notification-properties.ui from scratch --- src/capplet/mate-notification-properties.c | 144 ++--------- src/capplet/mate-notification-properties.ui | 371 +++++++++++----------------- 2 files changed, 163 insertions(+), 352 deletions(-) diff --git a/src/capplet/mate-notification-properties.c b/src/capplet/mate-notification-properties.c index 6a496da..718eae6 100644 --- a/src/capplet/mate-notification-properties.c +++ b/src/capplet/mate-notification-properties.c @@ -44,12 +44,12 @@ typedef struct { GtkWidget* dialog; GtkWidget* position_combo; - GtkWidget* monitor_combo; + GtkWidget* monitor_combo; GtkWidget* theme_combo; GtkWidget* preview_button; GtkWidget* active_checkbox; GtkWidget* dnd_checkbox; - GtkWidget* monitor_label; + GtkWidget* monitor_label; NotifyNotification* preview; } NotificationAppletDialog; @@ -380,92 +380,6 @@ static void notification_properties_dialog_setup_themes(NotificationAppletDialog g_free(theme); } -static void notification_properties_checkbox_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_checkbox_notify being called. - // Stop here instead of doing redundant work. - if (is_active == g_settings_get_boolean(dialog->gsettings, GSETTINGS_KEY_USE_ACTIVE_MONITOR)) - { - return; - } - - if (is_active) - { - g_settings_set_boolean(dialog->gsettings, GSETTINGS_KEY_USE_ACTIVE_MONITOR, TRUE); - gtk_widget_set_sensitive(dialog->monitor_combo, FALSE); - gtk_widget_set_sensitive(dialog->monitor_label, FALSE); - } - else - { - g_settings_set_boolean(dialog->gsettings, GSETTINGS_KEY_USE_ACTIVE_MONITOR, FALSE); - gtk_widget_set_sensitive(dialog->monitor_combo, TRUE); - gtk_widget_set_sensitive(dialog->monitor_label, TRUE); - } -} - -static void notification_properties_checkbox_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_checkbox_toggled being called. - // Stop here instead of doing redundant work. - if(is_set == gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (dialog->active_checkbox))) - { - return; - } - - if (is_set) - { - gtk_widget_set_sensitive(dialog->monitor_combo, FALSE); - gtk_widget_set_sensitive(dialog->monitor_label, FALSE); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (dialog->active_checkbox), TRUE); - } - else - { - gtk_widget_set_sensitive(dialog->monitor_combo, TRUE); - gtk_widget_set_sensitive(dialog->monitor_label, TRUE); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (dialog->active_checkbox), FALSE); - } -} - -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); @@ -539,9 +453,9 @@ static gboolean notification_properties_dialog_init(NotificationAppletDialog* di { GtkBuilder* builder = gtk_builder_new(); GError* error = NULL; + gboolean inv_active_checkbox; gtk_builder_add_from_resource (builder, "/org/mate/notifications/properties/mate-notification-properties.ui", &error); - if (error != NULL) { g_warning(_("Could not load user interface: %s"), error->message); @@ -550,56 +464,32 @@ static gboolean notification_properties_dialog_init(NotificationAppletDialog* di } dialog->dialog = GTK_WIDGET(gtk_builder_get_object(builder, "dialog")); - g_assert(dialog->dialog != NULL); - dialog->position_combo = GTK_WIDGET(gtk_builder_get_object(builder, "position_combo")); - g_assert(dialog->position_combo != NULL); - dialog->monitor_combo = GTK_WIDGET(gtk_builder_get_object(builder, "monitor_combo")); - g_assert(dialog->monitor_combo != NULL); - dialog->theme_combo = GTK_WIDGET(gtk_builder_get_object(builder, "theme_combo")); - g_assert(dialog->theme_combo != NULL); - 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); + dialog->monitor_label = GTK_WIDGET(gtk_builder_get_object(builder, "monitor_label")); - g_object_unref(builder); + g_object_unref (builder); dialog->gsettings = g_settings_new (GSETTINGS_SCHEMA); - g_signal_connect(dialog->dialog, "response", G_CALLBACK(notification_properties_dialog_response), dialog); - g_signal_connect(dialog->dialog, "destroy", G_CALLBACK(notification_properties_dialog_destroyed), dialog); - - 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->dialog, "response", G_CALLBACK(notification_properties_dialog_response), dialog); + g_signal_connect (dialog->dialog, "destroy", G_CALLBACK(notification_properties_dialog_destroyed), 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); + g_settings_bind (dialog->gsettings, GSETTINGS_KEY_USE_ACTIVE_MONITOR, dialog->active_checkbox, "active", G_SETTINGS_BIND_DEFAULT); + g_settings_bind (dialog->gsettings, GSETTINGS_KEY_DO_NOT_DISTURB, dialog->dnd_checkbox, "active", G_SETTINGS_BIND_DEFAULT); - notification_properties_dialog_setup_themes(dialog); - notification_properties_dialog_setup_positions(dialog); - notification_properties_dialog_setup_monitors(dialog); - - if (g_settings_get_boolean(dialog->gsettings, GSETTINGS_KEY_USE_ACTIVE_MONITOR)) - { - gtk_widget_set_sensitive(dialog->monitor_combo, FALSE); - gtk_widget_set_sensitive(dialog->monitor_label, FALSE); - } - else - { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (dialog->active_checkbox), FALSE); - gtk_widget_set_sensitive(dialog->monitor_combo, TRUE); - gtk_widget_set_sensitive(dialog->monitor_label, TRUE); - } + notification_properties_dialog_setup_themes (dialog); + notification_properties_dialog_setup_positions (dialog); + notification_properties_dialog_setup_monitors (dialog); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (dialog->dnd_checkbox), g_settings_get_boolean(dialog->gsettings, GSETTINGS_KEY_DO_NOT_DISTURB)); + inv_active_checkbox = !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->active_checkbox)); + gtk_widget_set_sensitive (dialog->monitor_combo, inv_active_checkbox); + gtk_widget_set_sensitive (dialog->monitor_label, inv_active_checkbox); + g_object_bind_property (dialog->active_checkbox, "active", dialog->monitor_combo, "sensitive", G_BINDING_INVERT_BOOLEAN); + g_object_bind_property (dialog->active_checkbox, "active", dialog->monitor_label, "sensitive", G_BINDING_INVERT_BOOLEAN); gtk_widget_show_all(dialog->dialog); diff --git a/src/capplet/mate-notification-properties.ui b/src/capplet/mate-notification-properties.ui index 30e39d4..d6dbfac 100644 --- a/src/capplet/mate-notification-properties.ui +++ b/src/capplet/mate-notification-properties.ui @@ -1,235 +1,184 @@ + - - + + + True + False + mate-notification-properties + + + True + False + window-close + False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 + 12 Notification Settings False - center-on-parent mate-notification-properties dialog + + + - - True + False - 2 + vertical + 12 - - True + False end - + + _Preview True True - False - False - - - True - False - 0 - 0 - - - True - False - 2 - - - True - False - mate-notification-properties - 3 - - - False - False - 0 - - - - - True - False - _Preview - True - - - False - False - 1 - - - - - - + True + image1 + True + True - False - False + True + True 0 - - gtk-close + + _Close True True - True - False - False - True + True + image2 + True + True - False - False + True + True 1 False - True - end + False 0 - + True False - 5 - 6 - - - True - False - 0 - <b>General Options</b> - True - - - False - True - 0 - - + 0 + none - + True False - + True False - 5 - 2 - 12 - 6 + 6 + vertical + 6 - + True False + 6 + 12 - - - 0 - + + True + False + start + _Theme: + True + theme_combo + + + 0 + 0 + - - - 1 - 2 - - - - - True - False - position_liststore - - - 0 - + + True + False + start + P_osition: + True + position_combo + + + 0 + 1 + - - - 1 - 2 - 1 - 2 - - - - - True - False - 0 - P_osition: - True - True - position_combo - - - 1 - 2 - GTK_FILL - GTK_FILL - - - - - True - False - 0 - _Theme: - True - True - theme_combo - - - GTK_FILL - GTK_FILL - - - - - True - False - 0 - _Monitor: - True - monitor_combo - - - 2 - 3 - GTK_FILL - GTK_FILL - - - - - True - False - - - 0 - + + True + False + start + _Monitor: + True + monitor_combo + + + 0 + 2 + + + + + True + False + True + + + 1 + 0 + + + + + True + False + True + + Top Left + Top Right + Bottom Left + Bottom Right + + + + 1 + 1 + + + + + True + False + True + + + 1 + 2 + - 1 - 2 - 2 - 3 + False + True + 0 @@ -238,14 +187,13 @@ True True False - False - True + start True - 2 - 3 - 4 + False + True + 1 @@ -254,29 +202,28 @@ True True False - False - True + start True - 2 - 4 - 5 + False + True + 2 - - True - True - 1 - - - False - True - 1 - + + + + True + False + General Options + + + + @@ -288,34 +235,8 @@ - button4 - button5 + button1 + button2 - - - - - - - - - - Top Left - top_left - - - Top Right - top_right - - - Bottom Left - bottom_left - - - Bottom Right - bottom_right - - - -- cgit v1.2.1