From 446385cf45b3702fba437dfbd1d0740e72740b36 Mon Sep 17 00:00:00 2001 From: karl-qdh Date: Fri, 15 Apr 2011 14:20:50 +0100 Subject: Prevent long appointment titles making the menu too wide --- src/indicator-datetime.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index 1c05ff0..a992507 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -1285,6 +1285,7 @@ new_appointment_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbu /* Label, probably a username, chat room or mailbox name */ mi_data->label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, APPOINTMENT_MENUITEM_PROP_LABEL)); gtk_misc_set_alignment(GTK_MISC(mi_data->label), 0.0, 0.5); + gtk_label_set_ellipsize(GTK_LABEL(mi_data->label), PANGO_ELLIPSIZE_END); gtk_box_pack_start(GTK_BOX(hbox), mi_data->label, TRUE, TRUE, 0); gtk_widget_show(mi_data->label); -- cgit v1.2.3 From 00518ac99caea18f056e911b4c9c4a7f1e62727b Mon Sep 17 00:00:00 2001 From: karl-qdh Date: Mon, 18 Apr 2011 10:41:58 +0100 Subject: min/max width for appointments --- src/indicator-datetime.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index 1c05ff0..58053ef 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -1285,6 +1285,13 @@ new_appointment_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbu /* Label, probably a username, chat room or mailbox name */ mi_data->label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, APPOINTMENT_MENUITEM_PROP_LABEL)); gtk_misc_set_alignment(GTK_MISC(mi_data->label), 0.0, 0.5); + + GtkStyle * style = gtk_widget_get_style(GTK_WIDGET(mi_data->label)); + PangoContext * context = gtk_widget_get_pango_context(GTK_WIDGET(mi_data->label)); + gint length = measure_string(style, context, "GGGGGGGGGGGGGGG"); // 15 char wide string max + gtk_widget_set_size_request(GTK_WIDGET(mi_data->label), length, -1); // Set the min size in pixels + + gtk_label_set_ellipsize(GTK_LABEL(mi_data->label), PANGO_ELLIPSIZE_END); gtk_box_pack_start(GTK_BOX(hbox), mi_data->label, TRUE, TRUE, 0); gtk_widget_show(mi_data->label); -- cgit v1.2.3 From 969771d64ab89a61a821420cb15f1bd04243c940 Mon Sep 17 00:00:00 2001 From: karl-qdh Date: Mon, 18 Apr 2011 10:57:40 +0100 Subject: indentation --- src/indicator-datetime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index 58053ef..db71e9d 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -1287,8 +1287,8 @@ new_appointment_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbu gtk_misc_set_alignment(GTK_MISC(mi_data->label), 0.0, 0.5); GtkStyle * style = gtk_widget_get_style(GTK_WIDGET(mi_data->label)); - PangoContext * context = gtk_widget_get_pango_context(GTK_WIDGET(mi_data->label)); - gint length = measure_string(style, context, "GGGGGGGGGGGGGGG"); // 15 char wide string max + PangoContext * context = gtk_widget_get_pango_context(GTK_WIDGET(mi_data->label)); + gint length = measure_string(style, context, "GGGGGGGGGGGGGGG"); // 15 char wide string max gtk_widget_set_size_request(GTK_WIDGET(mi_data->label), length, -1); // Set the min size in pixels gtk_label_set_ellipsize(GTK_LABEL(mi_data->label), PANGO_ELLIPSIZE_END); -- cgit v1.2.3 From 5325c7a9c8ca4779f0336424b9e349fcba8d681f Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Sun, 5 Jun 2011 20:45:28 +0200 Subject: fix two spelling mistakes spotted by lintian --- src/indicator-datetime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index eb4b695..800fa87 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -270,7 +270,7 @@ static void menu_visible_notfy_cb(GtkWidget * menu, G_GNUC_UNUSED GParamSpec *pspec, gpointer user_data) { IndicatorDatetime * self = INDICATOR_DATETIME(user_data); - g_debug("notify visible signal recieved"); + g_debug("notify visible signal received"); // we should only react if we're currently visible gboolean visible; @@ -1077,7 +1077,7 @@ guess_label_size (IndicatorDatetime * self) GArray * timevals = g_array_new(FALSE, TRUE, sizeof(struct tm)); build_timeval_array(timevals, posibilitymask); - g_debug("Checking against %d posible times", timevals->len); + g_debug("Checking against %d possible times", timevals->len); gint check_time; for (check_time = 0; check_time < timevals->len; check_time++) { gchar longstr[256]; -- cgit v1.2.3 From 7f2f5fbb5d6df00f9697bd604b437bbd250cf528 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Wed, 15 Jun 2011 10:44:57 -0400 Subject: finish port to gtk3 --- configure.ac | 93 +++++++++++++---------------------------------- libmap/cc-timezone-map.c | 52 +++++--------------------- src/datetime-prefs.c | 83 ++++++++++++++++++++++++------------------ src/timezone-completion.c | 6 +-- 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, @@ -1014,6 +971,13 @@ button_press_event (GtkWidget *widget, return TRUE; } +static void +state_flags_changed (GtkWidget *widget) +{ + // To catch sensitivity changes + gtk_widget_queue_draw (widget); +} + static void load_backward_tz (CcTimezoneMap *self) { @@ -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 . #include #include #include -#include +#include #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 @@ -593,21 +619,6 @@ key_pressed (GtkWidget * widget, GdkEventKey * event, gpointer user_data) return FALSE; } -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) { @@ -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); -- cgit v1.2.3 From 3c5f6a06ff0e44945f788254c44ede18f4061724 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 21 Jun 2011 13:49:37 -0500 Subject: 0.2.90 --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 125ce7d..810bab0 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(indicator-datetime, 0.2.3, ted@canonical.com) +AC_INIT(indicator-datetime, 0.2.90, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-datetime, 0.2.3) +AM_INIT_AUTOMAKE(indicator-datetime, 0.2.90) AM_MAINTAINER_MODE -- cgit v1.2.3