From 33a5118a820f07d8017924af1e5fc68467787bf1 Mon Sep 17 00:00:00 2001
From: Conor Curran <conor.curran@canonical.com>
Date: Thu, 16 Jun 2011 10:52:41 +0200
Subject: rejigged the icon handling so as it should be drawn directly as
 opposed to be handled by gtkmenuitem

---
 src/metadata-widget.c | 49 +++++++++++++++++++++++++++++--------------------
 1 file changed, 29 insertions(+), 20 deletions(-)

(limited to 'src')

diff --git a/src/metadata-widget.c b/src/metadata-widget.c
index bc998fa..95814c8 100644
--- a/src/metadata-widget.c
+++ b/src/metadata-widget.c
@@ -44,6 +44,7 @@ struct _MetadataWidgetPrivate
   GtkWidget* piece_label;
   GtkWidget* container_label;
   GtkWidget* player_label;
+  GtkWidget* player_icon;
   DbusmenuMenuitem* twin_item;      
 };
 
@@ -109,7 +110,9 @@ metadata_widget_init (MetadataWidget *self)
   MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self);
   GtkWidget *hbox;
   GtkWidget *outer_v_box;
-
+  GtkWidget *top_h_box;
+  
+  top_h_box = gtk_hbox_new(FALSE, 0); 
   outer_v_box = gtk_vbox_new (FALSE, 0);
   hbox = gtk_hbox_new(FALSE, 0);
   
@@ -185,8 +188,26 @@ metadata_widget_init (MetadataWidget *self)
   gtk_misc_set_padding (GTK_MISC(player_label), (gfloat)0, (gfloat)0);  
   gtk_widget_set_size_request (player_label, 200, 25);
   priv->player_label = player_label;
+
+  gtk_box_pack_start (GTK_BOX (top_h_box), priv->player_label, FALSE, FALSE, 0);  
+  
+  // Player Icon
+  gint width, height;
+  gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, &height);
+  
+  GtkWidget* player_icon;
+  player_icon = gtk_image_new();
+  priv->player_icon = player_icon;
+  
+  gtk_widget_set_size_request(priv->player_icon, width
+                                    + 5 /* ref triangle is 5x9 pixels */
+                                    + 1 /* padding */,
+                                    height);
+                                    
+  //gtk_misc_set_alignment(GTK_MISC(priv->player_icon), 0.5 /* right aligned */, 0);
+  gtk_box_pack_start (GTK_BOX (top_h_box), priv->player_icon, FALSE, FALSE, 0);  
   
-  gtk_box_pack_start (GTK_BOX(outer_v_box), priv->player_label, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX(outer_v_box), top_h_box, FALSE, FALSE, 0);
   gtk_box_pack_start (GTK_BOX(outer_v_box), priv->meta_data_h_box, FALSE, FALSE, 0);
     
   gtk_container_add (GTK_CONTAINER (self), outer_v_box);  
@@ -381,7 +402,6 @@ draw_album_art_placeholder(GtkWidget *metadata)
 
   _color_shade ( &fg_normal, 0.78, &light_bottom_color );
   
-
   cairo_set_source_rgba (cr,
                          light_bottom_color.r, 
                          light_bottom_color.g,
@@ -396,7 +416,6 @@ draw_album_art_placeholder(GtkWidget *metadata)
   g_object_unref(pcontext);
   g_string_free (string, TRUE);
   cairo_destroy (cr); 
-
 }
 
 static void
@@ -520,14 +539,7 @@ metadata_widget_handle_resizing (MetadataWidget* self)
     gtk_widget_show (priv->container_label); 
     gtk_widget_show (priv->album_art); 
     gtk_widget_show (priv->meta_data_v_box); 
-
     gtk_widget_set_size_request(GTK_WIDGET(self), 200, 95);   
-    // This is not working!
-    gtk_misc_set_alignment (GTK_MISC(gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM(self))),
-                            0.5 /* right aligned */,
-                            0);
-    gtk_widget_show( GTK_WIDGET(gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM(self))));
-
   }
   gtk_widget_queue_draw(GTK_WIDGET(self));      
 }
@@ -560,11 +572,11 @@ metadata_widget_set_icon (MetadataWidget *self)
   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);
+  gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, &height);
   
   GString* banshee_string = g_string_new ( "banshee" );
