[Xfce4-commits] [xfce/xfce4-settings] 13/18: display: Add 'Update profile' dialog when closing
noreply at xfce.org
noreply at xfce.org
Thu Apr 4 23:03:11 CEST 2019
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 xfce/xfce4-settings.
commit 14b7959141174976af86a3a02d397bd9ac2bd8da
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date: Tue Apr 2 00:08:26 2019 +0200
display: Add 'Update profile' dialog when closing
---
dialogs/display-settings/Makefile.am | 6 ++
dialogs/display-settings/display-dialog.glade | 12 +++-
dialogs/display-settings/main.c | 80 ++++++++++++++++++++++++++-
3 files changed, 92 insertions(+), 6 deletions(-)
diff --git a/dialogs/display-settings/Makefile.am b/dialogs/display-settings/Makefile.am
index 21c76eb..56c425d 100644
--- a/dialogs/display-settings/Makefile.am
+++ b/dialogs/display-settings/Makefile.am
@@ -14,6 +14,7 @@ xfce4_display_settings_SOURCES = \
confirmation-dialog_ui.h \
display-dialog_ui.h \
minimal-display-dialog_ui.h \
+ profile-changed-dialog_ui.h \
identity-popup_ui.h \
scrollarea.c \
scrollarea.h \
@@ -58,6 +59,7 @@ BUILT_SOURCES = \
confirmation-dialog_ui.h \
display-dialog_ui.h \
minimal-display-dialog_ui.h \
+ profile-changed-dialog_ui.h \
identity-popup_ui.h
confirmation-dialog_ui.h: confirmation-dialog.glade
@@ -69,6 +71,9 @@ display-dialog_ui.h: display-dialog.glade
minimal-display-dialog_ui.h: minimal-display-dialog.glade
exo-csource --static --strip-comments --strip-content --name=minimal_display_dialog_ui $< >$@
+profile-changed-dialog_ui.h: profile-changed-dialog.glade
+ exo-csource --static --strip-comments --strip-content --name=profile_changed_dialog_ui $< >$@
+
identity-popup_ui.h: identity-popup.glade
exo-csource --static --strip-comments --strip-content --name=identity_popup_ui $< >$@
@@ -94,6 +99,7 @@ EXTRA_DIST = \
confirmation-dialog.glade \
display-dialog.glade \
minimal-display-dialog.glade \
+ profile-changed-dialog.glade \
identity-popup.glade
DISTCLEANFILES = \
diff --git a/dialogs/display-settings/display-dialog.glade b/dialogs/display-settings/display-dialog.glade
index da5ccdc..c9d12f8 100644
--- a/dialogs/display-settings/display-dialog.glade
+++ b/dialogs/display-settings/display-dialog.glade
@@ -13,6 +13,11 @@
<property name="can_focus">False</property>
<property name="icon_name">document-save-symbolic</property>
</object>
+ <object class="GtkImage" id="image3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">close-symbolic</property>
+ </object>
<object class="GtkImage" id="image5">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -203,11 +208,12 @@
</child>
<child>
<object class="GtkButton" id="button-close">
- <property name="label">gtk-close</property>
+ <property name="label">_Close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="use_stock">True</property>
+ <property name="image">image3</property>
+ <property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
@@ -869,7 +875,7 @@
</child>
<action-widgets>
<action-widget response="-11">button-help</action-widget>
- <action-widget response="0">button-close</action-widget>
+ <action-widget response="-7">button-close</action-widget>
</action-widgets>
</object>
<object class="GtkPopover" id="popover-create-profile">
diff --git a/dialogs/display-settings/main.c b/dialogs/display-settings/main.c
index a5a887b..b61851b 100644
--- a/dialogs/display-settings/main.c
+++ b/dialogs/display-settings/main.c
@@ -49,6 +49,7 @@
#include "display-dialog_ui.h"
#include "confirmation-dialog_ui.h"
#include "minimal-display-dialog_ui.h"
+#include "profile-changed-dialog_ui.h"
#include "identity-popup_ui.h"
#include "scrollarea.h"
@@ -151,6 +152,9 @@ gboolean show_popups = FALSE;
gboolean supports_alpha = FALSE;
+/* Keep track of the initially active profile */
+gchar *active_profile = NULL;
+
/* Graphical randr */
GtkWidget *randr_gui_area = NULL;
GList *current_outputs = NULL;
@@ -1461,8 +1465,75 @@ display_settings_dialog_response (GtkDialog *dialog,
if (response_id == GTK_RESPONSE_HELP)
xfce_dialog_show_help_with_version (GTK_WINDOW (dialog), "xfce4-settings", "display",
NULL, XFCE4_SETTINGS_VERSION_SHORT);
- else
+ else if (response_id == GTK_RESPONSE_CLOSE)
+ {
+ gchar *new_active_profile = xfconf_channel_get_string (display_channel, "/ActiveProfile", NULL);
+
+ if (g_strcmp0 (active_profile, new_active_profile) != 0 &&
+ g_strcmp0 (active_profile, "Default") != 0)
+ {
+ GtkBuilder *profile_changed_builder;
+ GError *error = NULL;
+ gint profile_response_id;
+ gchar *property = g_strdup_printf ("/%s", active_profile);
+ gchar *profile_name = xfconf_channel_get_string (display_channel, property, NULL);
+
+ profile_changed_builder = gtk_builder_new ();
+
+ if (gtk_builder_add_from_string (profile_changed_builder, profile_changed_dialog_ui,
+ profile_changed_dialog_ui_length, &error) != 0)
+ {
+ GObject *profile_changed_dialog, *label, *button;
+ const char *str;
+ const char *format = "<big><b>\%s</b></big>";
+ char *markup;
+ gchar *button_label;
+
+ profile_changed_dialog = gtk_builder_get_object (profile_changed_builder, "profile-changed-dialog");
+
+ gtk_window_set_transient_for (GTK_WINDOW (profile_changed_dialog), GTK_WINDOW (dialog));
+ gtk_window_set_modal (GTK_WINDOW (profile_changed_dialog), TRUE);
+
+ label = gtk_builder_get_object (profile_changed_builder, "header");
+ str = g_strdup_printf(_("Update changed display profile '%s'"), profile_name);
+ markup = g_markup_printf_escaped (format, str);
+ gtk_label_set_markup (GTK_LABEL (label), markup);
+
+ button = gtk_builder_get_object (profile_changed_builder, "button-update");
+ button_label = g_strdup_printf (_("_Update '%s'"), profile_name);
+ gtk_button_set_label (GTK_BUTTON (button), button_label);
+
+ profile_response_id = gtk_dialog_run (GTK_DIALOG (profile_changed_dialog));
+ gtk_widget_destroy (GTK_WIDGET (profile_changed_dialog));
+ g_free (markup);
+ g_free (button_label);
+ }
+ else
+ {
+ profile_response_id = 2;
+ g_error ("Failed to load the UI file: %s.", error->message);
+ g_error_free (error);
+ }
+
+ /* update the profile */
+ if (profile_response_id == GTK_RESPONSE_OK)
+ {
+ guint i;
+
+ for (i = 0; i < xfce_randr->noutput; i++)
+ xfce_randr_save_output (xfce_randr, active_profile, display_channel, i);
+
+ xfconf_channel_set_string (display_channel, "/ActiveProfile", active_profile);
+ }
+
+ g_object_unref (G_OBJECT (profile_changed_builder));
+ g_free (profile_name);
+ g_free (property);
+ }
+ g_free (new_active_profile);
+ g_free (active_profile);
gtk_main_quit ();
+ }
}
static void
@@ -3416,8 +3487,11 @@ display_settings_show_main_dialog (GdkDisplay *display)
G_CALLBACK (on_viewport_changed), app);
gui_container = GTK_WIDGET(gtk_builder_get_object(builder, "randr-dnd"));
- gtk_container_add(GTK_CONTAINER(gui_container), GTK_WIDGET(randr_gui_area));
- gtk_widget_show_all(gui_container);
+ gtk_container_add (GTK_CONTAINER(gui_container), GTK_WIDGET(randr_gui_area));
+ gtk_widget_show_all (gui_container);
+
+ /* Keep track of the profile that was active when the dialog was launched */
+ active_profile = xfconf_channel_get_string (display_channel, "/ActiveProfile", "Default");
if (G_UNLIKELY (opt_socket_id == 0))
{
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list