diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/indicator-sound.c | 25 | ||||
-rw-r--r-- | src/title-widget.c | 34 | ||||
-rw-r--r-- | src/title-widget.h | 6 |
3 files changed, 39 insertions, 26 deletions
diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 0f0c32d..937ed68 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -48,7 +48,7 @@ typedef struct _IndicatorSoundPrivate IndicatorSoundPrivate; struct _IndicatorSoundPrivate { GtkWidget* volume_widget; - DbusmenuGtkMenu* menu; + //DbusmenuGtkMenu* menu; }; #define INDICATOR_SOUND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATOR_SOUND_TYPE, IndicatorSoundPrivate)) @@ -211,8 +211,8 @@ static GtkMenu * get_menu (IndicatorObject * io) { DbusmenuGtkMenu* menu = dbusmenu_gtkmenu_new(INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_DBUS_OBJECT); - IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (io)); - priv->menu = menu; + //IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (io)); + //priv->menu = menu; DbusmenuGtkClient *client = dbusmenu_gtkmenu_get_client(menu); g_object_set_data (G_OBJECT (client), "indicator", io); @@ -223,7 +223,7 @@ get_menu (IndicatorObject * io) dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_SCRUB_MENUITEM_TYPE, new_scrub_bar_widget); // register Key-press listening on the menu widget as the slider does not allow this. g_signal_connect(menu, "key-press-event", G_CALLBACK(key_press_cb), io); - priv->menu = menu; + //priv->menu = menu; return GTK_MENU(menu); } @@ -279,27 +279,16 @@ new_metadata_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm static gboolean new_title_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { - g_debug("indicator-sound: new_title_widget"); - + g_debug("indicator-sound: new_title_widget"); g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); + g_debug ("%s (\"%s\")", __func__, dbusmenu_menuitem_property_get(newitem, DBUSMENU_TITLE_MENUITEM_NAME)); + GtkWidget* title = NULL; - IndicatorObject *io = NULL; title = title_widget_new (newitem); GtkMenuItem *menu_title_widget = GTK_MENU_ITEM(title); - - io = g_object_get_data (G_OBJECT (client), "indicator"); - IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (io)); - - GtkWidget* image_item = gtk_image_menu_item_new(); - gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(image_item), - title_widget_get_player_icon(TITLE_WIDGET(title))); - - gtk_widget_show_all(image_item); - - gtk_menu_append(priv->menu, image_item); gtk_widget_show_all(title); 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 diff --git a/src/title-widget.h b/src/title-widget.h index 827a8f3..3e3ada8 100644 --- a/src/title-widget.h +++ b/src/title-widget.h @@ -19,7 +19,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef __TITLE_WIDGET_H__ #define __TITLE_WIDGET_H__ -#include <gtk/gtkmenuitem.h> +#include <gtk/gtkimagemenuitem.h> #include <libdbusmenu-gtk/menuitem.h> G_BEGIN_DECLS @@ -35,11 +35,11 @@ typedef struct _TitleWidget TitleWidget; typedef struct _TitleWidgetClass TitleWidgetClass; struct _TitleWidgetClass { - GtkMenuItemClass parent_class; + GtkImageMenuItemClass parent_class; }; struct _TitleWidget { - GtkMenuItem parent; + GtkImageMenuItem parent; }; GType title_widget_get_type (void); |