-  GString* app_panel = g_string_new ( g_utf8_strdown ( dbusmenu_menuitem_property_get(priv->twin_item, DBUSMENU_METADATA_MENUITEM_PLAYER_NAME),
-                                                    -1 ));
+  GString* app_panel = g_string_new ( g_utf8_strdown (dbusmenu_menuitem_property_get(priv->twin_item, DBUSMENU_METADATA_MENUITEM_PLAYER_NAME),
+                                                     -1));
   GtkWidget * icon = NULL;
   
   // Not ideal but apparently we want the banshee icon to be the greyscale one
@@ -587,8 +599,8 @@ metadata_widget_set_icon (MetadataWidget *self)
                                     + 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);
+  priv->player_icon = icon;
+  gtk_widget_show(priv->player_icon);
 }
 
 static void
@@ -644,7 +656,7 @@ metadata_widget_triangle_draw_cb (GtkWidget *widget,
   g_return_val_if_fail(IS_METADATA_WIDGET(user_data), FALSE);
   MetadataWidget* meta = METADATA_WIDGET(user_data);
   MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(meta);  
-  
+   
   GtkStyle *style;
   cairo_t *cr;
   int x, y, arrow_width, arrow_height;
@@ -686,10 +698,7 @@ metadata_widget_triangle_draw_cb (GtkWidget *widget,
 GtkWidget* 
 metadata_widget_new(DbusmenuMenuitem *item)
 {
-
   GtkWidget* widget =  g_object_new(METADATA_WIDGET_TYPE, NULL);
-  gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (widget),
-                                             TRUE);
   metadata_widget_set_twin_item ( METADATA_WIDGET(widget),
                                   item );
   return widget;                  
-- 
cgit v1.2.3


From 34bbf1f8606d25235727753242686d78802b303a Mon Sep 17 00:00:00 2001
From: Conor Curran <conor.curran@canonical.com>
Date: Thu, 16 Jun 2011 14:32:55 +0200
Subject: went the cairo method for drawing this icon in the gutter

---
 src/metadata-widget.c | 105 ++++++++++++++++++++++++++++----------------------
 1 file changed, 58 insertions(+), 47 deletions(-)

(limited to 'src')

diff --git a/src/metadata-widget.c b/src/metadata-widget.c
index 95814c8..5f04fd7 100644
--- a/src/metadata-widget.c
+++ b/src/metadata-widget.c
@@ -36,7 +36,7 @@ struct _MetadataWidgetPrivate
 {
   gboolean   theme_change_occured;
   GtkWidget* meta_data_h_box;
-  GtkWidget* meta_data_v_box;  
+  GtkWidget* meta_data_v_box;
   GtkWidget* album_art;
   GString*   image_path;
   GString*   old_image_path;
@@ -45,7 +45,8 @@ struct _MetadataWidgetPrivate
   GtkWidget* container_label;
   GtkWidget* player_label;
   GtkWidget* player_icon;
-  DbusmenuMenuitem* twin_item;      
+  GdkPixbuf* icon_buf;
+  DbusmenuMenuitem* twin_item;
 };
 
 #define METADATA_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), METADATA_WIDGET_TYPE, MetadataWidgetPrivate))
@@ -110,9 +111,8 @@ metadata_widget_init (MetadataWidget *self)
   MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self);
   GtkWidget *hbox;
   GtkWidget *outer_v_box;
-  GtkWidget *top_h_box;
-  
-  top_h_box = gtk_hbox_new(FALSE, 0); 
+  priv->icon_buf = NULL;
+    
   outer_v_box = gtk_vbox_new (FALSE, 0);
   hbox = gtk_hbox_new(FALSE, 0);
   
@@ -188,26 +188,8 @@ metadata_widget_init (MetadataWidget *self)
   gtk_misc_set_padding (GTK_MISC(player_label), (gfloat)0, (gfloat)0);  
   gtk_widget_set_size_request (player_label, 200, 25);
   priv->player_label = player_label;
-
-  gtk_box_pack_start (GTK_BOX (top_h_box), priv->player_label, FALSE, FALSE, 0);  
-  
-  // Player Icon
-  gint width, height;
-  gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, &height);
-  
-  GtkWidget* player_icon;
-  player_icon = gtk_image_new();
-  priv->player_icon = player_icon;
-  
-  gtk_widget_set_size_request(priv->player_icon, width
-                                    + 5 /* ref triangle is 5x9 pixels */
-                                    + 1 /* padding */,
-                                    height);
-                                    
-  //gtk_misc_set_alignment(GTK_MISC(priv->player_icon), 0.5 /* right aligned */, 0);
-  gtk_box_pack_start (GTK_BOX (top_h_box), priv->player_icon, FALSE, FALSE, 0);  
-  
-  gtk_box_pack_start (GTK_BOX(outer_v_box), top_h_box, FALSE, FALSE, 0);
+      
+  gtk_box_pack_start (GTK_BOX(outer_v_box), priv->player_label, FALSE, FALSE, 0);
   gtk_box_pack_start (GTK_BOX(outer_v_box), priv->meta_data_h_box, FALSE, FALSE, 0);
     
   gtk_container_add (GTK_CONTAINER (self), outer_v_box);  
