aboutsummaryrefslogtreecommitdiff
path: root/src/title-widget.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/title-widget.c')
-rw-r--r--src/title-widget.c48
1 files changed, 42 insertions, 6 deletions
diff --git a/src/title-widget.c b/src/title-widget.c
index f5af09e..45f918f 100644
--- a/src/title-widget.c
+++ b/src/title-widget.c
@@ -33,6 +33,8 @@ typedef struct _TitleWidgetPrivate TitleWidgetPrivate;
struct _TitleWidgetPrivate
{
GtkWidget* hbox;
+ GtkWidget* name;
+ GtkWidget* player_icon;
};
#define TITLE_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TITLE_WIDGET_TYPE, TitleWidgetPrivate))
@@ -42,19 +44,19 @@ static void title_widget_class_init (TitleWidgetClass *klass);
static void title_widget_init (TitleWidget *self);
static void title_widget_dispose (GObject *object);
static void title_widget_finalize (GObject *object);
+
// keyevent consumers
static gboolean title_widget_button_press_event (GtkWidget *menuitem,
- GdkEventButton *event);
+ GdkEventButton *event);
static gboolean title_widget_button_release_event (GtkWidget *menuitem,
- GdkEventButton *event);
+ 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,
GValue* value, gpointer userdata);
-
-
+static void style_name_text(TitleWidget* self);
G_DEFINE_TYPE (TitleWidget, title_widget, GTK_TYPE_MENU_ITEM);
@@ -87,9 +89,19 @@ title_widget_init (TitleWidget *self)
hbox = gtk_hbox_new(FALSE, 0);
priv->hbox = hbox;
-
g_signal_connect(G_OBJECT(twin_item), "property-changed",
G_CALLBACK(title_widget_property_update), self);
+
+ priv->player_icon = gtk_image_new_from_file("/home/ronoc/branches/sound-menu-v2/finish-indicate/indicator-sound/data/sound_icon.png");
+ gtk_box_pack_start(GTK_BOX (priv->hbox), priv->player_icon, FALSE, FALSE, 0);
+
+ priv->name = gtk_label_new(dbusmenu_menuitem_property_get(twin_item,
+ DBUSMENU_TITLE_MENUITEM_TEXT_NAME));
+ gtk_misc_set_padding(GTK_MISC(priv->name), 10, 0);
+ gtk_box_pack_start (GTK_BOX (priv->hbox), priv->name, FALSE, FALSE, 0);
+
+ style_name_text(self);
+
gtk_widget_show_all (priv->hbox);
gtk_container_add (GTK_CONTAINER (self), hbox);
@@ -113,6 +125,13 @@ title_widget_button_press_event (GtkWidget *menuitem,
GdkEventButton *event)
{
g_debug("TitleWidget::menu_press_event");
+
+ GValue value = {0};
+ g_value_init(&value, G_TYPE_BOOLEAN);
+
+ g_value_set_boolean(&value, TRUE);
+ dbusmenu_menuitem_handle_event (twin_item, "Title menu event", &value, 0);
+
return TRUE;
}
@@ -138,9 +157,26 @@ title_widget_property_update(DbusmenuMenuitem* item, gchar* property,
GValue* value, gpointer userdata)
{
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_TEXT_NAME, property) == 0){
+ gtk_label_set_text(GTK_LABEL(priv->name), g_value_get_string(value));
+ style_name_text(mitem);
+ }
}
+static void
+style_name_text(TitleWidget* self)
+{
+ TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(self);
+
+ char* markup;
+ markup = g_markup_printf_escaped ("<span weight=\"bold\">%s</span>",
+ gtk_label_get_text(GTK_LABEL(priv->name)));
+ gtk_label_set_markup (GTK_LABEL (priv->name), markup);
+ g_free(markup);
+}
/**
* transport_new: