[frogr] Use GtkHeaderBar for dialogs if header bars are enabled at configure time
- From: Mario Sanchez Prada <msanchez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [frogr] Use GtkHeaderBar for dialogs if header bars are enabled at configure time
- Date: Sun, 4 Jan 2015 00:09:25 +0000 (UTC)
commit 56aa9ae6196132e195b8e91ba7c896e5f261b7f7
Author: Mario Sanchez Prada <msanchez gnome org>
Date: Sun Jan 4 00:16:18 2015 +0100
Use GtkHeaderBar for dialogs if header bars are enabled at configure time
Also, raised the minimum GTK+ version for enabling header bars up to
3.12, where the 'use-header-bar' property has been introduced.
configure.ac | 11 ++++++-----
src/frogr-add-tags-dialog.c | 3 +++
src/frogr-add-to-group-dialog.c | 3 +++
src/frogr-add-to-set-dialog.c | 3 +++
src/frogr-auth-dialog.c | 6 ++++--
src/frogr-create-new-set-dialog.c | 3 +++
src/frogr-details-dialog.c | 3 +++
src/frogr-main-view.c | 14 +++++++-------
src/frogr-settings-dialog.c | 3 +++
9 files changed, 35 insertions(+), 14 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 9e96ac5..22e06d7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -72,12 +72,12 @@ AC_MSG_RESULT([$header_bar_feature])
GTK3_MIN_VERSION=3.4
if test "x$header_bar_feature" = "xyes"; then
- with_gtk_3_10="no"
- PKG_CHECK_MODULES(GTK3, gtk+-3.0 >= 3.10,
- [with_gtk_3_10="yes"], [with_gtk_3_10="no"])
+ with_gtk_3_12="no"
+ PKG_CHECK_MODULES(GTK3, gtk+-3.0 >= 3.12,
+ [with_gtk_3_12="yes"], [with_gtk_3_12="no"])
- # Disable header bar and fallback to GTK+ minimum version if 3.10 is not found
- if test "x$with_gtk_3_10" = "xyes"; then
+ # Disable header bar and fallback to GTK+ minimum version if 3.12 is not found
+ if test "x$with_gtk_3_12" = "xyes"; then
AC_DEFINE(USE_HEADER_BAR, 1, [Use GtkHeaderBar])
else
header_bar_feature="no"
@@ -85,6 +85,7 @@ if test "x$header_bar_feature" = "xyes"; then
fi
if test "x$header_bar_feature" = "xno"; then
PKG_CHECK_MODULES(GTK3, gtk+-3.0 >= $GTK3_MIN_VERSION)
+ AC_DEFINE(USE_HEADER_BAR, 0, [Use GtkHeaderBar])
fi
FROGR_CFLAGS="$FROGR_CFLAGS $GTK3_CFLAGS"
FROGR_LIBS="$FROGR_LIBS $GTK3_LIBS"
diff --git a/src/frogr-add-tags-dialog.c b/src/frogr-add-tags-dialog.c
index db98191..d012ad3 100644
--- a/src/frogr-add-tags-dialog.c
+++ b/src/frogr-add-tags-dialog.c
@@ -237,6 +237,9 @@ frogr_add_tags_dialog_show (GtkWindow *parent, const GSList *pictures, const GSL
"pictures", pictures,
"transient-for", parent,
"resizable", TRUE,
+#if GTK_CHECK_VERSION (3, 12, 0)
+ "use-header-bar", USE_HEADER_BAR,
+#endif
NULL);
/* Enable autocompletion if needed */
diff --git a/src/frogr-add-to-group-dialog.c b/src/frogr-add-to-group-dialog.c
index b7e744d..e2bdacd 100644
--- a/src/frogr-add-to-group-dialog.c
+++ b/src/frogr-add-to-group-dialog.c
@@ -608,6 +608,9 @@ frogr_add_to_group_dialog_show (GtkWindow *parent,
"groups", groups,
"transient-for", parent,
"resizable", TRUE,
+#if GTK_CHECK_VERSION (3, 12, 0)
+ "use-header-bar", USE_HEADER_BAR,
+#endif
NULL);
self = FROGR_ADD_TO_GROUP_DIALOG (new);
diff --git a/src/frogr-add-to-set-dialog.c b/src/frogr-add-to-set-dialog.c
index 061e291..0fb3ebc 100644
--- a/src/frogr-add-to-set-dialog.c
+++ b/src/frogr-add-to-set-dialog.c
@@ -609,6 +609,9 @@ frogr_add_to_set_dialog_show (GtkWindow *parent,
"photosets", photosets,
"transient-for", parent,
"resizable", TRUE,
+#if GTK_CHECK_VERSION (3, 12, 0)
+ "use-header-bar", USE_HEADER_BAR,
+#endif
NULL);
self = FROGR_ADD_TO_SET_DIALOG (new);
diff --git a/src/frogr-auth-dialog.c b/src/frogr-auth-dialog.c
index 9858af7..082839a 100644
--- a/src/frogr-auth-dialog.c
+++ b/src/frogr-auth-dialog.c
@@ -141,7 +141,9 @@ _ask_for_auth_confirmation (GtkWindow *parent)
title = g_strdup_printf (_("Authorize %s"), APP_SHORTNAME);
dialog = gtk_dialog_new_with_buttons (title,
parent,
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT |
GTK_DIALOG_USE_HEADER_BAR,
+ _("_Cancel"),
+ GTK_RESPONSE_CANCEL,
_("_Close"),
GTK_RESPONSE_CLOSE,
NULL);
@@ -213,7 +215,7 @@ _ask_for_auth_confirmation_response_cb (GtkDialog *dialog, gint response, gpoint
g_free (vercode_full);
}
- if (valid)
+ if (response == GTK_RESPONSE_CANCEL || valid)
gtk_widget_destroy (GTK_WIDGET (dialog));
}
diff --git a/src/frogr-create-new-set-dialog.c b/src/frogr-create-new-set-dialog.c
index fdf00e9..bfea993 100644
--- a/src/frogr-create-new-set-dialog.c
+++ b/src/frogr-create-new-set-dialog.c
@@ -405,6 +405,9 @@ frogr_create_new_set_dialog_show (GtkWindow *parent,
"width-request", -1,
"height-request", 300,
"resizable", TRUE,
+#if GTK_CHECK_VERSION (3, 12, 0)
+ "use-header-bar", USE_HEADER_BAR,
+#endif
NULL));
g_signal_connect (G_OBJECT (dialog), "response",
diff --git a/src/frogr-details-dialog.c b/src/frogr-details-dialog.c
index 233956b..4442c23 100644
--- a/src/frogr-details-dialog.c
+++ b/src/frogr-details-dialog.c
@@ -1222,6 +1222,9 @@ frogr_details_dialog_show (GtkWindow *parent,
"height-request", -1,
"resizable", TRUE,
"title", _("Edit Picture Details"),
+#if GTK_CHECK_VERSION (3, 12, 0)
+ "use-header-bar", USE_HEADER_BAR,
+#endif
NULL);
/* Initialize values for widgets based on the data (pictures) passed */
diff --git a/src/frogr-main-view.c b/src/frogr-main-view.c
index 214749f..ade90b7 100644
--- a/src/frogr-main-view.c
+++ b/src/frogr-main-view.c
@@ -49,7 +49,7 @@
#define UI_MAIN_VIEW_FILE "/gtkbuilder/frogr-main-view.xml"
#define UI_APP_MENU_FILE "/gtkbuilder/frogr-app-menu.xml"
#define UI_CONTEXT_MENU_FILE "/gtkbuilder/frogr-context-menu.xml"
-#ifdef USE_HEADER_BAR
+#if USE_HEADER_BAR
#define UI_MENU_BUTTON_FILE "/gtkbuilder/frogr-menu-button.xml"
#else
#define UI_MENU_BAR_FILE "/gtkbuilder/frogr-menu-bar.xml"
@@ -116,7 +116,7 @@ typedef struct _FrogrMainViewPrivate {
GtkApplication *gtk_app;
-#ifdef USE_HEADER_BAR
+#if USE_HEADER_BAR
GtkWidget *header_bar;
#endif
GtkWidget *icon_view;
@@ -146,7 +146,7 @@ enum {
FPICTURE_COL
};
-#ifdef USE_HEADER_BAR
+#if USE_HEADER_BAR
typedef enum {
HEADER_BAR_POSITION_START,
HEADER_BAR_POSITION_END
@@ -158,7 +158,7 @@ typedef enum {
static void _initialize_ui (FrogrMainView *self);
static gboolean _initialize_app_menu (FrogrMainView *self);
-#ifdef USE_HEADER_BAR
+#if USE_HEADER_BAR
static void _initialize_header_bar (FrogrMainView *self);
static void _add_item_to_header_bar (FrogrMainView *self, HeaderBarItemPosition pos, const gchar
*action_name, const gchar *icon_name, const gchar *label, const gchar *tooltip_text, const gchar *accel);
#else
@@ -396,7 +396,7 @@ _initialize_ui (FrogrMainView *self)
priv->app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu"));
gtk_application_set_app_menu (priv->gtk_app, priv->app_menu);
-#ifdef USE_HEADER_BAR
+#if USE_HEADER_BAR
/* Header_Bar and main vertical box below*/
_initialize_header_bar (self);
gtk_window_set_titlebar (GTK_WINDOW (self), priv->header_bar);
@@ -563,7 +563,7 @@ _initialize_app_menu (FrogrMainView *self)
return FALSE;
}
-#ifdef USE_HEADER_BAR
+#if USE_HEADER_BAR
/* This function was taken from gtkapplication.c, from gtk+, licensed
* under the GNU Lesser General Public License Version 2+ */
@@ -863,7 +863,7 @@ _update_window_title (FrogrMainView *self, gboolean dirty)
{
FrogrMainViewPrivate *priv = FROGR_MAIN_VIEW_GET_PRIVATE (self);
-#ifdef USE_HEADER_BAR
+#if USE_HEADER_BAR
gchar *title = NULL;
gchar *subtitle = NULL;
diff --git a/src/frogr-settings-dialog.c b/src/frogr-settings-dialog.c
index 5bb9a7d..bcecfea 100644
--- a/src/frogr-settings-dialog.c
+++ b/src/frogr-settings-dialog.c
@@ -1001,6 +1001,9 @@ frogr_settings_dialog_show (GtkWindow *parent)
"transient-for", parent,
"resizable", TRUE,
"title", _("Preferences"),
+#if GTK_CHECK_VERSION (3, 12, 0)
+ "use-header-bar", USE_HEADER_BAR,
+#endif
NULL);
_instance = FROGR_SETTINGS_DIALOG (object);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]