@@ -567,6 +549,9 @@ metadata_widget_set_style(GtkWidget* metadata, GtkStyle* style)
 static void 
 metadata_widget_set_icon (MetadataWidget *self)
 {
+  //TODO 
+  //tidy preexisting pixbufs (if they exist) in the prop update for images.
+
   MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self); 
 
   gint padding = 0;
@@ -577,30 +562,32 @@ metadata_widget_set_icon (MetadataWidget *self)
   GString* banshee_string = g_string_new ( "banshee" );
   GString* app_panel = g_string_new ( g_utf8_strdown (dbusmenu_menuitem_property_get(priv->twin_item, DBUSMENU_METADATA_MENUITEM_PLAYER_NAME),
                                                      -1));
-  GtkWidget * icon = NULL;
+  GdkPixbuf* icon_buf;
   
+  // Banshee Special case!  
   // Not ideal but apparently we want the banshee icon to be the greyscale one
   // and any others to be the icon from the desktop file => colour.
   if ( g_string_equal ( banshee_string, app_panel ) == TRUE &&
       gtk_icon_theme_has_icon ( gtk_icon_theme_get_default(), app_panel->str ) ){
     g_string_append ( app_panel, "-panel" );                                                   
-    icon = gtk_image_new_from_icon_name ( app_panel->str,
-                                          GTK_ICON_SIZE_MENU );    
   }
   else{
-    icon = gtk_image_new_from_icon_name ( g_strdup (dbusmenu_menuitem_property_get ( priv->twin_item, DBUSMENU_METADATA_MENUITEM_PLAYER_ICON )),
-                                          GTK_ICON_SIZE_MENU );
+    // Otherwise use what is stored in the props
+    g_string_erase (app_panel, 0, -1);
+    g_string_overwrite (app_panel,
+                        0,
+                        dbusmenu_menuitem_property_get ( priv->twin_item,
+                                                         DBUSMENU_METADATA_MENUITEM_PLAYER_ICON ));  
   }
+  icon_buf = gtk_icon_theme_load_icon ( gtk_icon_theme_get_default(),
+                                        app_panel->str,
+                                        (width > height) ? width : height,
+                                        GTK_ICON_LOOKUP_GENERIC_FALLBACK, 
+                                        NULL );  
+  gdk_pixbuf_ref (icon_buf);
+  priv->icon_buf = icon_buf;
   g_string_free ( app_panel, FALSE) ;
   g_string_free ( banshee_string, FALSE) ;
-
-  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);
-  priv->player_icon = icon;
-  gtk_widget_show(priv->player_icon);
 }
 
 static void
