aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-06-21 13:29:08 -0500
committerTed Gould <ted@gould.cx>2011-06-21 13:29:08 -0500
commit4102a7b9cd77973b8f01c8425d8570b632a93cf0 (patch)
tree5dda9b9d7f68c22776a812726adc36b697298a6a
parent7b878caf9f39ee8d8a799f6454e079e35fe2a962 (diff)
parent7f2f5fbb5d6df00f9697bd604b437bbd250cf528 (diff)
downloadayatana-indicator-datetime-4102a7b9cd77973b8f01c8425d8570b632a93cf0.tar.gz
ayatana-indicator-datetime-4102a7b9cd77973b8f01c8425d8570b632a93cf0.tar.bz2
ayatana-indicator-datetime-4102a7b9cd77973b8f01c8425d8570b632a93cf0.zip
GTK 3 Support
-rw-r--r--configure.ac93
-rw-r--r--libmap/cc-timezone-map.c52
-rw-r--r--src/datetime-prefs.c83
-rw-r--r--src/timezone-completion.c6
4 files changed, 86 insertions, 148 deletions
diff --git a/configure.ac b/configure.ac
index 1504c6a..125ce7d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -43,9 +43,9 @@ PKG_PROG_PKG_CONFIG
AC_ARG_WITH([gtk],
[AS_HELP_STRING([--with-gtk],
- [Which version of gtk to use @<:@default=2@:>@])],
+ [Which version of gtk to use for the indicator @<:@default=3@:>@])],
[],
- [with_gtk=2])
+ [with_gtk=3])
###########################
# Dependencies
@@ -55,7 +55,6 @@ INDICATOR_REQUIRED_VERSION=0.3.19
DBUSMENUGLIB_REQUIRED_VERSION=0.1.1
DBUSMENUGTK_REQUIRED_VERSION=0.3.94
GIO_REQUIRED_VERSION=2.25.11
-# Note: the GIO check below also ensures the proper glib with gsettings support is present
INDICATOR_DISPLAY_OBJECTS=0.2.2
GEOCLUE_REQUIRED_VERSION=0.12.0
ECAL_REQUIRED_VERSION=2.30
@@ -64,8 +63,7 @@ ICAL_REQUIRED_VERSION=0.44
CAIRO_REQUIRED_VERSION=1.10
GDK_REQUIRED_VERSION=2.22
GLIB_REQUIRED_VERSION=2.26
-GTK_REQUIRED_VERSION=2.12
-GTK3_REQUIRED_VERSION=3.0
+GTK3_REQUIRED_VERSION=3.1.4
GCONF_REQUIRED_VERSION=2.31
AS_IF([test "x$with_gtk" = x3],
@@ -85,69 +83,30 @@ AS_IF([test "x$with_gtk" = x3],
[AC_MSG_FAILURE([Value for --with-gtk was neither 2 nor 3])]
)
-AS_IF([test "x$with_gtk" = x3],
- [PKG_CHECK_MODULES(SERVICE, indicator >= $INDICATOR_REQUIRED_VERSION
- glib-2.0 >= $GLIB_REQUIRED_VERSION
- dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION
- dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION
- libido-0.1 >= $INDICATOR_DISPLAY_OBJECTS
- gio-2.0 >= $GIO_REQUIRED_VERSION
- geoclue >= $GEOCLUE_REQUIRED_VERSION
- libecal-1.2 >= $ECAL_REQUIRED_VERSION
- libical >= $ICAL_REQUIRED_VERSION
- libedataserver-1.2 >= EDS_REQUIRED_VERSION
- libedataserverui-1.2 >= EDS_REQUIRED_VERSION
- cairo >= CAIRO_REQUIRED_VERSION
- gdk-2.0 >= GDK_REQUIRED_VERSION
- gconf-2.0 >= GCONF_REQUIRED_VERSION)
- ],
- [test "x$with_gtk" = x2],
- [PKG_CHECK_MODULES(SERVICE, indicator >= $INDICATOR_REQUIRED_VERSION
- glib-2.0 >= $GLIB_REQUIRED_VERSION
- dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION
- dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION
- libido-0.1 >= $INDICATOR_DISPLAY_OBJECTS
- gio-2.0 >= $GIO_REQUIRED_VERSION
- geoclue >= $GEOCLUE_REQUIRED_VERSION
- libecal-1.2 >= $ECAL_REQUIRED_VERSION
- libical >= $ICAL_REQUIRED_VERSION
- libedataserver-1.2 >= EDS_REQUIRED_VERSION
- libedataserverui-1.2 >= EDS_REQUIRED_VERSION
- cairo >= CAIRO_REQUIRED_VERSION
- gdk-2.0 >= GDK_REQUIRED_VERSION
- gconf-2.0 >= GCONF_REQUIRED_VERSION)
- ],
- [AC_MSG_FAILURE([Value for --with-gtk was neither 2 nor 3])]
-)
+PKG_CHECK_MODULES(SERVICE, indicator3 >= $INDICATOR_REQUIRED_VERSION
+ glib-2.0 >= $GLIB_REQUIRED_VERSION
+ dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION
+ dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION
+ libido3-0.1 >= $INDICATOR_DISPLAY_OBJECTS
+ gio-2.0 >= $GIO_REQUIRED_VERSION
+ geoclue >= $GEOCLUE_REQUIRED_VERSION
+ libecal-1.2 >= $ECAL_REQUIRED_VERSION
+ libical >= $ICAL_REQUIRED_VERSION
+ libedataserver-1.2 >= EDS_REQUIRED_VERSION
+ libedataserverui-3.0 >= EDS_REQUIRED_VERSION
+ cairo >= CAIRO_REQUIRED_VERSION
+ gdk-3.0 >= GDK_REQUIRED_VERSION
+ gconf-2.0 >= GCONF_REQUIRED_VERSION)
+
+PKG_CHECK_MODULES(PREF, gio-2.0 >= $GIO_REQUIRED_VERSION
+ gtk+-3.0 >= $GTK3_REQUIRED_VERSION
+ unique-3.0
+ json-glib-1.0
+ polkit-gobject-1)
+
+PKG_CHECK_MODULES(LIBMAP, gio-2.0 >= $GIO_REQUIRED_VERSION
+ gtk+-3.0 >= $GTK3_REQUIRED_VERSION)
-# FIXME: polkit-gtk-1 isn't gtk3-compatible
-AS_IF([test "x$with_gtk" = x3],
- [PKG_CHECK_MODULES(PREF, gio-2.0 >= $GIO_REQUIRED_VERSION
- gtk+-3.0 >= $GTK3_REQUIRED_VERSION
- unique-3.0
- json-glib-1.0
- polkit-gtk-1)
- ],
- [test "x$with_gtk" = x2],
- [PKG_CHECK_MODULES(PREF, gio-2.0 >= $GIO_REQUIRED_VERSION
- gtk+-2.0 >= $GTK_REQUIRED_VERSION
- unique-1.0
- json-glib-1.0
- polkit-gtk-1)
- ],
- [AC_MSG_FAILURE([Value for --with-gtk was neither 2 nor 3])]
-)
-
-AS_IF([test "x$with_gtk" = x3],
- [PKG_CHECK_MODULES(LIBMAP, gio-2.0 >= $GIO_REQUIRED_VERSION
- gtk+-3.0 >= $GTK3_REQUIRED_VERSION)
- ],
- [test "x$with_gtk" = x2],
- [PKG_CHECK_MODULES(LIBMAP, gio-2.0 >= $GIO_REQUIRED_VERSION
- gtk+-2.0 >= $GTK_REQUIRED_VERSION)
- ],
- [AC_MSG_FAILURE([Value for --with-gtk was neither 2 nor 3])]
-)
AC_SUBST(INDICATOR_CFLAGS)
AC_SUBST(INDICATOR_LIBS)
diff --git a/libmap/cc-timezone-map.c b/libmap/cc-timezone-map.c
index 7b7d704..5ce1354 100644
--- a/libmap/cc-timezone-map.c
+++ b/libmap/cc-timezone-map.c
@@ -601,7 +601,6 @@ cc_timezone_map_finalize (GObject *object)
}
/* GtkWidget functions */
-#ifdef CCGTK3
static void
cc_timezone_map_get_preferred_width (GtkWidget *widget,
gint *minimum,
@@ -634,25 +633,6 @@ cc_timezone_map_get_preferred_height (GtkWidget *widget,
*natural = size;
}
-#else
-
-static void
-cc_timezone_map_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- CcTimezoneMapPrivate *priv = CC_TIMEZONE_MAP (widget)->priv;
-
- if (!requisition)
- return;
-
- /* The + 20 here is a slight tweak to make the map fill the
- * panel better without causing horizontal growing
- */
- requisition->height = 300 * gdk_pixbuf_get_height (priv->orig_background) / gdk_pixbuf_get_width (priv->orig_background) + 20;
- requisition->width = 300;
-}
-#endif
-
static void
cc_timezone_map_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
@@ -853,21 +833,6 @@ cc_timezone_map_draw (GtkWidget *widget,
return TRUE;
}
-#ifndef CCGTK3
-static gboolean
-cc_timezone_map_expose_event (GtkWidget *widget,
- GdkEventExpose *event)
-{
- gboolean rv;
- cairo_t *cr;
- cr = gdk_cairo_create (widget->window);
- rv = cc_timezone_map_draw (widget, cr);
- cairo_destroy (cr);
- return rv;
-}
-#endif
-
-
static void
cc_timezone_map_class_init (CcTimezoneMapClass *klass)
{
@@ -881,19 +846,11 @@ cc_timezone_map_class_init (CcTimezoneMapClass *klass)
object_class->dispose = cc_timezone_map_dispose;
object_class->finalize = cc_timezone_map_finalize;
-#ifdef CCGTK3
widget_class->get_preferred_width = cc_timezone_map_get_preferred_width;
widget_class->get_preferred_height = cc_timezone_map_get_preferred_height;
-#else
- widget_class->size_request = cc_timezone_map_size_request;
-#endif
widget_class->size_allocate = cc_timezone_map_size_allocate;
widget_class->realize = cc_timezone_map_realize;
-#ifdef CCGTK3
widget_class->draw = cc_timezone_map_draw;
-#else
- widget_class->expose_event = cc_timezone_map_expose_event;
-#endif
signals[LOCATION_CHANGED] = g_signal_new ("location-changed",
CC_TYPE_TIMEZONE_MAP,
@@ -1015,6 +972,13 @@ button_press_event (GtkWidget *widget,
}
static void
+state_flags_changed (GtkWidget *widget)
+{
+ // To catch sensitivity changes
+ gtk_widget_queue_draw (widget);
+}
+
+static void
load_backward_tz (CcTimezoneMap *self)
{
GError *error = NULL;
@@ -1108,6 +1072,8 @@ cc_timezone_map_init (CcTimezoneMap *self)
g_signal_connect (self, "button-press-event", G_CALLBACK (button_press_event),
NULL);
+ g_signal_connect (self, "state-flags-changed", G_CALLBACK (state_flags_changed),
+ NULL);
load_backward_tz (self);
}
diff --git a/src/datetime-prefs.c b/src/datetime-prefs.c
index 9b00e60..85068c7 100644
--- a/src/datetime-prefs.c
+++ b/src/datetime-prefs.c
@@ -33,7 +33,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include <unique/unique.h>
-#include <polkitgtk/polkitgtk.h>
+#include <polkit/polkit.h>
#include "dbus-shared.h"
#include "settings-shared.h"
@@ -115,23 +115,49 @@ add_widget_dependency (GtkWidget * parent, GtkWidget * dependent)
}
static void
-polkit_dependency_cb (GtkWidget * parent, GParamSpec *pspec, GtkWidget * dependent)
+polkit_dependency_cb (GPermission * permission, GParamSpec *pspec, GtkWidget * dependent)
{
- gboolean authorized, sensitive;
- g_object_get (G_OBJECT (parent),
- "is-authorized", &authorized,
- "sensitive", &sensitive, NULL);
- gtk_widget_set_sensitive (dependent, authorized && sensitive);
+ gboolean allowed = FALSE;
+
+ g_object_get (G_OBJECT (permission),
+ "allowed", &allowed, NULL);
+
+ gtk_widget_set_sensitive (dependent, allowed);
+}
+
+static void
+add_polkit_dependency_helper (GtkWidget * parent, GParamSpec *pspec, GtkWidget * dependent)
+{
+ GtkLockButton * button = GTK_LOCK_BUTTON (parent);
+ GPermission * permission = gtk_lock_button_get_permission (button);
+ g_signal_connect (permission, "notify::allowed",
+ G_CALLBACK(polkit_dependency_cb), dependent);
+ polkit_dependency_cb (permission, NULL, dependent);
}
static void
add_polkit_dependency (GtkWidget * parent, GtkWidget * dependent)
{
- g_signal_connect (parent, "notify::is-authorized", G_CALLBACK(polkit_dependency_cb),
+ /* polkit async hasn't finished at this point, so wait for permission to come in */
+ g_signal_connect (parent, "notify::permission", G_CALLBACK(add_polkit_dependency_helper),
dependent);
- g_signal_connect (parent, "notify::sensitive", G_CALLBACK(polkit_dependency_cb),
- dependent);
- polkit_dependency_cb (parent, NULL, dependent);
+ gtk_widget_set_sensitive (dependent, FALSE);
+}
+
+static void
+polkit_perm_ready (GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+ GError * error = NULL;
+ GPermission * permission = polkit_permission_new_finish (res, &error);
+
+ if (error != NULL) {
+ g_warning ("Could not get permission object: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ GtkLockButton * button = GTK_LOCK_BUTTON (user_data);
+ gtk_lock_button_set_permission (button, permission);
}
static void
@@ -594,21 +620,6 @@ key_pressed (GtkWidget * widget, GdkEventKey * event, gpointer user_data)
}
static GtkWidget *
-get_child_of_type (GtkContainer * parent, GType type)
-{
- GList * children, * iter;
-
- children = gtk_container_get_children (parent);
- for (iter = children; iter; iter = iter->next) {
- if (G_TYPE_CHECK_INSTANCE_TYPE (iter->data, type)) {
- return GTK_WIDGET (iter->data);
- }
- }
-
- return NULL;
-}
-
-static GtkWidget *
create_dialog (void)
{
GError * error = NULL;
@@ -629,15 +640,17 @@ create_dialog (void)
#define WIG(name) GTK_WIDGET (gtk_builder_get_object (builder, name))
/* Add policykit button */
- GtkWidget * polkit_button = polkit_lock_button_new ("org.gnome.settingsdaemon.datetimemechanism.configure");
- polkit_lock_button_set_unlock_text (POLKIT_LOCK_BUTTON (polkit_button), _("Unlock to change these settings"));
- polkit_lock_button_set_lock_text (POLKIT_LOCK_BUTTON (polkit_button), _("Lock to prevent further changes"));
- gtk_box_pack_start (GTK_BOX (WIG ("timeDateBox")), polkit_button, FALSE, TRUE, 0);
- /* Make sure border around button is visible */
- GtkWidget * polkit_button_button = get_child_of_type (GTK_CONTAINER (polkit_button), GTK_TYPE_BUTTON);
- if (polkit_button_button != NULL) {
- gtk_button_set_relief (GTK_BUTTON (polkit_button_button), GTK_RELIEF_NORMAL);
- }
+ GtkWidget * polkit_button = gtk_lock_button_new (NULL);
+ g_object_set (G_OBJECT (polkit_button),
+ "text-unlock", _("Unlock to change these settings"),
+ "text-lock", _("Lock to prevent further changes"),
+ NULL);
+ GtkWidget * alignment = gtk_alignment_new (0.0, 0.5, 0.0, 0.0);
+ gtk_container_add (GTK_CONTAINER (alignment), polkit_button);
+ gtk_box_pack_start (GTK_BOX (WIG ("timeDateBox")), alignment, FALSE, TRUE, 0);
+
+ const gchar * polkit_name = "org.gnome.settingsdaemon.datetimemechanism.configure";
+ polkit_permission_new (polkit_name, NULL, NULL, polkit_perm_ready, polkit_button);
/* Add map */
tzmap = cc_timezone_map_new ();
diff --git a/src/timezone-completion.c b/src/timezone-completion.c
index 7dcc28e..6ba1e88 100644
--- a/src/timezone-completion.c
+++ b/src/timezone-completion.c
@@ -455,9 +455,9 @@ find_popup_treeview (GtkWidget * widget, GtkTreeModel * model)
static gboolean
entry_keypress (GtkEntry * entry, GdkEventKey *event, TimezoneCompletion * completion)
{
- if (event->keyval == GDK_ISO_Enter ||
- event->keyval == GDK_KP_Enter ||
- event->keyval == GDK_Return) {
+ if (event->keyval == GDK_KEY_ISO_Enter ||
+ event->keyval == GDK_KEY_KP_Enter ||
+ event->keyval == GDK_KEY_Return) {
/* Make sure that user has a selection to choose, otherwise ignore */
GtkTreeModel * model = gtk_entry_completion_get_model (GTK_ENTRY_COMPLETION (completion));
GtkTreeView * view = find_popup_treeview (GTK_WIDGET (entry), model);