diff options
author | rbuj <[email protected]> | 2020-03-16 20:36:25 +0100 |
---|---|---|
committer | raveit65 <[email protected]> | 2020-04-08 20:14:41 +0200 |
commit | e6b3c74e8dc73f098ce2b0f8e1ba57e5851e1db3 (patch) | |
tree | 9058213ec55730e5375101c6f64a5b27f8b556f8 /src/capplet | |
parent | 8024fb9854540c3a849d5f1d83efe971dff3b16b (diff) | |
download | mate-notification-daemon-e6b3c74e8dc73f098ce2b0f8e1ba57e5851e1db3.tar.bz2 mate-notification-daemon-e6b3c74e8dc73f098ce2b0f8e1ba57e5851e1db3.tar.xz |
Rewrite mate-notification-properties.ui from scratch
Diffstat (limited to 'src/capplet')
-rw-r--r-- | src/capplet/mate-notification-properties.c | 144 | ||||
-rw-r--r-- | 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 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.22.2 --> <interface> - <requires lib="gtk+" version="2.18"/> - <!-- interface-naming-policy toplevel-contextual --> + <requires lib="gtk+" version="3.22"/> + <object class="GtkImage" id="image1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="icon_name">mate-notification-properties</property> + </object> + <object class="GtkImage" id="image2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="icon_name">window-close</property> + </object> <object class="GtkDialog" id="dialog"> <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="border_width">5</property> + <property name="border_width">12</property> <property name="title" translatable="yes">Notification Settings</property> <property name="resizable">False</property> - <property name="window_position">center-on-parent</property> <property name="icon_name">mate-notification-properties</property> <property name="type_hint">dialog</property> + <child type="titlebar"> + <placeholder/> + </child> <child internal-child="vbox"> - <object class="GtkVBox" id="dialog-vbox1"> - <property name="visible">True</property> + <object class="GtkBox"> <property name="can_focus">False</property> - <property name="spacing">2</property> + <property name="orientation">vertical</property> + <property name="spacing">12</property> <child internal-child="action_area"> - <object class="GtkHButtonBox" id="dialog-action_area1"> - <property name="visible">True</property> + <object class="GtkButtonBox"> <property name="can_focus">False</property> <property name="layout_style">end</property> <child> - <object class="GtkButton" id="button4"> + <object class="GtkButton" id="button1"> + <property name="label" translatable="yes">_Preview</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> - <child> - <object class="GtkAlignment" id="alignment2"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xscale">0</property> - <property name="yscale">0</property> - <child> - <object class="GtkHBox" id="hbox3"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="spacing">2</property> - <child> - <object class="GtkImage" id="image2"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="icon_name">mate-notification-properties</property> - <property name="icon-size">3</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label12"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">_Preview</property> - <property name="use_underline">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - </object> - </child> - </object> - </child> + <property name="receives_default">True</property> + <property name="image">image1</property> + <property name="use_underline">True</property> + <property name="always_show_image">True</property> </object> <packing> - <property name="expand">False</property> - <property name="fill">False</property> + <property name="expand">True</property> + <property name="fill">True</property> <property name="position">0</property> </packing> </child> <child> - <object class="GtkButton" id="button5"> - <property name="label">gtk-close</property> + <object class="GtkButton" id="button2"> + <property name="label" translatable="yes">_Close</property> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="receives_default">False</property> - <property name="use_action_appearance">False</property> - <property name="use_stock">True</property> + <property name="receives_default">True</property> + <property name="image">image2</property> + <property name="use_underline">True</property> + <property name="always_show_image">True</property> </object> <packing> - <property name="expand">False</property> - <property name="fill">False</property> + <property name="expand">True</property> + <property name="fill">True</property> <property name="position">1</property> </packing> </child> </object> <packing> <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">end</property> + <property name="fill">False</property> <property name="position">0</property> </packing> </child> <child> - <object class="GtkVBox" id="vbox4"> + <object class="GtkFrame"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="border_width">5</property> - <property name="spacing">6</property> - <child> - <object class="GtkLabel" id="label7"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes"><b>General Options</b></property> - <property name="use_markup">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> + <property name="label_xalign">0</property> + <property name="shadow_type">none</property> <child> - <object class="GtkHBox" id="hbox1"> + <object class="GtkAlignment"> <property name="visible">True</property> <property name="can_focus">False</property> <child> - <object class="GtkTable" id="table3"> + <object class="GtkBox"> <property name="visible">True</property> <property name="can_focus">False</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> + <property name="margin_top">6</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> <child> - <object class="GtkComboBox" id="theme_combo"> + <object class="GtkGrid"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="row_spacing">6</property> + <property name="column_spacing">12</property> <child> - <object class="GtkCellRendererText" id="theme_cellrenderertext"/> - <attributes> - <attribute name="text">0</attribute> - </attributes> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="label" translatable="yes">_Theme:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">theme_combo</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> </child> - </object> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="position_combo"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="model">position_liststore</property> <child> - <object class="GtkCellRendererText" id="position_cellrenderertext"/> - <attributes> - <attribute name="text">0</attribute> - </attributes> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="label" translatable="yes">P_osition:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">position_combo</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> </child> - </object> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label9"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">P_osition:</property> - <property name="use_markup">True</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">position_combo</property> - </object> - <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options">GTK_FILL</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label8"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Theme:</property> - <property name="use_markup">True</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">theme_combo</property> - </object> - <packing> - <property name="x_options">GTK_FILL</property> - <property name="y_options">GTK_FILL</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="monitor_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Monitor:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">monitor_combo</property> - </object> - <packing> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options">GTK_FILL</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="monitor_combo"> - <property name="visible">True</property> - <property name="can_focus">False</property> <child> - <object class="GtkCellRendererText" id="monitor_cellrenderertext"/> - <attributes> - <attribute name="text">0</attribute> - </attributes> + <object class="GtkLabel" id="monitor_label"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="label" translatable="yes">_Monitor:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">monitor_combo</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkComboBoxText" id="theme_combo"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkComboBoxText" id="position_combo"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <items> + <item id="top_left" translatable="yes">Top Left</item> + <item id="top_right" translatable="yes">Top Right</item> + <item id="bottom_left" translatable="yes">Bottom Left</item> + <item id="bottom_right" translatable="yes">Bottom Right</item> + </items> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkComboBoxText" id="monitor_combo"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">2</property> + </packing> </child> </object> <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> </packing> </child> <child> @@ -238,14 +187,13 @@ <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="halign">start</property> <property name="draw_indicator">True</property> </object> <packing> - <property name="right_attach">2</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> </packing> </child> <child> @@ -254,29 +202,28 @@ <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="halign">start</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> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> </packing> </child> </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> </child> </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> + </child> + <child type="label"> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">General Options</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> </child> </object> <packing> @@ -288,34 +235,8 @@ </object> </child> <action-widgets> - <action-widget response="-3">button4</action-widget> - <action-widget response="-7">button5</action-widget> + <action-widget response="-3">button1</action-widget> + <action-widget response="-6">button2</action-widget> </action-widgets> </object> - <object class="GtkListStore" id="position_liststore"> - <columns> - <!-- column-name label --> - <column type="gchararray"/> - <!-- column-name name --> - <column type="gchararray"/> - </columns> - <data> - <row> - <col id="0" translatable="yes">Top Left</col> - <col id="1">top_left</col> - </row> - <row> - <col id="0" translatable="yes">Top Right</col> - <col id="1">top_right</col> - </row> - <row> - <col id="0" translatable="yes">Bottom Left</col> - <col id="1">bottom_left</col> - </row> - <row> - <col id="0" translatable="yes">Bottom Right</col> - <col id="1">bottom_right</col> - </row> - </data> - </object> </interface> |