@@ -656,15 +643,10 @@ metadata_widget_triangle_draw_cb (GtkWidget *widget,
   g_return_val_if_fail(IS_METADATA_WIDGET(user_data), FALSE);
   MetadataWidget* meta = METADATA_WIDGET(user_data);
   MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(meta);  
-   
+  
   GtkStyle *style;
   cairo_t *cr;
-  int x, y, arrow_width, arrow_height;
-                                                
-  if (! dbusmenu_menuitem_property_get_bool (priv->twin_item,
-                                             DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING)){
-    return FALSE;
-  }
+  int x, y, arrow_width, arrow_height;               
   
   style = gtk_widget_get_style (widget);
 
@@ -674,7 +656,36 @@ metadata_widget_triangle_draw_cb (GtkWidget *widget,
   
   x = widget->allocation.x;
   y = widget->allocation.y + (double)arrow_height/2.0 + vertical_offset;
-  
+    
+  // Draw player icon  
+  if (priv->icon_buf != NULL){
+    g_debug ("Is the icon a pixbuf for image string : %i",
+             GDK_IS_PIXBUF (priv->icon_buf));                                        
+  
+    gint pixbuf_width = gdk_pixbuf_get_width (priv->icon_buf);
+    gint pixbuf_height = gdk_pixbuf_get_width (priv->icon_buf);
+
+    cairo_surface_t *surface = cairo_image_surface_create_for_data (gdk_pixbuf_get_pixels(priv->icon_buf),
+                                                                    CAIRO_FORMAT_RGB24,
+                                                                    pixbuf_width,
+                                                                    pixbuf_height,
+                                                                    gdk_pixbuf_get_rowstride(priv->icon_buf));
+    cr = cairo_create (surface);
+    cairo_move_to (cr, x, y);
+
+    cairo_paint (cr);
+
+    cairo_destroy (cr);
+    cairo_surface_destroy (surface);      
+    g_debug ("here 1");                                    
+  }
+    
+  // Draw triangle but only if the player is running.
+  if (! dbusmenu_menuitem_property_get_bool (priv->twin_item,
+                                             DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING)){
+    return FALSE;
+  }
+
   cr = (cairo_t*) gdk_cairo_create (widget->window);
 
   cairo_set_line_width (cr, 1.0);
@@ -688,7 +699,7 @@ metadata_widget_triangle_draw_cb (GtkWidget *widget,
                             style->fg[gtk_widget_get_state(widget)].blue/65535.0);
   cairo_fill (cr);
   cairo_destroy (cr);
-  return FALSE;  
+  return FALSE;
 }
 
  /**
-- 
cgit v1.2.3


From 9ab1c1505226e7b384ebdaea1eca760d05bc803d Mon Sep 17 00:00:00 2001
From: Conor Curran <conor.curran@canonical.com>
Date: Thu, 16 Jun 2011 16:01:26 +0200
Subject: spacing issues resolved plus some unwanted prop set to invisible@

---
 src/metadata-widget.c      | 65 +++++++++++++++++++---------------------------
 src/player-controller.vala |  3 ++-
 src/player-item.vala       |  2 --
 3 files changed, 29 insertions(+), 41 deletions(-)

(limited to 'src')

diff --git a/src/metadata-widget.c b/src/metadata-widget.c
index 5f04fd7..aea6f2e 100644
--- a/src/metadata-widget.c
+++ b/src/metadata-widget.c
@@ -79,9 +79,9 @@ static void metadata_widget_selection_received_event_callback( GtkWidget
                                                                 GtkSelectionData *data,
                                                                 guint             time,
                                                                 gpointer          user_data);
-static gboolean metadata_widget_triangle_draw_cb ( GtkWidget *image,
-                                                   GdkEventExpose *event,
-                                                   gpointer user_data);
+static gboolean metadata_widget_icon_triangle_draw_cb ( GtkWidget *image,
+                                                        GdkEventExpose *event,
+                                                        gpointer user_data );
 
 static void metadata_widget_set_icon (MetadataWidget *self);
 static void metadata_widget_handle_resizing (MetadataWidget* self);
@@ -127,9 +127,9 @@ metadata_widget_init (MetadataWidget *self)
                    G_CALLBACK(metadata_image_expose),
                    GTK_WIDGET(self));
 
-  g_signal_connect(GTK_WIDGET(self), "expose-event", 
-                   G_CALLBACK(metadata_widget_triangle_draw_cb),
-                   GTK_WIDGET(self));
+  g_signal_connect_after (GTK_WIDGET(self), "expose-event", 
+                          G_CALLBACK(metadata_widget_icon_triangle_draw_cb),
+                          GTK_WIDGET(self));
   
   gtk_box_pack_start (GTK_BOX (priv->meta_data_h_box),
                       priv->album_art,
@@ -185,7 +185,7 @@ metadata_widget_init (MetadataWidget *self)
   GtkWidget* player_label;
   player_label = gtk_label_new("");
   gtk_misc_set_alignment(GTK_MISC(player_label), (gfloat)0, (gfloat)0);
-  gtk_misc_set_padding (GTK_MISC(player_label), (gfloat)0, (gfloat)0);  
+  gtk_misc_set_padding (GTK_MISC(player_label), (gfloat)1, (gfloat)0);  
   gtk_widget_set_size_request (player_label, 200, 25);
   priv->player_label = player_label;
       
@@ -391,7 +391,7 @@ draw_album_art_placeholder(GtkWidget *metadata)
                          1.0);
   
   pango_cairo_update_layout(cr, layout);
-  cairo_move_to (cr, alloc.x + alloc.width/6, alloc.y + alloc.height/8);  
+  cairo_move_to (cr, alloc.x + alloc.width/6, alloc.y + 3);  
   pango_cairo_show_layout(cr, layout);
 
   g_object_unref(layout); 
@@ -586,8 +586,8 @@ metadata_widget_set_icon (MetadataWidget *self)
                                         NULL );  
   gdk_pixbuf_ref (icon_buf);
   priv->icon_buf = icon_buf;
-  g_string_free ( app_panel, FALSE) ;
-  g_string_free ( banshee_string, FALSE) ;
+  g_string_free ( app_panel, FALSE);
+  g_string_free ( banshee_string, FALSE);
 }
 
 static void
@@ -636,9 +636,9 @@ metadata_widget_set_twin_item (MetadataWidget* self,
 
 // Draw the triangle if the player is running ...
 static gboolean
-metadata_widget_triangle_draw_cb (GtkWidget *widget,
-                                  GdkEventExpose *event,
-                                  gpointer user_data)
+metadata_widget_icon_triangle_draw_cb (GtkWidget *widget,
+                                       GdkEventExpose *event,
+                                       gpointer user_data)
 {
   g_return_val_if_fail(IS_METADATA_WIDGET(user_data), FALSE);
   MetadataWidget* meta = METADATA_WIDGET(user_data);
@@ -647,47 +647,36 @@ metadata_widget_triangle_draw_cb (GtkWidget *widget,
   GtkStyle *style;
   cairo_t *cr;
   int x, y, arrow_width, arrow_height;               
-  
-  style = gtk_widget_get_style (widget);
 
+  gint offset = 3;
   arrow_width = 5; 
   arrow_height = 9;
-  gint vertical_offset = 3;
+  
+  style = gtk_widget_get_style (widget);
+
+  cr = (cairo_t*) gdk_cairo_create (widget->window);  
   
   x = widget->allocation.x;
-  y = widget->allocation.y + (double)arrow_height/2.0 + vertical_offset;
+  y = widget->allocation.y;
     
   // Draw player icon  
-  if (priv->icon_buf != NULL){
-    g_debug ("Is the icon a pixbuf for image string : %i",
-             GDK_IS_PIXBUF (priv->icon_buf));                                        
-  
-    gint pixbuf_width = gdk_pixbuf_get_width (priv->icon_buf);
-    gint pixbuf_height = gdk_pixbuf_get_width (priv->icon_buf);
-
-    cairo_surface_t *surface = cairo_image_surface_create_for_data (gdk_pixbuf_get_pixels(priv->icon_buf),
-                                                                    CAIRO_FORMAT_RGB24,
-                                                                    pixbuf_width,
-                                                                    pixbuf_height,
-                                                                    gdk_pixbuf_get_rowstride(priv->icon_buf));
-    cr = cairo_create (surface);
-    cairo_move_to (cr, x, y);
-
+  if (priv->icon_buf != NULL){  
+    gdk_cairo_set_source_pixbuf (cr,
+                                 priv->icon_buf,
+                                 x + arrow_width + 1,
+                                 y + offset);
     cairo_paint (cr);
-
-    cairo_destroy (cr);
-    cairo_surface_destroy (surface);      
-    g_debug ("here 1");                                    
   }
     
   // Draw triangle but only if the player is running.
   if (! dbusmenu_menuitem_property_get_bool (priv->twin_item,
                                              DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING)){
+    cairo_destroy (cr);
     return FALSE;
   }
 
-  cr = (cairo_t*) gdk_cairo_create (widget->window);
-
+  
+  y += (double)arrow_height/2.0 + offset;
   cairo_set_line_width (cr, 1.0);
 
   cairo_move_to (cr, x, y);
diff --git a/src/player-controller.vala b/src/player-controller.vala
index 002af65..a08f692 100644
--- a/src/player-controller.vala
+++ b/src/player-controller.vala
@@ -142,7 +142,8 @@ public class PlayerController : GLib.Object
   }
 
   public void update_layout()
-  {     
+  {    
+    debug ("a call to update layout"); 
     PlaylistsMenuitem playlists_menuitem = this.custom_items[widget_order.PLAYLISTS] as PlaylistsMenuitem;
     MetadataMenuitem metadata_menuitem = this.custom_items[widget_order.METADATA] as MetadataMenuitem;
     if(this.current_state != state.CONNECTED){
diff --git a/src/player-item.vala b/src/player-item.vala
index 2af3f36..162dbea 100644
--- a/src/player-item.vala
+++ b/src/player-item.vala
@@ -86,8 +86,6 @@ public class PlayerItem : Dbusmenu.Menuitem
         this.property_set_bool(property, v.get_boolean());
       }
     }
-    // TODO- is this only relevant for the metadata, if so please call for just that case
-    this.property_set_bool(MENUITEM_PROP_VISIBLE, populated(attributes));        
   } 
   
   public bool populated(HashSet<string> attrs)
-- 
cgit v1.2.3


From 76406c4e1590a739f592e336cfa2816bd8ae6f4d Mon Sep 17 00:00:00 2001
From: Conor Curran <conor.curran@canonical.com>
Date: Thu, 16 Jun 2011 16:06:11 +0200
Subject: reverted the metadata widget to inherit from plain old gtk menu item,
 we don't need it to inherit from gtkimagemenuitem anymore

---
 src/metadata-widget.c | 3 +--
 src/metadata-widget.h | 7 +++----
 2 files changed, 4 insertions(+), 6 deletions(-)

(limited to 'src')

diff --git a/src/metadata-widget.c b/src/metadata-widget.c
index aea6f2e..71af85d 100644
--- a/src/metadata-widget.c
+++ b/src/metadata-widget.c
@@ -44,7 +44,6 @@ struct _MetadataWidgetPrivate
   GtkWidget* piece_label;
   GtkWidget* container_label;
   GtkWidget* player_label;
-  GtkWidget* player_icon;
   GdkPixbuf* icon_buf;
   DbusmenuMenuitem* twin_item;
 };
@@ -87,7 +86,7 @@ static void metadata_widget_set_icon (MetadataWidget *self);
 static void metadata_widget_handle_resizing (MetadataWidget* self);
 
 
-G_DEFINE_TYPE (MetadataWidget, metadata_widget, GTK_TYPE_IMAGE_MENU_ITEM);
+G_DEFINE_TYPE (MetadataWidget, metadata_widget, GTK_TYPE_MENU_ITEM);
 
 static void
 metadata_widget_class_init (MetadataWidgetClass *klass)
diff --git a/src/metadata-widget.h b/src/metadata-widget.h
index 48dc61e..30b629c 100644
--- a/src/metadata-widget.h
+++ b/src/metadata-widget.h
@@ -19,8 +19,7 @@ with this program.  If not, see <http://www.gnu.org/licenses/>.
 #ifndef __METADATA_WIDGET_H__
 #define __METADATA_WIDGET_H__
 
-//#include <gtk/gtkmenuitem.h>
-#include <gtk/gtkimagemenuitem.h>
+#include <gtk/gtkmenuitem.h>
 #include <libdbusmenu-gtk/menuitem.h>
 
 G_BEGIN_DECLS
@@ -36,11 +35,11 @@ typedef struct _MetadataWidget      MetadataWidget;
 typedef struct _MetadataWidgetClass MetadataWidgetClass;
 
 struct _MetadataWidgetClass {
-  GtkImageMenuItemClass parent_class;
+  GtkMenuItemClass parent_class;
 };
 
 struct _MetadataWidget {
-  GtkImageMenuItem parent;
+  GtkMenuItem parent;
 };
 
 GType metadata_widget_get_type (void);
-- 
cgit v1.2.3


From ea24e75c29663159bbb942e8dfdf3a6970a9044a Mon Sep 17 00:00:00 2001
From: Conor Curran <conor.curran@canonical.com>
Date: Thu, 16 Jun 2011 16:33:03 +0200
Subject: some mem leaks caught and a tidy up

---
 src/metadata-widget.c | 48 ++++++++++++++++++++++++++----------------------
 1 file changed, 26 insertions(+), 22 deletions(-)

(limited to 'src')

diff --git a/src/metadata-widget.c b/src/metadata-widget.c
index 71af85d..e4f8fdc 100644
--- a/src/metadata-widget.c
+++ b/src/metadata-widget.c
@@ -197,6 +197,11 @@ metadata_widget_init (MetadataWidget *self)
 static void
 metadata_widget_dispose (GObject *object)
 {
+  MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(METADATA_WIDGET(object)); 
+
+  if (priv->icon_buf != NULL){
+    gdk_pixbuf_unref(priv->icon_buf);
+  }
   G_OBJECT_CLASS (metadata_widget_parent_class)->dispose (object);
 }
 
@@ -548,11 +553,13 @@ metadata_widget_set_style(GtkWidget* metadata, GtkStyle* style)
 static void 
 metadata_widget_set_icon (MetadataWidget *self)
 {
-  //TODO 
-  //tidy preexisting pixbufs (if they exist) in the prop update for images.
-
   MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self); 
 
+  if (priv->icon_buf != NULL){
+    gdk_pixbuf_unref(priv->icon_buf);
+    priv->icon_buf = NULL;    
+  }
+  
   gint padding = 0;
   gtk_widget_style_get(GTK_WIDGET(self), "horizontal-padding", &padding, NULL);
   gint width, height;
@@ -568,7 +575,7 @@ metadata_widget_set_icon (MetadataWidget *self)
   // and any others to be the icon from the desktop file => colour.
   if ( g_string_equal ( banshee_string, app_panel ) == TRUE &&
       gtk_icon_theme_has_icon ( gtk_icon_theme_get_default(), app_panel->str ) ){
-    g_string_append ( app_panel, "-panel" );                                                   
+    g_string_append ( app_panel, "-panel" );
   }
   else{
     // Otherwise use what is stored in the props
@@ -585,8 +592,8 @@ metadata_widget_set_icon (MetadataWidget *self)
                                         NULL );  
   gdk_pixbuf_ref (icon_buf);
   priv->icon_buf = icon_buf;
-  g_string_free ( app_panel, FALSE);
-  g_string_free ( banshee_string, FALSE);
+  g_string_free ( app_panel, TRUE);
+  g_string_free ( banshee_string, TRUE);
 }
 
 static void
@@ -668,26 +675,23 @@ metadata_widget_icon_triangle_draw_cb (GtkWidget *widget,
   }
     
   // Draw triangle but only if the player is running.
-  if (! dbusmenu_menuitem_property_get_bool (priv->twin_item,
+  if (dbusmenu_menuitem_property_get_bool (priv->twin_item,
                                              DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING)){
-    cairo_destroy (cr);
-    return FALSE;
+    y += (double)arrow_height/2.0 + offset;
+    cairo_set_line_width (cr, 1.0);
+
+    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);                                             
   }
-
   
-  y += (double)arrow_height/2.0 + offset;
-  cairo_set_line_width (cr, 1.0);
-
-  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);
   cairo_destroy (cr);
-  return FALSE;
+  return FALSE;  
 }
 
  /**
-- 
cgit v1.2.3


From 1b7f9eb7bb78339e2755632d3945219d226dbd58 Mon Sep 17 00:00:00 2001
From: Conor Curran <conor.curran@canonical.com>
Date: Thu, 16 Jun 2011 16:38:53 +0200
Subject: no need to ref the pixbuf

---
 src/metadata-widget.c | 1 -
 1 file changed, 1 deletion(-)

(limited to 'src')

diff --git a/src/metadata-widget.c b/src/metadata-widget.c
index e4f8fdc..f687d0c 100644
--- a/src/metadata-widget.c
+++ b/src/metadata-widget.c
@@ -590,7 +590,6 @@ metadata_widget_set_icon (MetadataWidget *self)
                                         (width > height) ? width : height,
                                         GTK_ICON_LOOKUP_GENERIC_FALLBACK, 
                                         NULL );  
-  gdk_pixbuf_ref (icon_buf);
   priv->icon_buf = icon_buf;
   g_string_free ( app_panel, TRUE);
   g_string_free ( banshee_string, TRUE);
-- 
cgit v1.2.3