[gnome-flashback] add GfConfirmDisplayChangeDialog and remove old dialog
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback] add GfConfirmDisplayChangeDialog and remove old dialog
- Date: Wed, 27 Sep 2017 22:03:29 +0000 (UTC)
commit c4b2c993a9e2737c6781997a37d99b8f1e474777
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Thu Sep 28 01:00:47 2017 +0300
add GfConfirmDisplayChangeDialog and remove old dialog
configure.ac | 1 +
data/Makefile.am | 1 +
data/ui/Makefile.am | 7 +
.../ui/gf-confirm-display-change-dialog.ui | 92 ++++---
gnome-flashback/Makefile.am | 2 +
gnome-flashback/flashback.gresource.xml | 4 +-
gnome-flashback/gf-confirm-display-change-dialog.c | 252 ++++++++++++++++++++
gnome-flashback/gf-confirm-display-change-dialog.h | 33 +++
gnome-flashback/libdisplay-config/Makefile.am | 6 -
.../libdisplay-config/flashback-confirm-dialog.c | 242 -------------------
.../libdisplay-config/flashback-confirm-dialog.h | 51 ----
.../libdisplay-config/flashback-display-config.c | 1 -
po/POTFILES.in | 4 +-
13 files changed, 353 insertions(+), 343 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index b0ca8a0..7474a78 100644
--- a/configure.ac
+++ b/configure.ac
@@ -284,6 +284,7 @@ AC_CONFIG_FILES([
data/theme/Makefile
data/theme/Adwaita/Makefile
data/theme/HighContrast/Makefile
+ data/ui/Makefile
data/xsessions/Makefile
gnome-flashback/Makefile
diff --git a/data/Makefile.am b/data/Makefile.am
index 29b91ff..4479e5b 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -8,6 +8,7 @@ SUBDIRS = \
schemas \
sessions \
theme \
+ ui \
xsessions \
$(NULL)
diff --git a/data/ui/Makefile.am b/data/ui/Makefile.am
new file mode 100644
index 0000000..dd679d0
--- /dev/null
+++ b/data/ui/Makefile.am
@@ -0,0 +1,7 @@
+NULL =
+
+EXTRA_DIST = \
+ gf-confirm-display-change-dialog.ui \
+ $(NULL)
+
+-include $(top_srcdir)/git.mk
diff --git a/gnome-flashback/libdisplay-config/flashback-confirm-dialog.ui
b/data/ui/gf-confirm-display-change-dialog.ui
similarity index 65%
rename from gnome-flashback/libdisplay-config/flashback-confirm-dialog.ui
rename to data/ui/gf-confirm-display-change-dialog.ui
index 8526f2e..e32d6af 100644
--- a/gnome-flashback/libdisplay-config/flashback-confirm-dialog.ui
+++ b/data/ui/gf-confirm-display-change-dialog.ui
@@ -1,34 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.20.0 -->
<interface domain="gnome-flashback">
- <requires lib="gtk+" version="3.12"/>
- <template class="FlashbackConfirmDialog" parent="GtkWindow">
+ <requires lib="gtk+" version="3.20"/>
+ <template class="GfConfirmDisplayChangeDialog" parent="GtkWindow">
<property name="can_focus">False</property>
- <property name="border_width">12</property>
- <property name="title" translatable="yes">Confirm</property>
<property name="resizable">False</property>
<property name="window_position">center</property>
<property name="type_hint">dialog</property>
+ <property name="skip_taskbar_hint">True</property>
+ <property name="skip_pager_hint">True</property>
<property name="urgency_hint">True</property>
<child>
- <object class="GtkBox" id="content_box">
+ <object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="margin_left">12</property>
+ <property name="margin_right">12</property>
+ <property name="margin_top">12</property>
+ <property name="margin_bottom">12</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
- <object class="GtkBox" id="main_box">
+ <object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="vexpand">True</property>
- <property name="border_width">0</property>
- <property name="baseline_position">top</property>
+ <property name="margin_left">12</property>
+ <property name="margin_right">12</property>
+ <property name="margin_top">12</property>
+ <property name="margin_bottom">12</property>
+ <property name="spacing">16</property>
<child>
- <object class="GtkImage" id="image1">
+ <object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xpad">12</property>
- <property name="ypad">12</property>
+ <property name="valign">center</property>
<property name="icon_name">preferences-desktop-display</property>
<property name="icon_size">6</property>
</object>
@@ -39,20 +44,21 @@
</packing>
</child>
<child>
- <object class="GtkBox" id="box1">
+ <object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
- <property name="spacing">6</property>
+ <property name="spacing">4</property>
<child>
<object class="GtkLabel" id="title">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="halign">start</property>
<property name="label" translatable="yes">Do you want to keep these display
settings?</property>
- <property name="single_line_mode">True</property>
- <property name="lines">1</property>
+ <property name="xalign">0</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
</object>
<packing>
<property name="expand">False</property>
@@ -64,7 +70,8 @@
<object class="GtkLabel" id="description">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="halign">start</property>
+ <property name="label">Settings changes will revert in 20 seconds!</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
@@ -74,55 +81,49 @@
</child>
</object>
<packing>
- <property name="expand">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="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkBox" id="buttons_box">
+ <object class="GtkButtonBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="spacing">12</property>
+ <property name="layout_style">expand</property>
<child>
- <object class="GtkButton" id="keep_changes">
- <property name="label" translatable="yes">_Keep Changes</property>
+ <object class="GtkButton">
+ <property name="label" translatable="yes">_Revert Settings</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="has_focus">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
<property name="receives_default">True</property>
- <property name="halign">end</property>
<property name="use_underline">True</property>
- <signal name="clicked" handler="keep_changes_clicked_cb" swapped="yes"/>
+ <signal name="clicked" handler="revert_settings_clicked_cb" swapped="no"/>
</object>
<packing>
- <property name="expand">False</property>
+ <property name="expand">True</property>
<property name="fill">True</property>
- <property name="pack_type">end</property>
- <property name="position">0</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
- <object class="GtkButton" id="revert_settings">
- <property name="label" translatable="yes">_Revert Settings</property>
+ <object class="GtkButton">
+ <property name="label" translatable="yes">_Keep Changes</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="halign">start</property>
+ <property name="receives_default">True</property>
<property name="use_underline">True</property>
- <signal name="clicked" handler="revert_settings_clicked_cb" swapped="yes"/>
+ <signal name="clicked" handler="keep_changes_clicked_cb" swapped="no"/>
</object>
<packing>
- <property name="expand">False</property>
+ <property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
@@ -131,10 +132,21 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">3</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
</child>
+ <child type="titlebar">
+ <object class="GtkHeaderBar">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="title">Confirm Changes</property>
+ <property name="show_close_button">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
</template>
</interface>
diff --git a/gnome-flashback/Makefile.am b/gnome-flashback/Makefile.am
index 27dad95..f3abfd4 100644
--- a/gnome-flashback/Makefile.am
+++ b/gnome-flashback/Makefile.am
@@ -45,6 +45,8 @@ gnome_flashback_CFLAGS = \
gnome_flashback_SOURCES = \
gf-application.c \
gf-application.h \
+ gf-confirm-display-change-dialog.c \
+ gf-confirm-display-change-dialog.h \
gf-main.c \
gf-session.c \
gf-session.h \
diff --git a/gnome-flashback/flashback.gresource.xml b/gnome-flashback/flashback.gresource.xml
index e35cf55..2452385 100644
--- a/gnome-flashback/flashback.gresource.xml
+++ b/gnome-flashback/flashback.gresource.xml
@@ -6,8 +6,10 @@
<file alias="HighContrast/gnome-flashback.css">../data/theme/HighContrast/gnome-flashback.css</file>
<file
alias="HighContrast/gnome-flashback-dark.css">../data/theme/HighContrast/gnome-flashback-dark.css</file>
</gresource>
+ <gresource prefix="/org/gnome/gnome-flashback/ui">
+ <file alias="gf-confirm-display-change-dialog.ui"
compressed="true">../data/ui/gf-confirm-display-change-dialog.ui</file>
+ </gresource>
<gresource prefix="/org/gnome/gnome-flashback">
- <file alias="flashback-confirm-dialog.ui"
compressed="true">libdisplay-config/flashback-confirm-dialog.ui</file>
<file alias="gf-inhibit-dialog.ui" compressed="true">libend-session-dialog/gf-inhibit-dialog.ui</file>
<file alias="flashback-polkit-dialog.ui" compressed="true">libpolkit/flashback-polkit-dialog.ui</file>
</gresource>
diff --git a/gnome-flashback/gf-confirm-display-change-dialog.c
b/gnome-flashback/gf-confirm-display-change-dialog.c
new file mode 100644
index 0000000..69b661d
--- /dev/null
+++ b/gnome-flashback/gf-confirm-display-change-dialog.c
@@ -0,0 +1,252 @@
+/*
+ * Copyright (C) 2017 Alberts Muktupāvels
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+
+#include "gf-confirm-display-change-dialog.h"
+
+struct _GfConfirmDisplayChangeDialog
+{
+ GtkWindow parent;
+
+ gint timeout;
+ GtkWidget *description;
+
+ guint timeout_id;
+};
+
+enum
+{
+ PROP_0,
+
+ PROP_TIMEOUT,
+
+ LAST_PROP
+};
+
+static GParamSpec *dialog_properties[LAST_PROP] = { NULL };
+
+enum
+{
+ CLOSE,
+ KEEP_CHANGES,
+
+ LAST_SIGNAL
+};
+
+static guint dialog_signals[LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE (GfConfirmDisplayChangeDialog, gf_confirm_display_change_dialog, GTK_TYPE_WINDOW)
+
+static void
+update_description (GfConfirmDisplayChangeDialog *dialog)
+{
+ gchar *description;
+
+ description = g_strdup_printf (ngettext ("Settings changes will revert in %d second!",
+ "Settings changes will revert in %d seconds!",
+ dialog->timeout), dialog->timeout);
+
+ gtk_label_set_text (GTK_LABEL (dialog->description), description);
+ g_free (description);
+}
+
+static gboolean
+timeout_cb (gpointer user_data)
+{
+ GfConfirmDisplayChangeDialog *dialog;
+
+ dialog = GF_CONFIRM_DISPLAY_CHANGE_DIALOG (user_data);
+
+ if (dialog->timeout == 0)
+ {
+ dialog->timeout = 0;
+
+ g_signal_emit (dialog, dialog_signals[KEEP_CHANGES], 0, FALSE);
+ return G_SOURCE_REMOVE;
+ }
+
+ dialog->timeout--;
+
+ update_description (dialog);
+ return G_SOURCE_CONTINUE;
+}
+
+static void
+keep_changes_clicked_cb (GtkButton *button,
+ GfConfirmDisplayChangeDialog *dialog)
+{
+ g_signal_emit (dialog, dialog_signals[KEEP_CHANGES], 0, TRUE);
+}
+
+static void
+revert_settings_clicked_cb (GtkButton *button,
+ GfConfirmDisplayChangeDialog *dialog)
+{
+ g_signal_emit (dialog, dialog_signals[KEEP_CHANGES], 0, FALSE);
+}
+
+static void
+close_cb (GfConfirmDisplayChangeDialog *dialog,
+ gpointer user_data)
+{
+ g_signal_emit (dialog, dialog_signals[KEEP_CHANGES], 0, FALSE);
+}
+
+static gboolean
+delete_event_cb (GfConfirmDisplayChangeDialog *dialog,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ g_signal_emit (dialog, dialog_signals[KEEP_CHANGES], 0, FALSE);
+ return TRUE;
+}
+
+static void
+gf_confirm_display_change_dialog_finalize (GObject *object)
+{
+ GfConfirmDisplayChangeDialog *dialog;
+
+ dialog = GF_CONFIRM_DISPLAY_CHANGE_DIALOG (object);
+
+ if (dialog->timeout_id > 0)
+ {
+ g_source_remove (dialog->timeout_id);
+ dialog->timeout_id = 0;
+ }
+
+ G_OBJECT_CLASS (gf_confirm_display_change_dialog_parent_class)->finalize (object);
+}
+
+static void
+gf_confirm_display_change_dialog_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GfConfirmDisplayChangeDialog *dialog;
+
+ dialog = GF_CONFIRM_DISPLAY_CHANGE_DIALOG (object);
+
+ switch (property_id)
+ {
+ case PROP_TIMEOUT:
+ dialog->timeout = g_value_get_int (value);
+ update_description (dialog);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gf_confirm_display_change_dialog_show (GtkWidget *widget)
+{
+ GfConfirmDisplayChangeDialog *dialog;
+
+ dialog = GF_CONFIRM_DISPLAY_CHANGE_DIALOG (widget);
+ GTK_WIDGET_CLASS (gf_confirm_display_change_dialog_parent_class)->show (widget);
+
+ if (dialog->timeout_id == 0)
+ {
+ dialog->timeout_id = g_timeout_add (1000, timeout_cb, dialog);
+ g_source_set_name_by_id (dialog->timeout_id, "[gnome-flashback] timeout_cb");
+ }
+}
+
+static void
+install_properties (GObjectClass *object_class)
+{
+ dialog_properties[PROP_TIMEOUT] =
+ g_param_spec_int ("timeout", "timeout", "timeout",
+ G_MININT, G_MAXINT, 20,
+ G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, LAST_PROP,
+ dialog_properties);
+}
+
+static void
+install_signals (GObjectClass *object_class)
+{
+ dialog_signals[CLOSE] =
+ g_signal_new ("close",
+ GF_TYPE_CONFIRM_DISPLAY_CHANGE_DIALOG,
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ 0, NULL, NULL, NULL, G_TYPE_NONE, 0);
+
+ dialog_signals[KEEP_CHANGES] =
+ g_signal_new ("keep-changes",
+ GF_TYPE_CONFIRM_DISPLAY_CHANGE_DIALOG,
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL, G_TYPE_NONE, 1,
+ G_TYPE_BOOLEAN);
+}
+
+static void
+gf_confirm_display_change_dialog_class_init (GfConfirmDisplayChangeDialogClass *dialog_class)
+{
+ GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
+ GtkBindingSet *binding_set;
+ const gchar *resource_name;
+
+ object_class = G_OBJECT_CLASS (dialog_class);
+ widget_class = GTK_WIDGET_CLASS (dialog_class);
+
+ object_class->finalize = gf_confirm_display_change_dialog_finalize;
+ object_class->set_property = gf_confirm_display_change_dialog_set_property;
+
+ widget_class->show = gf_confirm_display_change_dialog_show;
+
+ install_properties (object_class);
+ install_signals (object_class);
+
+ binding_set = gtk_binding_set_by_class (dialog_class);
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, "close", 0);
+
+ resource_name = "/org/gnome/gnome-flashback/ui/gf-confirm-display-change-dialog.ui";
+ gtk_widget_class_set_template_from_resource (widget_class, resource_name);
+
+ gtk_widget_class_bind_template_child (widget_class, GfConfirmDisplayChangeDialog, description);
+
+ gtk_widget_class_bind_template_callback (widget_class, keep_changes_clicked_cb);
+ gtk_widget_class_bind_template_callback (widget_class, revert_settings_clicked_cb);
+}
+
+static void
+gf_confirm_display_change_dialog_init (GfConfirmDisplayChangeDialog *dialog)
+{
+ gtk_widget_init_template (GTK_WIDGET (dialog));
+ gtk_window_set_keep_above (GTK_WINDOW (dialog), TRUE);
+
+ g_signal_connect (dialog, "close", G_CALLBACK (close_cb), NULL);
+ g_signal_connect (dialog, "delete-event", G_CALLBACK (delete_event_cb), NULL);
+}
+
+GtkWidget *
+gf_confirm_display_change_dialog_new (gint timeout)
+{
+ return g_object_new (GF_TYPE_CONFIRM_DISPLAY_CHANGE_DIALOG,
+ "timeout", timeout,
+ NULL);
+}
diff --git a/gnome-flashback/gf-confirm-display-change-dialog.h
b/gnome-flashback/gf-confirm-display-change-dialog.h
new file mode 100644
index 0000000..c9da3ce
--- /dev/null
+++ b/gnome-flashback/gf-confirm-display-change-dialog.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2017 Alberts Muktupāvels
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GF_CONFIRM_DISPLAY_CHANGE_DIALOG_H
+#define GF_CONFIRM_DISPLAY_CHANGE_DIALOG_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GF_TYPE_CONFIRM_DISPLAY_CHANGE_DIALOG (gf_confirm_display_change_dialog_get_type ())
+G_DECLARE_FINAL_TYPE (GfConfirmDisplayChangeDialog, gf_confirm_display_change_dialog,
+ GF, CONFIRM_DISPLAY_CHANGE_DIALOG, GtkWindow)
+
+GtkWidget *gf_confirm_display_change_dialog_new (gint timeout);
+
+G_END_DECLS
+
+#endif
diff --git a/gnome-flashback/libdisplay-config/Makefile.am b/gnome-flashback/libdisplay-config/Makefile.am
index 6833bfe..9029bcd 100644
--- a/gnome-flashback/libdisplay-config/Makefile.am
+++ b/gnome-flashback/libdisplay-config/Makefile.am
@@ -20,8 +20,6 @@ libdisplay_config_la_SOURCES = \
edid-parse.c \
edid.h \
meta-display-config-shared.h \
- flashback-confirm-dialog.c \
- flashback-confirm-dialog.h \
flashback-display-config.c \
flashback-display-config.h \
flashback-monitor-manager.c \
@@ -37,8 +35,4 @@ libdisplay_config_la_LIBADD = \
$(DISPLAY_CONFIG_LIBS) \
$(NULL)
-EXTRA_DIST = \
- flashback-confirm-dialog.ui \
- $(NULL)
-
-include $(top_srcdir)/git.mk
diff --git a/gnome-flashback/libdisplay-config/flashback-display-config.c
b/gnome-flashback/libdisplay-config/flashback-display-config.c
index 60db776..a562273 100644
--- a/gnome-flashback/libdisplay-config/flashback-display-config.c
+++ b/gnome-flashback/libdisplay-config/flashback-display-config.c
@@ -29,7 +29,6 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <math.h>
-#include "flashback-confirm-dialog.h"
#include "flashback-display-config.h"
#include "flashback-monitor-manager.h"
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 296ce67..6bd42c3 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -11,15 +11,15 @@ data/schemas/org.gnome.gnome-flashback.gschema.xml
data/schemas/org.gnome.gnome-flashback.desktop-background.gschema.xml
data/schemas/org.gnome.gnome-flashback.input-sources.gschema.xml
data/schemas/org.gnome.gnome-flashback.workarounds.gschema.xml
+data/ui/gf-confirm-display-change-dialog.ui
data/xsessions/gnome-flashback-compiz.desktop.in.in
data/xsessions/gnome-flashback-metacity.desktop.in.in
+gnome-flashback/gf-confirm-display-change-dialog.c
gnome-flashback/gf-main.c
gnome-flashback/libaudio-device-selection/gf-audio-device-selection-dialog.c
gnome-flashback/libautomount-manager/gsd-automount-manager.c
gnome-flashback/libautomount-manager/gsd-autorun.c
gnome-flashback/libbluetooth-applet/gf-bluetooth-applet.c
-gnome-flashback/libdisplay-config/flashback-confirm-dialog.ui
-gnome-flashback/libdisplay-config/flashback-display-config.c
gnome-flashback/libend-session-dialog/gf-inhibit-dialog.c
gnome-flashback/libend-session-dialog/gf-inhibit-dialog.ui
gnome-flashback/libinput-sources/gf-input-sources.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]