From e6fc3937fd425dfed550884bf9852e16f1cb7401 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 19 Aug 2010 18:20:27 +0100 Subject: set position works without a jumping slider, correct button press behaviour of the title and metadata menuitems clipboard functionality in place --- src/title-widget.c | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) (limited to 'src/title-widget.c') diff --git a/src/title-widget.c b/src/title-widget.c index 8037eb7..7e73f7e 100644 --- a/src/title-widget.c +++ b/src/title-widget.c @@ -49,10 +49,6 @@ static void title_widget_finalize (GObject *object); // keyevent consumers static gboolean title_widget_button_press_event (GtkWidget *menuitem, GdkEventButton *event); -static gboolean title_widget_button_release_event (GtkWidget *menuitem, - GdkEventButton *event); -static gboolean title_widget_expose_event(GtkWidget* widget, - GdkEventExpose* event); // Dbusmenuitem properties update callback static void title_widget_property_update(DbusmenuMenuitem* item, gchar* property, @@ -72,8 +68,6 @@ title_widget_class_init (TitleWidgetClass *klass) GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); widget_class->button_press_event = title_widget_button_press_event; - widget_class->button_release_event = title_widget_button_release_event; - widget_class->expose_event = title_widget_expose_event; g_type_class_add_private (klass, sizeof (TitleWidgetPrivate)); @@ -124,24 +118,7 @@ title_widget_button_press_event (GtkWidget *menuitem, g_value_set_boolean(&value, TRUE); dbusmenu_menuitem_handle_event (priv->twin_item, "Title menu event", &value, 0); - return TRUE; -} - -static gboolean -title_widget_button_release_event (GtkWidget *menuitem, - GdkEventButton *event) -{ - g_debug("TitleWidget::menu_release_event"); - return TRUE; -} - -static gboolean -title_widget_expose_event(GtkWidget* widget, GdkEventExpose* event) -{ - TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(widget); - - gtk_container_propagate_expose(GTK_CONTAINER(widget), priv->hbox, event); - return TRUE; + return FALSE; } static void -- cgit v1.2.3 From 0cfad99ce347f365d52783a2f3543b25acc94706 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 25 Aug 2010 15:18:45 +0100 Subject: fonts sorted --- src/title-widget.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/title-widget.c') diff --git a/src/title-widget.c b/src/title-widget.c index 7e73f7e..b5ed3c0 100644 --- a/src/title-widget.c +++ b/src/title-widget.c @@ -160,12 +160,12 @@ title_widget_style_name_text(TitleWidget* self) TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(self); char* markup; - markup = g_markup_printf_escaped ("%s", + markup = g_markup_printf_escaped ("%s", gtk_label_get_text(GTK_LABEL(priv->name))); gtk_label_set_markup (GTK_LABEL (priv->name), markup); g_free(markup); } - + /** * transport_new: * @returns: a new #TitleWidget. -- cgit v1.2.3 From 254525b58e75739e8739cc1e13681a38b4beb615 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 25 Aug 2010 18:15:56 +0100 Subject: more tweaks --- src/title-widget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/title-widget.c') diff --git a/src/title-widget.c b/src/title-widget.c index b5ed3c0..e9f34d6 100644 --- a/src/title-widget.c +++ b/src/title-widget.c @@ -160,7 +160,7 @@ title_widget_style_name_text(TitleWidget* self) TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(self); char* markup; - markup = g_markup_printf_escaped ("%s", + markup = g_markup_printf_escaped ("%s", gtk_label_get_text(GTK_LABEL(priv->name))); gtk_label_set_markup (GTK_LABEL (priv->name), markup); g_free(markup); -- cgit v1.2.3 From 262ef2532f8aa20018a750307f3d4815933e3c47 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 1 Sep 2010 00:31:55 +0100 Subject: first legit attempt at icon gutter placement failed --- src/title-widget.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/title-widget.c') diff --git a/src/title-widget.c b/src/title-widget.c index e9f34d6..8f0c3c5 100644 --- a/src/title-widget.c +++ b/src/title-widget.c @@ -35,6 +35,7 @@ struct _TitleWidgetPrivate GtkWidget* hbox; GtkWidget* name; GtkWidget* player_icon; + GtkWidget* image_item; DbusmenuMenuitem* twin_item; }; @@ -73,7 +74,6 @@ title_widget_class_init (TitleWidgetClass *klass) gobject_class->dispose = title_widget_dispose; gobject_class->finalize = title_widget_finalize; - } static void @@ -84,12 +84,12 @@ title_widget_init (TitleWidget *self) TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(self); GtkWidget *hbox; - + hbox = gtk_hbox_new(FALSE, 0); priv->hbox = hbox; - priv->player_icon = indicator_image_helper("sound_icon"); - gtk_box_pack_start(GTK_BOX (priv->hbox), priv->player_icon, FALSE, FALSE, 0); + + //gtk_box_pack_start(GTK_BOX (priv->hbox), priv->image_item, FALSE, FALSE, 0); } static void @@ -165,7 +165,13 @@ title_widget_style_name_text(TitleWidget* self) gtk_label_set_markup (GTK_LABEL (priv->name), markup); g_free(markup); } - + +GtkWidget* title_widget_get_player_icon(TitleWidget* self) +{ + TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(self); + return priv->player_icon; +} + /** * transport_new: * @returns: a new #TitleWidget. -- cgit v1.2.3 From 0c040b86cd7a05c8284662bb3032dccbf6707e90 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 2 Sep 2010 15:42:54 +0100 Subject: added the image as advised, still no showA --- src/title-widget.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'src/title-widget.c') diff --git a/src/title-widget.c b/src/title-widget.c index 8f0c3c5..0a59cca 100644 --- a/src/title-widget.c +++ b/src/title-widget.c @@ -58,7 +58,7 @@ static void title_widget_set_twin_item( TitleWidget* self, DbusmenuMenuitem* twin_item); static void title_widget_style_name_text(TitleWidget* self); -G_DEFINE_TYPE (TitleWidget, title_widget, GTK_TYPE_MENU_ITEM); +G_DEFINE_TYPE (TitleWidget, title_widget, GTK_TYPE_IMAGE_MENU_ITEM); @@ -87,8 +87,31 @@ title_widget_init (TitleWidget *self) hbox = gtk_hbox_new(FALSE, 0); priv->hbox = hbox; - priv->player_icon = indicator_image_helper("sound_icon"); + // Add image to the 'gutter' + gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(self), TRUE); + + gint padding = 4; + gtk_widget_style_get(GTK_WIDGET(self), "horizontal-padding", &padding, NULL); + + gint width, height; + gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); + + //priv->player_icon = indicator_image_helper("sound_icon"); + GtkWidget * icon = gtk_image_new_from_icon_name("sound_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(self), icon); + gtk_widget_show(icon); + + GtkImageType type = gtk_image_get_storage_type(GTK_IMAGE(icon)); + g_debug("gtk_image_storage_type = %i", type); + + //gtk_container_add(GTK_CONTAINER(gmi), priv->hbox); //gtk_box_pack_start(GTK_BOX (priv->hbox), priv->image_item, FALSE, FALSE, 0); } @@ -143,15 +166,16 @@ title_widget_set_twin_item(TitleWidget* self, priv->twin_item = twin_item; g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(title_widget_property_update), self); + // Add the application name priv->name = gtk_label_new(dbusmenu_menuitem_property_get(priv->twin_item, DBUSMENU_TITLE_MENUITEM_NAME)); - gtk_misc_set_padding(GTK_MISC(priv->name), 10, 0); + gtk_misc_set_padding(GTK_MISC(priv->name), 0, 0); gtk_box_pack_start (GTK_BOX (priv->hbox), priv->name, FALSE, FALSE, 0); title_widget_style_name_text(self); - gtk_widget_show_all (priv->hbox); - gtk_container_add (GTK_CONTAINER (self), priv->hbox); + gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET(priv->hbox)); + gtk_widget_show_all (priv->hbox); } static void -- cgit v1.2.3 From 966137c8c0547f1c749fa7b13955c6f536539129 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 2 Sep 2010 16:31:30 +0100 Subject: tidy up --- src/title-widget.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'src/title-widget.c') diff --git a/src/title-widget.c b/src/title-widget.c index 0a59cca..04471c0 100644 --- a/src/title-widget.c +++ b/src/title-widget.c @@ -34,7 +34,6 @@ struct _TitleWidgetPrivate { GtkWidget* hbox; GtkWidget* name; - GtkWidget* player_icon; GtkWidget* image_item; DbusmenuMenuitem* twin_item; }; @@ -88,7 +87,7 @@ title_widget_init (TitleWidget *self) hbox = gtk_hbox_new(FALSE, 0); priv->hbox = hbox; - // Add image to the 'gutter' + // Add image to the 'gutter' gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(self), TRUE); gint padding = 4; @@ -97,7 +96,6 @@ title_widget_init (TitleWidget *self) gint width, height; gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); - //priv->player_icon = indicator_image_helper("sound_icon"); GtkWidget * icon = gtk_image_new_from_icon_name("sound_icon", GTK_ICON_SIZE_MENU); gtk_widget_set_size_request(icon, width @@ -107,12 +105,11 @@ title_widget_init (TitleWidget *self) gtk_misc_set_alignment(GTK_MISC(icon), 1.0 /* right aligned */, 0.5); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(self), icon); gtk_widget_show(icon); - + gtk_widget_show(GTK_WIDGET(self)); + GtkImageType type = gtk_image_get_storage_type(GTK_IMAGE(icon)); g_debug("gtk_image_storage_type = %i", type); - //gtk_container_add(GTK_CONTAINER(gmi), priv->hbox); - //gtk_box_pack_start(GTK_BOX (priv->hbox), priv->image_item, FALSE, FALSE, 0); } static void @@ -190,12 +187,6 @@ title_widget_style_name_text(TitleWidget* self) g_free(markup); } -GtkWidget* title_widget_get_player_icon(TitleWidget* self) -{ - TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(self); - return priv->player_icon; -} - /** * transport_new: * @returns: a new #TitleWidget. -- cgit v1.2.3 From 0125f59bd6229cc8c98314b86795814ca5df6c42 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 2 Sep 2010 18:04:41 +0100 Subject: active triangle now in place --- src/title-widget.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) (limited to 'src/title-widget.c') diff --git a/src/title-widget.c b/src/title-widget.c index 04471c0..4b77cb2 100644 --- a/src/title-widget.c +++ b/src/title-widget.c @@ -57,6 +57,10 @@ static void title_widget_set_twin_item( TitleWidget* self, DbusmenuMenuitem* twin_item); static void title_widget_style_name_text(TitleWidget* self); +static gboolean title_widget_triangle_draw_cb (GtkWidget *widget, + GdkEventExpose *event, + gpointer data); + G_DEFINE_TYPE (TitleWidget, title_widget, GTK_TYPE_IMAGE_MENU_ITEM); @@ -104,9 +108,9 @@ title_widget_init (TitleWidget *self) height); gtk_misc_set_alignment(GTK_MISC(icon), 1.0 /* right aligned */, 0.5); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(self), icon); - gtk_widget_show(icon); - gtk_widget_show(GTK_WIDGET(self)); + gtk_widget_show_all(icon); + // DEBUG GtkImageType type = gtk_image_get_storage_type(GTK_IMAGE(icon)); g_debug("gtk_image_storage_type = %i", type); @@ -163,6 +167,9 @@ title_widget_set_twin_item(TitleWidget* self, priv->twin_item = twin_item; g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(title_widget_property_update), self); + g_signal_connect_after(G_OBJECT (self), + "expose_event", G_CALLBACK (title_widget_triangle_draw_cb), twin_item); + // Add the application name priv->name = gtk_label_new(dbusmenu_menuitem_property_get(priv->twin_item, DBUSMENU_TITLE_MENUITEM_NAME)); @@ -187,6 +194,53 @@ title_widget_style_name_text(TitleWidget* self) g_free(markup); } +static gboolean +title_widget_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) +{ + GtkStyle *style; + cairo_t *cr; + int x, y, arrow_width, arrow_height; + + if (!GTK_IS_WIDGET (widget)) return FALSE; + if (!DBUSMENU_IS_MENUITEM (data)) return FALSE; + + /* render the triangle indicator only if the application is running */ + if (! dbusmenu_menuitem_property_get_bool (DBUSMENU_MENUITEM(data), + DBUSMENU_TITLE_MENUITEM_RUNNING)){ + return FALSE; + } + + /* get style */ + style = gtk_widget_get_style (widget); + + /* set arrow position / dimensions */ + arrow_width = 5; /* the pixel-based reference triangle is 5x9 */ + arrow_height = 9; + x = widget->allocation.x; + y = widget->allocation.y + widget->allocation.height/2.0 - (double)arrow_height/2.0; + + /* initialize cairo drawing area */ + cr = (cairo_t*) gdk_cairo_create (widget->window); + + /* set line width */ + cairo_set_line_width (cr, 1.0); + + /* cairo drawing code */ + cairo_move_to (cr, x, y); + cairo_line_to (cr, x, y + arrow_height); + cairo_line_to (cr, x + arrow_width, y + (double)arrow_height/2.0); + cairo_close_path (cr); + cairo_set_source_rgb (cr, style->fg[gtk_widget_get_state(widget)].red/65535.0, + style->fg[gtk_widget_get_state(widget)].green/65535.0, + style->fg[gtk_widget_get_state(widget)].blue/65535.0); + cairo_fill (cr); + + /* remember to destroy cairo context to avoid leaks */ + cairo_destroy (cr); + + return FALSE; +} + /** * transport_new: * @returns: a new #TitleWidget. -- cgit v1.2.3 From 41b5b22e56892b7246f5bcfc270d685f052c0f70 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 6 Sep 2010 13:19:53 +0100 Subject: tried everything, the image will not show on the menu --- src/title-widget.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'src/title-widget.c') diff --git a/src/title-widget.c b/src/title-widget.c index 4b77cb2..d34dc7f 100644 --- a/src/title-widget.c +++ b/src/title-widget.c @@ -92,28 +92,54 @@ title_widget_init (TitleWidget *self) priv->hbox = hbox; // Add image to the 'gutter' - gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(self), TRUE); - + gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(self), TRUE); + gtk_image_menu_item_set_use_stock(GTK_IMAGE_MENU_ITEM(self), FALSE); + gint padding = 4; gtk_widget_style_get(GTK_WIDGET(self), "horizontal-padding", &padding, NULL); gint width, height; gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); + g_debug("title widget init - height and weight = %i and %i", height, width); + + GtkImage * image = indicator_image_helper("sound_icon"); + GdkPixbuf* buf = gtk_image_get_pixbuf (image); + g_debug("Is it a pixbuf : %i", GDK_IS_PIXBUF(buf)); GtkWidget * icon = gtk_image_new_from_icon_name("sound_icon", GTK_ICON_SIZE_MENU); + + g_debug("title widget init - icon pixel size = %i", gtk_image_get_pixel_size (GTK_IMAGE(icon))); + g_debug("title widget init - image pixel size = %i", gtk_image_get_pixel_size (image)); 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(self), icon); + gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(self), GTK_WIDGET(image)); + gtk_widget_show_all(icon); + GtkWidget* returned_image = gtk_image_menu_item_get_image(GTK_IMAGE_MENU_ITEM(self)); + g_debug("returned image is not null %i", GTK_IS_IMAGE(returned_image)); // DEBUG - GtkImageType type = gtk_image_get_storage_type(GTK_IMAGE(icon)); - g_debug("gtk_image_storage_type = %i", type); + GtkImageType type; + type = gtk_image_get_storage_type(GTK_IMAGE(icon)); + g_debug("gtk_image_storage_type on widget = %i", type); + type = gtk_image_get_storage_type(image); + g_debug("gtk_image_storage_type on image = %i", type); + + gboolean* use_stock; + use_stock = g_new0(gboolean, 1); + gboolean* show_image; + show_image = g_new0(gboolean, 1); + + g_object_get(GTK_WIDGET(self), "use-stock", use_stock, NULL ); + g_object_get(GTK_WIDGET(self), "always-show-image", show_image, NULL); + g_debug("title widget init : use-stock = %i and show image = %i", *use_stock, *show_image); + g_free(use_stock); + g_free(show_image); } static void -- cgit v1.2.3 From 3461e88ae36e6237ad20b7e9c8069b364974fdd0 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 7 Sep 2010 19:01:38 +0100 Subject: alloc stuff --- src/title-widget.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/title-widget.c') diff --git a/src/title-widget.c b/src/title-widget.c index d34dc7f..0315a8e 100644 --- a/src/title-widget.c +++ b/src/title-widget.c @@ -110,13 +110,14 @@ title_widget_init (TitleWidget *self) g_debug("title widget init - icon pixel size = %i", gtk_image_get_pixel_size (GTK_IMAGE(icon))); g_debug("title widget init - image pixel size = %i", gtk_image_get_pixel_size (image)); - + 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(self), GTK_WIDGET(image)); + + gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(self), GTK_WIDGET(icon)); gtk_widget_show_all(icon); GtkWidget* returned_image = gtk_image_menu_item_get_image(GTK_IMAGE_MENU_ITEM(self)); @@ -136,6 +137,23 @@ title_widget_init (TitleWidget *self) g_object_get(GTK_WIDGET(self), "use-stock", use_stock, NULL ); g_object_get(GTK_WIDGET(self), "always-show-image", show_image, NULL); + + GtkAllocation new_alloc; + new_alloc.width = 16; + new_alloc.height = 16; + new_alloc.x = 16; + new_alloc.y = 16; + + gtk_widget_set_allocation(icon, &new_alloc); + + GtkAllocation alloc; + gtk_widget_get_allocation(icon, &alloc); + + g_debug("title widget init - alloc for icon: width : %i, height : %i, x : %i and y : %i", + alloc.width, + alloc.height, + alloc.x, + alloc.y); g_debug("title widget init : use-stock = %i and show image = %i", *use_stock, *show_image); g_free(use_stock); -- cgit v1.2.3 From 86423311e123d01b3528365b2010f25dc292625d Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 7 Sep 2010 19:16:24 +0100 Subject: tidied up debug statements --- src/title-widget.c | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) (limited to 'src/title-widget.c') diff --git a/src/title-widget.c b/src/title-widget.c index 0315a8e..fbcac0a 100644 --- a/src/title-widget.c +++ b/src/title-widget.c @@ -101,34 +101,46 @@ title_widget_init (TitleWidget *self) gint width, height; gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); - g_debug("title widget init - height and weight = %i and %i", height, width); - GtkImage * image = indicator_image_helper("sound_icon"); GdkPixbuf* buf = gtk_image_get_pixbuf (image); - g_debug("Is it a pixbuf : %i", GDK_IS_PIXBUF(buf)); - GtkWidget * icon = gtk_image_new_from_icon_name("sound_icon", GTK_ICON_SIZE_MENU); - - g_debug("title widget init - icon pixel size = %i", gtk_image_get_pixel_size (GTK_IMAGE(icon))); - g_debug("title widget init - image pixel size = %i", gtk_image_get_pixel_size (image)); - + + //GtkWidget * icon = gtk_image_new_from_icon_name("sound_icon", GTK_ICON_SIZE_MENU); + GtkWidget * icon = gtk_image_new_from_file("/usr/share/icons/ubuntu-mono-dark/status/16/sound_icon.png"); + + GtkAllocation new_alloc; + new_alloc.width = 16; + new_alloc.height = 16; + new_alloc.x = 16; + new_alloc.y = 16; + + gtk_widget_set_allocation(icon, &new_alloc); + 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(self), GTK_WIDGET(icon)); gtk_widget_show_all(icon); - GtkWidget* returned_image = gtk_image_menu_item_get_image(GTK_IMAGE_MENU_ITEM(self)); - g_debug("returned image is not null %i", GTK_IS_IMAGE(returned_image)); // DEBUG + g_debug("title widget init - Is there a pixbuf from image loaded with helper : %i", GDK_IS_PIXBUF(buf)); + + g_debug("title widget init - icon pixel size = %i", gtk_image_get_pixel_size (GTK_IMAGE(icon))); + g_debug("title widget init - image pixel size = %i", gtk_image_get_pixel_size (image)); + + g_debug("title widget init - height and weight = %i and %i", height, width); + GtkImageType type; type = gtk_image_get_storage_type(GTK_IMAGE(icon)); - g_debug("gtk_image_storage_type on widget = %i", type); + g_debug("title widget init - gtk_image_storage_type on widget = %i", type); type = gtk_image_get_storage_type(image); - g_debug("gtk_image_storage_type on image = %i", type); + g_debug("title widget init - gtk_image_storage_type on image = %i", type); + + GtkWidget* returned_image = gtk_image_menu_item_get_image(GTK_IMAGE_MENU_ITEM(self)); + g_debug("title widget init - returned image is not null %i", GTK_IS_IMAGE(returned_image)); gboolean* use_stock; use_stock = g_new0(gboolean, 1); @@ -137,14 +149,6 @@ title_widget_init (TitleWidget *self) g_object_get(GTK_WIDGET(self), "use-stock", use_stock, NULL ); g_object_get(GTK_WIDGET(self), "always-show-image", show_image, NULL); - - GtkAllocation new_alloc; - new_alloc.width = 16; - new_alloc.height = 16; - new_alloc.x = 16; - new_alloc.y = 16; - - gtk_widget_set_allocation(icon, &new_alloc); GtkAllocation alloc; gtk_widget_get_allocation(icon, &alloc); -- cgit v1.2.3 From 39680a792b250f478fcdd430c7c09a734ab35590 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 7 Sep 2010 21:00:08 +0100 Subject: removed unnecessary hbox and label and set the text directly on the menuitem --- src/title-widget.c | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) (limited to 'src/title-widget.c') diff --git a/src/title-widget.c b/src/title-widget.c index fbcac0a..245c14c 100644 --- a/src/title-widget.c +++ b/src/title-widget.c @@ -32,8 +32,8 @@ typedef struct _TitleWidgetPrivate TitleWidgetPrivate; struct _TitleWidgetPrivate { - GtkWidget* hbox; - GtkWidget* name; + //GtkWidget* hbox; + //GtkWidget* name; GtkWidget* image_item; DbusmenuMenuitem* twin_item; }; @@ -55,7 +55,7 @@ static void title_widget_property_update(DbusmenuMenuitem* item, gchar* property GValue* value, gpointer userdata); static void title_widget_set_twin_item( TitleWidget* self, DbusmenuMenuitem* twin_item); -static void title_widget_style_name_text(TitleWidget* self); +//static void title_widget_style_name_text(TitleWidget* self); static gboolean title_widget_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, @@ -86,10 +86,10 @@ title_widget_init (TitleWidget *self) TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(self); - GtkWidget *hbox; + //GtkWidget *hbox; - hbox = gtk_hbox_new(FALSE, 0); - priv->hbox = hbox; + //hbox = gtk_hbox_new(FALSE, 0); + //priv->hbox = hbox; // Add image to the 'gutter' gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(self), TRUE); @@ -123,7 +123,7 @@ title_widget_init (TitleWidget *self) gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(self), GTK_WIDGET(icon)); - gtk_widget_show_all(icon); + //gtk_widget_show_all(icon); // DEBUG g_debug("title widget init - Is there a pixbuf from image loaded with helper : %i", GDK_IS_PIXBUF(buf)); @@ -202,8 +202,10 @@ title_widget_property_update(DbusmenuMenuitem* item, gchar* property, TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(mitem); if(g_ascii_strcasecmp(DBUSMENU_TITLE_MENUITEM_NAME, property) == 0){ - gtk_label_set_text(GTK_LABEL(priv->name), g_value_get_string(value)); - title_widget_style_name_text(mitem); + gtk_menu_item_set_label (GTK_MENU_ITEM(mitem), + g_value_get_string(value)); + //gtk_label_set_text(GTK_LABEL(priv->name), g_value_get_string(value)); + //title_widget_style_name_text(mitem); } } @@ -219,18 +221,21 @@ title_widget_set_twin_item(TitleWidget* self, "expose_event", G_CALLBACK (title_widget_triangle_draw_cb), twin_item); // Add the application name - priv->name = gtk_label_new(dbusmenu_menuitem_property_get(priv->twin_item, - DBUSMENU_TITLE_MENUITEM_NAME)); - gtk_misc_set_padding(GTK_MISC(priv->name), 0, 0); - gtk_box_pack_start (GTK_BOX (priv->hbox), priv->name, FALSE, FALSE, 0); - - title_widget_style_name_text(self); - - gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET(priv->hbox)); - gtk_widget_show_all (priv->hbox); + //priv->name = gtk_label_new(dbusmenu_menuitem_property_get(priv->twin_item, + // DBUSMENU_TITLE_MENUITEM_NAME)); + //gtk_misc_set_padding(GTK_MISC(priv->name), 0, 0); + //gtk_box_pack_start (GTK_BOX (priv->hbox), priv->name, FALSE, FALSE, 0); + + //title_widget_style_name_text(self); + gtk_menu_item_set_label (GTK_MENU_ITEM(self), + dbusmenu_menuitem_property_get(priv->twin_item, + DBUSMENU_TITLE_MENUITEM_NAME)); + + //gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET(priv->hbox)); + gtk_widget_show_all (GTK_WIDGET(self)); } -static void +/*static void title_widget_style_name_text(TitleWidget* self) { TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(self); @@ -240,7 +245,7 @@ title_widget_style_name_text(TitleWidget* self) gtk_label_get_text(GTK_LABEL(priv->name))); gtk_label_set_markup (GTK_LABEL (priv->name), markup); g_free(markup); -} +}*/ static gboolean title_widget_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) -- cgit v1.2.3 From 7569d1ceb769afcd429eec614c3a0c0b9ca0a2c0 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 7 Sep 2010 21:03:57 +0100 Subject: removed unnecessary hbox and label and set the text directly on the menuitem --- src/title-widget.c | 37 +++---------------------------------- 1 file changed, 3 insertions(+), 34 deletions(-) (limited to 'src/title-widget.c') diff --git a/src/title-widget.c b/src/title-widget.c index 245c14c..1925b6d 100644 --- a/src/title-widget.c +++ b/src/title-widget.c @@ -32,8 +32,6 @@ typedef struct _TitleWidgetPrivate TitleWidgetPrivate; struct _TitleWidgetPrivate { - //GtkWidget* hbox; - //GtkWidget* name; GtkWidget* image_item; DbusmenuMenuitem* twin_item; }; @@ -55,8 +53,6 @@ static void title_widget_property_update(DbusmenuMenuitem* item, gchar* property GValue* value, gpointer userdata); static void title_widget_set_twin_item( TitleWidget* self, DbusmenuMenuitem* twin_item); -//static void title_widget_style_name_text(TitleWidget* self); - static gboolean title_widget_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data); @@ -86,10 +82,6 @@ title_widget_init (TitleWidget *self) TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(self); - //GtkWidget *hbox; - - //hbox = gtk_hbox_new(FALSE, 0); - //priv->hbox = hbox; // Add image to the 'gutter' gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(self), TRUE); @@ -123,7 +115,7 @@ title_widget_init (TitleWidget *self) gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(self), GTK_WIDGET(icon)); - //gtk_widget_show_all(icon); + gtk_widget_show_all(icon); // DEBUG g_debug("title widget init - Is there a pixbuf from image loaded with helper : %i", GDK_IS_PIXBUF(buf)); @@ -204,8 +196,6 @@ title_widget_property_update(DbusmenuMenuitem* item, gchar* property, if(g_ascii_strcasecmp(DBUSMENU_TITLE_MENUITEM_NAME, property) == 0){ gtk_menu_item_set_label (GTK_MENU_ITEM(mitem), g_value_get_string(value)); - //gtk_label_set_text(GTK_LABEL(priv->name), g_value_get_string(value)); - //title_widget_style_name_text(mitem); } } @@ -220,33 +210,12 @@ title_widget_set_twin_item(TitleWidget* self, g_signal_connect_after(G_OBJECT (self), "expose_event", G_CALLBACK (title_widget_triangle_draw_cb), twin_item); - // Add the application name - //priv->name = gtk_label_new(dbusmenu_menuitem_property_get(priv->twin_item, - // DBUSMENU_TITLE_MENUITEM_NAME)); - //gtk_misc_set_padding(GTK_MISC(priv->name), 0, 0); - //gtk_box_pack_start (GTK_BOX (priv->hbox), priv->name, FALSE, FALSE, 0); - - //title_widget_style_name_text(self); gtk_menu_item_set_label (GTK_MENU_ITEM(self), dbusmenu_menuitem_property_get(priv->twin_item, - DBUSMENU_TITLE_MENUITEM_NAME)); - - //gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET(priv->hbox)); - gtk_widget_show_all (GTK_WIDGET(self)); + DBUSMENU_TITLE_MENUITEM_NAME)); + //gtk_widget_show_all (GTK_WIDGET(self)); } -/*static void -title_widget_style_name_text(TitleWidget* self) -{ - TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(self); - - char* markup; - markup = g_markup_printf_escaped ("%s", - gtk_label_get_text(GTK_LABEL(priv->name))); - gtk_label_set_markup (GTK_LABEL (priv->name), markup); - g_free(markup); -}*/ - static gboolean title_widget_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) { -- cgit v1.2.3 From 9840130d7059edec3acd634d18f8f601c2afc28a Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 7 Sep 2010 21:04:47 +0100 Subject: removed unnecessary hbox and label and set the text directly on the menuitem --- src/title-widget.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/title-widget.c') diff --git a/src/title-widget.c b/src/title-widget.c index 1925b6d..1021c89 100644 --- a/src/title-widget.c +++ b/src/title-widget.c @@ -80,9 +80,6 @@ title_widget_init (TitleWidget *self) { g_debug("TitleWidget::title_widget_init"); - TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(self); - - // Add image to the 'gutter' gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(self), TRUE); gtk_image_menu_item_set_use_stock(GTK_IMAGE_MENU_ITEM(self), FALSE); @@ -191,7 +188,6 @@ title_widget_property_update(DbusmenuMenuitem* item, gchar* property, { g_return_if_fail (IS_TITLE_WIDGET (userdata)); TitleWidget* mitem = TITLE_WIDGET(userdata); - TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(mitem); if(g_ascii_strcasecmp(DBUSMENU_TITLE_MENUITEM_NAME, property) == 0){ gtk_menu_item_set_label (GTK_MENU_ITEM(mitem), -- cgit v1.2.3 From 1f038d6725571f8e80530a96112d427d5b051022 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 8 Sep 2010 15:51:52 +0100 Subject: title widget now shows the icon in the right place, play button have been alter accordingly --- src/title-widget.c | 117 ++++++++++++++++------------------------------------- 1 file changed, 35 insertions(+), 82 deletions(-) (limited to 'src/title-widget.c') diff --git a/src/title-widget.c b/src/title-widget.c index 1021c89..1146818 100644 --- a/src/title-widget.c +++ b/src/title-widget.c @@ -32,8 +32,7 @@ typedef struct _TitleWidgetPrivate TitleWidgetPrivate; struct _TitleWidgetPrivate { - GtkWidget* image_item; - DbusmenuMenuitem* twin_item; + DbusmenuMenuitem* twin_item; }; #define TITLE_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TITLE_WIDGET_TYPE, TitleWidgetPrivate)) @@ -52,7 +51,7 @@ static gboolean title_widget_button_press_event (GtkWidget *menuitem, static void title_widget_property_update(DbusmenuMenuitem* item, gchar* property, GValue* value, gpointer userdata); static void title_widget_set_twin_item( TitleWidget* self, - DbusmenuMenuitem* twin_item); + DbusmenuMenuitem* twin_item); static gboolean title_widget_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data); @@ -80,77 +79,22 @@ title_widget_init (TitleWidget *self) { g_debug("TitleWidget::title_widget_init"); - // Add image to the 'gutter' - gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(self), TRUE); - gtk_image_menu_item_set_use_stock(GTK_IMAGE_MENU_ITEM(self), FALSE); - - gint padding = 4; + gint padding = 0; gtk_widget_style_get(GTK_WIDGET(self), "horizontal-padding", &padding, NULL); gint width, height; gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); - GtkImage * image = indicator_image_helper("sound_icon"); - GdkPixbuf* buf = gtk_image_get_pixbuf (image); - - //GtkWidget * icon = gtk_image_new_from_icon_name("sound_icon", GTK_ICON_SIZE_MENU); - GtkWidget * icon = gtk_image_new_from_file("/usr/share/icons/ubuntu-mono-dark/status/16/sound_icon.png"); - - GtkAllocation new_alloc; - new_alloc.width = 16; - new_alloc.height = 16; - new_alloc.x = 16; - new_alloc.y = 16; - - gtk_widget_set_allocation(icon, &new_alloc); - - 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(self), GTK_WIDGET(icon)); - - gtk_widget_show_all(icon); - - // DEBUG - g_debug("title widget init - Is there a pixbuf from image loaded with helper : %i", GDK_IS_PIXBUF(buf)); + GtkWidget * icon = gtk_image_new_from_icon_name("sound_icon", GTK_ICON_SIZE_MENU); - g_debug("title widget init - icon pixel size = %i", gtk_image_get_pixel_size (GTK_IMAGE(icon))); - g_debug("title widget init - image pixel size = %i", gtk_image_get_pixel_size (image)); + gtk_widget_set_size_request(icon, width + + 5 /* ref triangle is 5x9 pixels */ + + 1 /* padding */, + height); + gtk_misc_set_alignment(GTK_MISC(icon), 0.5 /* right aligned */, 0); + gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(self), GTK_WIDGET(icon)); + gtk_widget_show(icon); - g_debug("title widget init - height and weight = %i and %i", height, width); - - GtkImageType type; - type = gtk_image_get_storage_type(GTK_IMAGE(icon)); - g_debug("title widget init - gtk_image_storage_type on widget = %i", type); - type = gtk_image_get_storage_type(image); - g_debug("title widget init - gtk_image_storage_type on image = %i", type); - - GtkWidget* returned_image = gtk_image_menu_item_get_image(GTK_IMAGE_MENU_ITEM(self)); - g_debug("title widget init - returned image is not null %i", GTK_IS_IMAGE(returned_image)); - - gboolean* use_stock; - use_stock = g_new0(gboolean, 1); - gboolean* show_image; - show_image = g_new0(gboolean, 1); - - g_object_get(GTK_WIDGET(self), "use-stock", use_stock, NULL ); - g_object_get(GTK_WIDGET(self), "always-show-image", show_image, NULL); - - GtkAllocation alloc; - gtk_widget_get_allocation(icon, &alloc); - - g_debug("title widget init - alloc for icon: width : %i, height : %i, x : %i and y : %i", - alloc.width, - alloc.height, - alloc.x, - alloc.y); - - g_debug("title widget init : use-stock = %i and show image = %i", *use_stock, *show_image); - g_free(use_stock); - g_free(show_image); } static void @@ -188,10 +132,10 @@ title_widget_property_update(DbusmenuMenuitem* item, gchar* property, { g_return_if_fail (IS_TITLE_WIDGET (userdata)); TitleWidget* mitem = TITLE_WIDGET(userdata); - - if(g_ascii_strcasecmp(DBUSMENU_TITLE_MENUITEM_NAME, property) == 0){ - gtk_menu_item_set_label (GTK_MENU_ITEM(mitem), - g_value_get_string(value)); + + if(g_ascii_strcasecmp(DBUSMENU_TITLE_MENUITEM_NAME, property) == 0){ + gtk_menu_item_set_label (GTK_MENU_ITEM(mitem), + g_value_get_string(value)); } } @@ -199,17 +143,23 @@ static void title_widget_set_twin_item(TitleWidget* self, DbusmenuMenuitem* twin_item) { - TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(self); - priv->twin_item = twin_item; - g_signal_connect(G_OBJECT(twin_item), "property-changed", - G_CALLBACK(title_widget_property_update), self); - g_signal_connect_after(G_OBJECT (self), - "expose_event", G_CALLBACK (title_widget_triangle_draw_cb), twin_item); - - gtk_menu_item_set_label (GTK_MENU_ITEM(self), + TitleWidgetPrivate *priv = TITLE_WIDGET_GET_PRIVATE(self); + + priv->twin_item = twin_item; + + g_signal_connect (G_OBJECT (twin_item), + "property-changed", + G_CALLBACK (title_widget_property_update), + self); + g_signal_connect_after (G_OBJECT (self), + "expose_event", + G_CALLBACK (title_widget_triangle_draw_cb), + twin_item); + + gtk_menu_item_set_label (GTK_MENU_ITEM(self), dbusmenu_menuitem_property_get(priv->twin_item, - DBUSMENU_TITLE_MENUITEM_NAME)); - //gtk_widget_show_all (GTK_WIDGET(self)); + DBUSMENU_TITLE_MENUITEM_NAME)); + } static gboolean @@ -266,8 +216,11 @@ title_widget_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointe GtkWidget* title_widget_new(DbusmenuMenuitem *item) { - GtkWidget* widget = g_object_new(TITLE_WIDGET_TYPE, NULL); + GtkWidget* widget = g_object_new (TITLE_WIDGET_TYPE, + NULL); + gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (widget), TRUE); title_widget_set_twin_item((TitleWidget*)widget, item); + return widget; } -- cgit v1.2.3 From 198a4eed0247f8795a93aee73af73a55d2ab2d4a Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 13 Sep 2010 15:56:12 +0100 Subject: fixed autotools --- src/title-widget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/title-widget.c') diff --git a/src/title-widget.c b/src/title-widget.c index 1146818..bc1d453 100644 --- a/src/title-widget.c +++ b/src/title-widget.c @@ -85,7 +85,7 @@ title_widget_init (TitleWidget *self) gint width, height; gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); - GtkWidget * icon = gtk_image_new_from_icon_name("sound_icon", GTK_ICON_SIZE_MENU); + GtkWidget * icon = gtk_image_new_from_icon_name("sound-icon", GTK_ICON_SIZE_MENU); gtk_widget_set_size_request(icon, width + 5 /* ref triangle is 5x9 pixels */ -- cgit v1.2.3