From b2b83a02f97e077f1b42bf6e16210b368fb6a710 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Sun, 22 Jan 2012 10:57:19 +0100 Subject: Use gtk_box_new instead of gtk_hbox_new gtk_hbox_new is deprecated and using it broke the build with -Werror=deprecated-declarations, which seems to be enabled by default. --- src/indicator-messages.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index d13de56..82fcfaf 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -695,7 +695,7 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm gint font_size = RIGHT_LABEL_FONT_SIZE; gtk_widget_style_get(GTK_WIDGET(gmi), "toggle-spacing", &padding, NULL); - GtkWidget * hbox = gtk_hbox_new(FALSE, padding); + GtkWidget * hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, padding); /* Icon, probably someone's face or avatar on an IM */ mi_data->icon = gtk_image_new(); -- cgit v1.2.3 From fbe01602bb5e3f9c7f6c25bc704387771da87895 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Sun, 22 Jan 2012 11:41:22 +0100 Subject: Don't force lozenges to have the same width This makes the menu more consistent with the mockups at https://wiki.ubuntu.com/MessagingMenu and https://wiki.ubuntu.com/MenuLayout --- src/indicator-messages.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 82fcfaf..32ed98a 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -78,7 +78,6 @@ INDICATOR_SET_TYPE(INDICATOR_MESSAGES_TYPE) /* Globals */ static GtkWidget * main_image = NULL; static GDBusProxy * icon_proxy = NULL; -static GtkSizeGroup * indicator_right_group = NULL; static GDBusNodeInfo * bus_node_info = NULL; static GDBusInterfaceInfo * bus_interface_info = NULL; static const gchar * accessible_desc = NULL; @@ -743,7 +742,6 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm /* Usually either the time or the count on the individual item. */ mi_data->right = gtk_label_new(dbusmenu_menuitem_property_get(newitem, INDICATOR_MENUITEM_PROP_RIGHT)); - gtk_size_group_add_widget(indicator_right_group, mi_data->right); /* install extra decoration overlay */ #if GTK_CHECK_VERSION(3, 0, 0) g_signal_connect (G_OBJECT (mi_data->right), "draw", @@ -782,8 +780,6 @@ get_icon (IndicatorObject * io) static GtkMenu * get_menu (IndicatorObject * io) { - indicator_right_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); - DbusmenuGtkMenu * menu = dbusmenu_gtkmenu_new(INDICATOR_MESSAGES_DBUS_NAME, INDICATOR_MESSAGES_DBUS_OBJECT); DbusmenuGtkClient * client = dbusmenu_gtkmenu_get_client(menu); -- cgit v1.2.3 From 0d029e38b6d9b0f556b8d994385e972107c766a1 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Sun, 22 Jan 2012 12:04:41 +0100 Subject: Get the menu's current font size instead of hard coding it to 12pt --- src/indicator-messages.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 32ed98a..bb1d618 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -53,9 +53,6 @@ with this program. If not, see . #define M_PI 3.1415926535897932384626433832795028841971693993751 -#define RIGHT_LABEL_FONT_SIZE 12 -#define RIGHT_LABEL_RADIUS 20 - typedef struct _IndicatorMessages IndicatorMessages; typedef struct _IndicatorMessagesClass IndicatorMessagesClass; @@ -485,12 +482,23 @@ application_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer return FALSE; } +static gint +gtk_widget_get_font_size (GtkWidget *widget) +{ + const PangoFontDescription *font; + + font = gtk_style_context_get_font (gtk_widget_get_style_context (widget), + gtk_widget_get_state_flags (widget)); + + return pango_font_description_get_size (font) / PANGO_SCALE; +} + /* Custom function to draw rounded rectangle with max radius */ static void custom_cairo_rounded_rectangle (cairo_t *cr, double x, double y, double w, double h) { - double radius = MIN (w/2.0, h/2.0); + double radius = h / 2.0; cairo_move_to (cr, x+radius, y); cairo_arc (cr, x+w-radius, y+radius, radius, M_PI*1.5, M_PI*2); @@ -514,7 +522,7 @@ numbers_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) GtkStyle *style; double x, y, w, h; PangoLayout * layout; - gint font_size = RIGHT_LABEL_FONT_SIZE; + gint font_size = gtk_widget_get_font_size (widget); if (!GTK_IS_WIDGET (widget)) return FALSE; @@ -535,12 +543,6 @@ numbers_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) layout = gtk_label_get_layout (GTK_LABEL(widget)); - /* This does not work, don't ask me why but font_size is 0. - * I wanted to use a dynamic font size to adjust the padding on left/right edges - * of the rounded rectangle. Andrea Cimitan */ - /* const PangoFontDescription * font_description = pango_layout_get_font_description (layout); - font_size = pango_font_description_get_size (font_description); */ - #if GTK_CHECK_VERSION(3, 0, 0) cairo_save (cr); #else @@ -691,7 +693,7 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new()); gint padding = 4; - gint font_size = RIGHT_LABEL_FONT_SIZE; + gint font_size = gtk_widget_get_font_size (GTK_WIDGET (gmi)); gtk_widget_style_get(GTK_WIDGET(gmi), "toggle-spacing", &padding, NULL); GtkWidget * hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, padding); -- cgit v1.2.3 From a9e89356835246b29f2ce06278e846eb8543b9db Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Sun, 22 Jan 2012 12:17:54 +0100 Subject: Center lozenge text vertically This ignores the label's padding and alignments, but they aren't used right now. --- src/indicator-messages.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index bb1d618..a39d7f1 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -522,6 +522,7 @@ numbers_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) GtkStyle *style; double x, y, w, h; PangoLayout * layout; + PangoRectangle layout_extents; gint font_size = gtk_widget_get_font_size (widget); if (!GTK_IS_WIDGET (widget)) return FALSE; @@ -542,6 +543,8 @@ numbers_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) h = allocation.height; layout = gtk_label_get_layout (GTK_LABEL(widget)); + pango_layout_get_extents (layout, NULL, &layout_extents); + pango_extents_to_pixels (&layout_extents, NULL); #if GTK_CHECK_VERSION(3, 0, 0) cairo_save (cr); @@ -562,6 +565,7 @@ numbers_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) style->fg[gtk_widget_get_state(widget)].green/65535.0, style->fg[gtk_widget_get_state(widget)].blue/65535.0, 0.5); + y += (allocation.height - layout_extents.height) / 2.0; cairo_move_to (cr, x, y); pango_cairo_layout_path (cr, layout); cairo_fill (cr); -- cgit v1.2.3 From c48bb0976c283da3dec6effe0ca5392b4facf7b3 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Sun, 22 Jan 2012 12:27:43 +0100 Subject: Pixel-align the lozenge text to make it less blurry --- src/Makefile.am | 2 +- src/indicator-messages.c | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index c631436..9da71ad 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -26,7 +26,7 @@ libmessaging_la_CFLAGS = \ -Wl,--as-needed \ -Werror \ -DG_LOG_DOMAIN=\"Indicator-Messages\" -libmessaging_la_LIBADD = $(APPLET_LIBS) +libmessaging_la_LIBADD = $(APPLET_LIBS) -lm libmessaging_la_LDFLAGS = -module -avoid-version ###################################### diff --git a/src/indicator-messages.c b/src/indicator-messages.c index a39d7f1..4a2ee29 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -23,6 +23,7 @@ with this program. If not, see . #include "config.h" #include +#include #include #include #include @@ -51,8 +52,6 @@ with this program. If not, see . #define IS_INDICATOR_MESSAGES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), INDICATOR_MESSAGES_TYPE)) #define INDICATOR_MESSAGES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), INDICATOR_MESSAGES_TYPE, IndicatorMessagesClass)) -#define M_PI 3.1415926535897932384626433832795028841971693993751 - typedef struct _IndicatorMessages IndicatorMessages; typedef struct _IndicatorMessagesClass IndicatorMessagesClass; @@ -566,7 +565,7 @@ numbers_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) style->fg[gtk_widget_get_state(widget)].blue/65535.0, 0.5); y += (allocation.height - layout_extents.height) / 2.0; - cairo_move_to (cr, x, y); + cairo_move_to (cr, round (x), round (y)); pango_cairo_layout_path (cr, layout); cairo_fill (cr); -- cgit v1.2.3 From 8e506f98d42c0dd0b964b2608f8edc30ea4dcdc0 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Sun, 22 Jan 2012 18:10:04 +0100 Subject: Align status icons with app icons This breaks down for sources which don't advertise themselves as an "indicator-item" (e.g. Thunderbird's "Compose New Message" and "Contacts"), because they keep being indented like a normal menu item. --- src/indicator-messages.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 4a2ee29..840deec 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -586,29 +586,24 @@ new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbu { g_debug ("%s (\"%s\")", __func__, dbusmenu_menuitem_property_get(newitem, APPLICATION_MENUITEM_PROP_NAME)); - GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_image_menu_item_new()); - gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(gmi), TRUE); + GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new()); - /* Set the minimum size, we always want it to take space */ - gint width, height; - gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); + gint padding = 4; + gtk_widget_style_get(GTK_WIDGET(gmi), "toggle-spacing", &padding, NULL); + + GtkWidget * hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, padding); GtkWidget * icon = gtk_image_new_from_icon_name(dbusmenu_menuitem_property_get(newitem, APPLICATION_MENUITEM_PROP_ICON), GTK_ICON_SIZE_MENU); - gtk_widget_set_size_request(icon, width - + 5 /* ref triangle is 5x9 pixels */ - + 2 /* padding */, - height); gtk_misc_set_alignment(GTK_MISC(icon), 1.0 /* right aligned */, 0.5); - gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(gmi), icon); - gtk_widget_show(icon); + gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0); /* Application name in a label */ GtkWidget * label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, APPLICATION_MENUITEM_PROP_NAME)); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - gtk_widget_show(label); + gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0); - /* Insert the hbox */ - gtk_container_add(GTK_CONTAINER(gmi), label); + gtk_container_add(GTK_CONTAINER(gmi), hbox); + gtk_widget_show_all (GTK_WIDGET (gmi)); /* Attach some of the standard GTK stuff */ dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); @@ -707,7 +702,9 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm /* Set the minimum size, we always want it to take space */ gint width, height; gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); - gtk_widget_set_size_request(mi_data->icon, width, height); + gtk_widget_set_size_request(GTK_WIDGET (gmi), -1, height + 4); + + gtk_widget_set_margin_left (hbox, width + padding); GdkPixbuf * pixbuf = dbusmenu_menuitem_property_get_image(newitem, INDICATOR_MENUITEM_PROP_ICON); if (pixbuf != NULL) { -- cgit v1.2.3 From b8d31fd4b64dc18c499702cc412565e3e195f4c2 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Fri, 3 Feb 2012 17:20:14 +0100 Subject: Switch to new dbusmenu includes --- src/indicator-messages.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 840deec..23d4d70 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -29,13 +29,8 @@ with this program. If not, see . #include #include -#if GTK_CHECK_VERSION(3, 0, 0) -#include -#include -#else #include #include -#endif #include #include -- cgit v1.2.3 From 85a365b27c845389d6b9540c296fc5edef4ad648 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Fri, 3 Feb 2012 18:19:19 +0100 Subject: Make minimum width of lozenge that of two characters --- src/indicator-messages.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 23d4d70..66d7276 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -559,6 +559,7 @@ numbers_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) style->fg[gtk_widget_get_state(widget)].green/65535.0, style->fg[gtk_widget_get_state(widget)].blue/65535.0, 0.5); + x += (allocation.width - layout_extents.width) / 2.0; y += (allocation.height - layout_extents.height) / 2.0; cairo_move_to (cr, round (x), round (y)); pango_cairo_layout_path (cr, layout); @@ -750,6 +751,7 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm gtk_misc_set_alignment(GTK_MISC(mi_data->right), 1.0, 0.5); gtk_box_pack_start(GTK_BOX(hbox), mi_data->right, FALSE, FALSE, padding + font_size/2.0); + gtk_label_set_width_chars (GTK_LABEL (mi_data->right), 2); gtk_widget_show(mi_data->right); gtk_container_add(GTK_CONTAINER(gmi), hbox); -- cgit v1.2.3 From 7595847dcd7e6e7f69a61031d1e3dfbe16f7baac Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Fri, 3 Feb 2012 18:24:15 +0100 Subject: Don't draw empty lozenges --- src/indicator-messages.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 66d7276..34152ac 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -540,6 +540,9 @@ numbers_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) pango_layout_get_extents (layout, NULL, &layout_extents); pango_extents_to_pixels (&layout_extents, NULL); + if (layout_extents.width == 0) + return TRUE; + #if GTK_CHECK_VERSION(3, 0, 0) cairo_save (cr); #else -- cgit v1.2.3 From 54b82d7275a9c37a815c7ed7840798c6492e9b81 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Fri, 3 Feb 2012 19:43:39 +0100 Subject: Only draw right items as lozenges if they contain a count --- src/dbus-data.h | 9 +++++---- src/im-menu-item.c | 6 ++++++ src/indicator-messages.c | 13 +++++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/dbus-data.h b/src/dbus-data.h index abff3aa..fac732e 100644 --- a/src/dbus-data.h +++ b/src/dbus-data.h @@ -13,10 +13,11 @@ #define APPLICATION_MENUITEM_PROP_ICON "icon-name" #define APPLICATION_MENUITEM_PROP_RUNNING "app-running" -#define INDICATOR_MENUITEM_TYPE "indicator-item" -#define INDICATOR_MENUITEM_PROP_LABEL "indicator-label" -#define INDICATOR_MENUITEM_PROP_ICON "indicator-icon" -#define INDICATOR_MENUITEM_PROP_RIGHT "right-side-text" +#define INDICATOR_MENUITEM_TYPE "indicator-item" +#define INDICATOR_MENUITEM_PROP_LABEL "indicator-label" +#define INDICATOR_MENUITEM_PROP_ICON "indicator-icon" +#define INDICATOR_MENUITEM_PROP_RIGHT "right-side-text" +#define INDICATOR_MENUITEM_PROP_RIGHT_IS_LOZENGE "right-is-lozenge" #define MAX_NUMBER_OF_INDICATORS 7 diff --git a/src/im-menu-item.c b/src/im-menu-item.c index 25fea52..e7c0177 100644 --- a/src/im-menu-item.c +++ b/src/im-menu-item.c @@ -340,6 +340,9 @@ count_cb (IndicateListener * listener, IndicateListenerServer * server, Indicate g_free(priv->count); priv->count = NULL; update_time(self); + dbusmenu_menuitem_property_set_bool (DBUSMENU_MENUITEM (self), + INDICATOR_MENUITEM_PROP_RIGHT_IS_LOZENGE, + FALSE); } return; } @@ -350,6 +353,9 @@ count_cb (IndicateListener * listener, IndicateListenerServer * server, Indicate priv->count = g_strdup_printf("%s", propertydata); dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), INDICATOR_MENUITEM_PROP_RIGHT, priv->count); + dbusmenu_menuitem_property_set_bool (DBUSMENU_MENUITEM (self), + INDICATOR_MENUITEM_PROP_RIGHT_IS_LOZENGE, + TRUE); return; } diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 34152ac..3059e1f 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -518,9 +518,14 @@ numbers_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) PangoLayout * layout; PangoRectangle layout_extents; gint font_size = gtk_widget_get_font_size (widget); + gboolean is_lozenge = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "is-lozenge")); if (!GTK_IS_WIDGET (widget)) return FALSE; + /* let the label handle the drawing if it's not a lozenge */ + if (!is_lozenge) + return FALSE; + /* get style */ style = gtk_widget_get_style (widget); @@ -637,6 +642,9 @@ indicator_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GVariant * value, } else if (!g_strcmp0(prop, INDICATOR_MENUITEM_PROP_RIGHT)) { /* Set the right label */ gtk_label_set_text(GTK_LABEL(mi_data->right), g_variant_get_string(value, NULL)); + } else if (!g_strcmp0(prop, INDICATOR_MENUITEM_PROP_RIGHT_IS_LOZENGE)) { + g_object_set_data (G_OBJECT (mi_data->right), "is-lozenge", GINT_TO_POINTER (TRUE)); + gtk_widget_queue_draw (mi_data->right); } else if (!g_strcmp0(prop, INDICATOR_MENUITEM_PROP_ICON)) { /* We don't use the value here, which is probably less efficient, but it's easier to use the easy function. And since th value @@ -743,6 +751,9 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm /* Usually either the time or the count on the individual item. */ mi_data->right = gtk_label_new(dbusmenu_menuitem_property_get(newitem, INDICATOR_MENUITEM_PROP_RIGHT)); + g_object_set_data (G_OBJECT (mi_data->right), + "is-lozenge", + GINT_TO_POINTER (dbusmenu_menuitem_property_get_bool (newitem, INDICATOR_MENUITEM_PROP_RIGHT_IS_LOZENGE))); /* install extra decoration overlay */ #if GTK_CHECK_VERSION(3, 0, 0) g_signal_connect (G_OBJECT (mi_data->right), "draw", @@ -755,6 +766,8 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm gtk_misc_set_alignment(GTK_MISC(mi_data->right), 1.0, 0.5); gtk_box_pack_start(GTK_BOX(hbox), mi_data->right, FALSE, FALSE, padding + font_size/2.0); gtk_label_set_width_chars (GTK_LABEL (mi_data->right), 2); + gtk_style_context_add_class (gtk_widget_get_style_context (mi_data->right), + "accelerator"); gtk_widget_show(mi_data->right); gtk_container_add(GTK_CONTAINER(gmi), hbox); -- cgit v1.2.3 From 981c01a3442a6a0a459ac313e29486b67aa1aac7 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Fri, 10 Feb 2012 08:38:52 +0100 Subject: Fix left margin of indicator items --- src/indicator-messages.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 3059e1f..f5f2fe0 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -711,7 +711,7 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); gtk_widget_set_size_request(GTK_WIDGET (gmi), -1, height + 4); - gtk_widget_set_margin_left (hbox, width + padding); + gtk_widget_set_margin_left (hbox, width + 2 * padding); GdkPixbuf * pixbuf = dbusmenu_menuitem_property_get_image(newitem, INDICATOR_MENUITEM_PROP_ICON); if (pixbuf != NULL) { -- cgit v1.2.3 From 60e7fb308d2607b7d547917a7efc5e1165333c11 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Fri, 10 Feb 2012 17:46:41 +0100 Subject: Use floor instead of round for lozenge position, better err on them being too large --- src/indicator-messages.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 197d55a..c22419d 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -569,7 +569,7 @@ numbers_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) x += (allocation.width - layout_extents.width) / 2.0; y += (allocation.height - layout_extents.height) / 2.0; - cairo_move_to (cr, round (x), round (y)); + cairo_move_to (cr, floor (x), floor (y)); pango_cairo_layout_path (cr, layout); cairo_fill (cr); -- cgit v1.2.3 From fea93b0417486ba0b660c9d4d160013778e39f11 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 10 Feb 2012 15:42:43 -0600 Subject: Removing some GTK3 code, won't look as nice on GTK2, but eh --- src/indicator-messages.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index c22419d..cf81f40 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -479,12 +479,16 @@ application_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer static gint gtk_widget_get_font_size (GtkWidget *widget) { +#if GTK_CHECK_VERSION(3, 0, 0) const PangoFontDescription *font; font = gtk_style_context_get_font (gtk_widget_get_style_context (widget), gtk_widget_get_state_flags (widget)); return pango_font_description_get_size (font) / PANGO_SCALE; +#else + return 12; +#endif } /* Custom function to draw rounded rectangle with max radius */ @@ -595,7 +599,11 @@ new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbu gint padding = 4; gtk_widget_style_get(GTK_WIDGET(gmi), "toggle-spacing", &padding, NULL); +#if GTK_CHECK_VERSION(3, 0, 0) GtkWidget * hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, padding); +#else + GtkWidget * hbox = gtk_hbox_new(FALSE, padding); +#endif GtkWidget * icon = gtk_image_new_from_icon_name(dbusmenu_menuitem_property_get(newitem, APPLICATION_MENUITEM_PROP_ICON), GTK_ICON_SIZE_MENU); gtk_misc_set_alignment(GTK_MISC(icon), 1.0 /* right aligned */, 0.5); @@ -715,7 +723,9 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); gtk_widget_set_size_request(GTK_WIDGET (gmi), -1, height + 4); +#if GTK_CHECK_VERSION(3, 0, 0) gtk_widget_set_margin_left (hbox, width + 2 * padding); +#endif GdkPixbuf * pixbuf = dbusmenu_menuitem_property_get_image(newitem, INDICATOR_MENUITEM_PROP_ICON); if (pixbuf != NULL) { @@ -770,8 +780,10 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm gtk_misc_set_alignment(GTK_MISC(mi_data->right), 1.0, 0.5); gtk_box_pack_start(GTK_BOX(hbox), mi_data->right, FALSE, FALSE, padding + font_size/2.0); gtk_label_set_width_chars (GTK_LABEL (mi_data->right), 2); +#if GTK_CHECK_VERSION(3, 0, 0) gtk_style_context_add_class (gtk_widget_get_style_context (mi_data->right), "accelerator"); +#endif gtk_widget_show(mi_data->right); gtk_container_add(GTK_CONTAINER(gmi), hbox); -- cgit v1.2.3