Merge lp:~bratsche/indicator-sound/icon-placement into lp:indicator-sound/sound-menu-v2

Proposed by Conor Curran
Status: Merged
Merge reported by: Conor Curran
Merged at revision: not available
Proposed branch: lp:~bratsche/indicator-sound/icon-placement
Merge into: lp:indicator-sound/sound-menu-v2
Diff against target: 703 lines (+210/-100) (has conflicts)
10 files modified
src/common-defs.h (+1/-0)
src/indicator-sound.c (+32/-27)
src/mpris2-controller.vala (+11/-11)
src/player-controller.vala (+6/-0)
src/sound-service.c (+6/-0)
src/title-menu-item.vala (+6/-1)
src/title-widget.c (+131/-54)
src/title-widget.h (+7/-5)
src/transport-menu-item.vala (+9/-2)
vapi/common-defs.vapi (+1/-0)
Text conflict in src/sound-service.c
To merge this branch: bzr merge lp:~bratsche/indicator-sound/icon-placement
Reviewer Review Type Date Requested Status
Conor Curran (community) Approve
Review via email: mp+34798@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Conor Curran (cjcurran) wrote :

+1

review: Approve
Revision history for this message
Conor Curran (cjcurran) wrote :

Manually merged.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/common-defs.h'
--- src/common-defs.h 2010-09-03 13:06:00 +0000
+++ src/common-defs.h 2010-09-07 20:31:00 +0000
@@ -41,6 +41,7 @@
4141
42#define DBUSMENU_TITLE_MENUITEM_TYPE "x-canonical-sound-menu-player-title-type"42#define DBUSMENU_TITLE_MENUITEM_TYPE "x-canonical-sound-menu-player-title-type"
43#define DBUSMENU_TITLE_MENUITEM_NAME "x-canonical-sound-menu-player-title-name"43#define DBUSMENU_TITLE_MENUITEM_NAME "x-canonical-sound-menu-player-title-name"
44#define DBUSMENU_TITLE_MENUITEM_RUNNING "x-canonical-sound-menu-player-title-running"
4445
45#define DBUSMENU_SCRUB_MENUITEM_TYPE "x-canonical-sound-menu-player-scrub-type"46#define DBUSMENU_SCRUB_MENUITEM_TYPE "x-canonical-sound-menu-player-scrub-type"
46#define DBUSMENU_SCRUB_MENUITEM_DURATION "x-canonical-sound-menu-player-scrub-mpris:length"47#define DBUSMENU_SCRUB_MENUITEM_DURATION "x-canonical-sound-menu-player-scrub-mpris:length"
4748
=== modified file 'src/indicator-sound.c'
--- src/indicator-sound.c 2010-09-06 17:07:15 +0000
+++ src/indicator-sound.c 2010-09-07 20:31:00 +0000
@@ -133,7 +133,7 @@
133 IndicatorObjectClass *io_class = INDICATOR_OBJECT_CLASS(klass);133 IndicatorObjectClass *io_class = INDICATOR_OBJECT_CLASS(klass);
134134
135 g_type_class_add_private (klass, sizeof (IndicatorSoundPrivate));135 g_type_class_add_private (klass, sizeof (IndicatorSoundPrivate));
136 136
137 io_class->get_label = get_label;137 io_class->get_label = get_label;
138 io_class->get_image = get_icon;138 io_class->get_image = get_icon;
139 io_class->get_menu = get_menu;139 io_class->get_menu = get_menu;
@@ -154,7 +154,7 @@
154 blocked_id = 0;154 blocked_id = 0;
155 initial_mute = FALSE;155 initial_mute = FALSE;
156 device_available = TRUE;156 device_available = TRUE;
157 157
158 IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self);158 IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self);
159 priv->volume_widget = NULL;159 priv->volume_widget = NULL;
160160
@@ -196,8 +196,10 @@
196static GtkImage *196static GtkImage *
197get_icon (IndicatorObject * io)197get_icon (IndicatorObject * io)
198{198{
199 gchar* current_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(current_state));199 gchar* current_name = g_hash_table_lookup(volume_states,
200 g_debug("At start-up attempting to set the image to %s", current_name);200 GINT_TO_POINTER(current_state));
201 g_debug("At start-up attempting to set the image to %s",
202 current_name);
201 speaker_image = indicator_image_helper(current_name);203 speaker_image = indicator_image_helper(current_name);
202 gtk_widget_show(GTK_WIDGET(speaker_image));204 gtk_widget_show(GTK_WIDGET(speaker_image));
203 return speaker_image;205 return speaker_image;
@@ -209,18 +211,19 @@
209static GtkMenu *211static GtkMenu *
210get_menu (IndicatorObject * io)212get_menu (IndicatorObject * io)
211{213{
212 DbusmenuGtkMenu *menu = dbusmenu_gtkmenu_new(INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_DBUS_OBJECT);214 DbusmenuGtkMenu* menu = dbusmenu_gtkmenu_new(INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_DBUS_OBJECT);
215
213 DbusmenuGtkClient *client = dbusmenu_gtkmenu_get_client(menu);216 DbusmenuGtkClient *client = dbusmenu_gtkmenu_get_client(menu);
214 g_object_set_data (G_OBJECT (client), "indicator", io);217 g_object_set_data (G_OBJECT (client), "indicator", io);
215 dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_VOLUME_MENUITEM_TYPE, new_volume_slider_widget);218 dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_VOLUME_MENUITEM_TYPE, new_volume_slider_widget);
216 dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_TRANSPORT_MENUITEM_TYPE, new_transport_widget);219 dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_TRANSPORT_MENUITEM_TYPE, new_transport_widget);
217 dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_METADATA_MENUITEM_TYPE, new_metadata_widget);220 dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_METADATA_MENUITEM_TYPE, new_metadata_widget);
218 dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_TITLE_MENUITEM_TYPE, new_title_widget);221 dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_TITLE_MENUITEM_TYPE, new_title_widget);
219 dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_SCRUB_MENUITEM_TYPE, new_scrub_bar_widget); 222 dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_SCRUB_MENUITEM_TYPE, new_scrub_bar_widget);
220
221 // register Key-press listening on the menu widget as the slider does not allow this.223 // register Key-press listening on the menu widget as the slider does not allow this.
222 g_signal_connect(menu, "key-press-event", G_CALLBACK(key_press_cb), io);224 g_signal_connect(menu, "key-press-event", G_CALLBACK(key_press_cb), io);
223 return GTK_MENU(menu);225
226 return GTK_MENU(menu);
224}227}
225228
226static void229static void
@@ -275,19 +278,21 @@
275new_title_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client)278new_title_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client)
276{279{
277 g_debug("indicator-sound: new_title_widget");280 g_debug("indicator-sound: new_title_widget");
281 g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
282 g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);
283
284 g_debug ("%s (\"%s\")", __func__, dbusmenu_menuitem_property_get(newitem, DBUSMENU_TITLE_MENUITEM_NAME));
278285
279 GtkWidget* title = NULL;286 GtkWidget* title = NULL;
280287
281 g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
282 g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);
283
284 title = title_widget_new (newitem);288 title = title_widget_new (newitem);
285 GtkMenuItem *menu_title_widget = GTK_MENU_ITEM(title);289 GtkMenuItem *menu_title_widget = GTK_MENU_ITEM(title);
286290
287 gtk_widget_show_all(title);291 gtk_widget_show_all(title);
288292
289 dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_title_widget, parent);293 dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client),
290294 newitem,
295 menu_title_widget, parent);
291 return TRUE;296 return TRUE;
292}297}
293298
@@ -322,29 +327,29 @@
322 g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);327 g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
323 g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);328 g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);
324329
325 volume_widget = volume_widget_new (newitem); 330 volume_widget = volume_widget_new (newitem);
326 io = g_object_get_data (G_OBJECT (client), "indicator");331 io = g_object_get_data (G_OBJECT (client), "indicator");
327 IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (io));332 IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (io));
328 priv->volume_widget = volume_widget;333 priv->volume_widget = volume_widget;
329334
330 GtkWidget* ido_slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget));335 GtkWidget* ido_slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget));
331336
332 g_signal_connect(ido_slider_widget, "style-set", G_CALLBACK(style_changed_cb), NULL); 337 g_signal_connect(ido_slider_widget, "style-set", G_CALLBACK(style_changed_cb), NULL);
333 gtk_widget_set_sensitive(ido_slider_widget,338 gtk_widget_set_sensitive(ido_slider_widget,
334 !initial_mute);339 !initial_mute);
335 gtk_widget_show_all(ido_slider_widget);340 gtk_widget_show_all(ido_slider_widget);
336341
337 342
338 GtkMenuItem *menu_volume_item = GTK_MENU_ITEM(ido_slider_widget);343 GtkMenuItem *menu_volume_item = GTK_MENU_ITEM(ido_slider_widget);
339 dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client),344 dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client),
340 newitem,345 newitem,
341 menu_volume_item,346 menu_volume_item,
342 parent);347 parent);
343 348
344 fetch_mute_value_from_dbus();349 fetch_mute_value_from_dbus();
345 fetch_sink_availability_from_dbus(INDICATOR_SOUND (io));350 fetch_sink_availability_from_dbus(INDICATOR_SOUND (io));
346 351
347 return TRUE; 352 return TRUE;
348}353}
349354
350355
@@ -376,7 +381,7 @@
376 dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_AVAILABLE_UPDATE, G_CALLBACK(catch_signal_sink_availability_update), NULL, NULL);381 dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_AVAILABLE_UPDATE, G_CALLBACK(catch_signal_sink_availability_update), NULL, NULL);
377382
378 g_return_if_fail(IS_INDICATOR_SOUND(userdata));383 g_return_if_fail(IS_INDICATOR_SOUND(userdata));
379 384
380 }385 }
381 }386 }
382 return;387 return;
@@ -536,7 +541,7 @@
536fetch_sink_availability_from_dbus(IndicatorSound* self)541fetch_sink_availability_from_dbus(IndicatorSound* self)
537{542{
538 g_return_if_fail(IS_INDICATOR_SOUND(self));543 g_return_if_fail(IS_INDICATOR_SOUND(self));
539 544
540 GError * error = NULL;545 GError * error = NULL;
541 gboolean * available_input;546 gboolean * available_input;
542 available_input = g_new0(gboolean, 1);547 available_input = g_new0(gboolean, 1);
@@ -547,7 +552,7 @@
547 g_free(available_input);552 g_free(available_input);
548 return;553 return;
549 }554 }
550 555
551 device_available = *available_input;556 device_available = *available_input;
552 if (device_available == FALSE) {557 if (device_available == FALSE) {
553 update_state(STATE_SINKS_NONE);558 update_state(STATE_SINKS_NONE);
@@ -555,7 +560,7 @@
555 }560 }
556561
557 IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self);562 IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self);
558 GtkWidget* slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget)); 563 GtkWidget* slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget));
559 gtk_widget_set_sensitive(slider_widget, device_available);564 gtk_widget_set_sensitive(slider_widget, device_available);
560565
561 g_free(available_input);566 g_free(available_input);
@@ -600,7 +605,7 @@
600/*605/*
601 We can be sure the service won't send a mute signal unless it has changed !606 We can be sure the service won't send a mute signal unless it has changed !
602 UNMUTE's force a volume update therefore icon is updated appropriately => no need for unmute handling here.607 UNMUTE's force a volume update therefore icon is updated appropriately => no need for unmute handling here.
603*/ 608*/
604static void609static void
605catch_signal_sink_mute_update(DBusGProxy *proxy, gboolean mute_value, gpointer userdata)610catch_signal_sink_mute_update(DBusGProxy *proxy, gboolean mute_value, gpointer userdata)
606{611{
@@ -617,7 +622,7 @@
617 if(priv->volume_widget == NULL){622 if(priv->volume_widget == NULL){
618 return;623 return;
619 }624 }
620 GtkWidget* slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget)); 625 GtkWidget* slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget));
621 gtk_widget_set_sensitive(slider_widget, !mute_value);626 gtk_widget_set_sensitive(slider_widget, !mute_value);
622}627}
623628
@@ -652,8 +657,8 @@
652 if(priv->volume_widget == NULL){657 if(priv->volume_widget == NULL){
653 return FALSE;658 return FALSE;
654 }659 }
655 660
656 GtkWidget* slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget)); 661 GtkWidget* slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget));
657 GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)slider_widget);662 GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)slider_widget);
658 GtkRange* range = (GtkRange*)slider;663 GtkRange* range = (GtkRange*)slider;
659 gdouble current_value = gtk_range_get_value(range);664 gdouble current_value = gtk_range_get_value(range);
660665
=== modified file 'src/mpris2-controller.vala'
--- src/mpris2-controller.vala 2010-09-06 20:14:15 +0000
+++ src/mpris2-controller.vala 2010-09-07 20:31:00 +0000
@@ -105,7 +105,7 @@
105 if(play_v != null){105 if(play_v != null){
106 string state = play_v.get_string(); 106 string state = play_v.get_string();
107 debug("new playback state = %s", state); 107 debug("new playback state = %s", state);
108 int p = this.determine_play_state(state);108 TransportMenuitem.state p = (TransportMenuitem.state)this.determine_play_state(state);
109 (this.owner.custom_items[PlayerController.widget_order.TRANSPORT] as TransportMenuitem).change_play_state(p); 109 (this.owner.custom_items[PlayerController.widget_order.TRANSPORT] as TransportMenuitem).change_play_state(p);
110 }110 }
111 111
@@ -143,29 +143,29 @@
143 }143 }
144 144
145 145
146 private int determine_play_state(string status){146 private TransportMenuitem.state determine_play_state(string status){
147 if(status == null)147 if(status == null)
148 return 1;148 return TransportMenuitem.state.PAUSED;
149 149
150 if(status != null && status == "Playing"){150 if(status != null && status == "Playing"){
151 debug("determine play state - state = %s", status);151 debug("determine play state - state = %s", status);
152 return 0;152 return TransportMenuitem.state.PLAYING;
153 }153 }
154 return 1; 154 return TransportMenuitem.state.PAUSED;
155 }155 }
156 156
157 public void initial_update()157 public void initial_update()
158 {158 {
159 int32 status;159 TransportMenuitem.state update;
160 if(this.player.PlaybackStatus == null){160 if(this.player.PlaybackStatus == null){
161 status = 1;161 update = TransportMenuitem.state.PAUSED;
162 }162 }
163 else{163 else{
164 status = determine_play_state(this.player.PlaybackStatus);164 update = determine_play_state(this.player.PlaybackStatus);
165 }165 }
166 debug("initial update - play state %i", status);166 debug("initial update - play state %i", (int)update);
167 167
168 (this.owner.custom_items[PlayerController.widget_order.TRANSPORT] as TransportMenuitem).change_play_state(status);168 (this.owner.custom_items[PlayerController.widget_order.TRANSPORT] as TransportMenuitem).change_play_state(update);
169 GLib.HashTable<string, Value?> cleaned_metadata = this.clean_metadata();169 GLib.HashTable<string, Value?> cleaned_metadata = this.clean_metadata();
170 this.owner.custom_items[PlayerController.widget_order.METADATA].update(cleaned_metadata,170 this.owner.custom_items[PlayerController.widget_order.METADATA].update(cleaned_metadata,
171 MetadataMenuitem.attributes_format());171 MetadataMenuitem.attributes_format());
@@ -260,7 +260,7 @@
260 this.mpris2_root.Raise();260 this.mpris2_root.Raise();
261 }261 }
262 catch(DBus.Error e){262 catch(DBus.Error e){
263 error("Exception thrown while calling root function Raise - %s", e.message);263 error("Exception thrown while calling function Raise - %s", e.message);
264 }264 }
265 }265 }
266 }266 }
267267
=== modified file 'src/player-controller.vala'
--- src/player-controller.vala 2010-08-27 11:25:47 +0000
+++ src/player-controller.vala 2010-09-07 20:31:00 +0000
@@ -116,6 +116,8 @@
116 update_state(PlayerController.state.OFFLINE);116 update_state(PlayerController.state.OFFLINE);
117 this.custom_items[widget_order.TRANSPORT].reset(TransportMenuitem.attributes_format());117 this.custom_items[widget_order.TRANSPORT].reset(TransportMenuitem.attributes_format());
118 this.custom_items[widget_order.METADATA].reset(MetadataMenuitem.attributes_format());118 this.custom_items[widget_order.METADATA].reset(MetadataMenuitem.attributes_format());
119 TitleMenuitem title = this.custom_items[widget_order.TITLE] as TitleMenuitem;
120 title.toggle_active_triangle(false);
119 }121 }
120122
121 public void update_layout()123 public void update_layout()
@@ -172,6 +174,10 @@
172 {174 {
173 if(this.mpris_bridge.connected() == true){175 if(this.mpris_bridge.connected() == true){
174 this.update_state(state.CONNECTED);176 this.update_state(state.CONNECTED);
177 TitleMenuitem title = this.custom_items[widget_order.TITLE] as TitleMenuitem;
178 title.toggle_active_triangle(true);
179 TransportMenuitem transport = this.custom_items[widget_order.TRANSPORT] as TransportMenuitem;
180 transport.change_play_state(TransportMenuitem.state.PAUSED);
175 }181 }
176 else{182 else{
177 this.update_state(state.DISCONNECTED);183 this.update_state(state.DISCONNECTED);
178184
=== modified file 'src/sound-service.c'
--- src/sound-service.c 2010-09-07 16:57:49 +0000
+++ src/sound-service.c 2010-09-07 20:31:00 +0000
@@ -40,9 +40,15 @@
40{40{
41 if (mainloop != NULL) {41 if (mainloop != NULL) {
42 g_debug("Service shutdown !");42 g_debug("Service shutdown !");
43<<<<<<< TREE
43 //TODO: uncomment for release !!44 //TODO: uncomment for release !!
44 //close_pulse_activites();45 //close_pulse_activites();
45 //g_main_loop_quit(mainloop);46 //g_main_loop_quit(mainloop);
47=======
48 // TODO: uncomment for release !!
49 //close_pulse_activites();
50 //g_main_loop_quit(mainloop);
51>>>>>>> MERGE-SOURCE
46 }52 }
47 return;53 return;
48}54}
4955
=== modified file 'src/title-menu-item.vala'
--- src/title-menu-item.vala 2010-08-17 16:26:47 +0000
+++ src/title-menu-item.vala 2010-09-07 20:31:00 +0000
@@ -27,6 +27,7 @@
27 {27 {
28 Object(item_type: MENUITEM_TYPE, owner: parent);28 Object(item_type: MENUITEM_TYPE, owner: parent);
29 this.property_set(MENUITEM_NAME, parent.name); 29 this.property_set(MENUITEM_NAME, parent.name);
30 this.property_set_bool(MENUITEM_RUNNING, false);
30 }31 }
3132
32 public override void handle_event(string name, GLib.Value input_value, uint timestamp)33 public override void handle_event(string name, GLib.Value input_value, uint timestamp)
@@ -39,7 +40,11 @@
39 this.owner.mpris_bridge.expose();40 this.owner.mpris_bridge.expose();
40 } 41 }
41 }42 }
42 43
44 public void toggle_active_triangle(bool update)
45 {
46 this.property_set_bool(MENUITEM_RUNNING, update);
47 }
4348
44 public static HashSet<string> attributes_format()49 public static HashSet<string> attributes_format()
45 {50 {
4651
=== modified file 'src/title-widget.c'
--- src/title-widget.c 2010-08-25 17:15:56 +0000
+++ src/title-widget.c 2010-09-07 20:31:00 +0000
@@ -4,16 +4,16 @@
4Authors:4Authors:
5 Conor Curran <conor.curran@canonical.com>5 Conor Curran <conor.curran@canonical.com>
66
7This program is free software: you can redistribute it and/or modify it 7This program is free software: you can redistribute it and/or modify it
8under the terms of the GNU General Public License version 3, as published 8under the terms of the GNU General Public License version 3, as published
9by the Free Software Foundation.9by the Free Software Foundation.
1010
11This program is distributed in the hope that it will be useful, but 11This program is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranties of 12WITHOUT ANY WARRANTY; without even the implied warranties of
13MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 13MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
14PURPOSE. See the GNU General Public License for more details.14PURPOSE. See the GNU General Public License for more details.
1515
16You should have received a copy of the GNU General Public License along 16You should have received a copy of the GNU General Public License along
17with this program. If not, see <http://www.gnu.org/licenses/>.17with this program. If not, see <http://www.gnu.org/licenses/>.
18*/18*/
1919
@@ -27,15 +27,12 @@
27#include <gtk/gtk.h>27#include <gtk/gtk.h>
28#include <libindicator/indicator-image-helper.h>28#include <libindicator/indicator-image-helper.h>
2929
30
31typedef struct _TitleWidgetPrivate TitleWidgetPrivate;
32
33struct _TitleWidgetPrivate30struct _TitleWidgetPrivate
34{31{
35 GtkWidget* hbox;32 GtkWidget* hbox;
36 GtkWidget* name;33 GtkWidget* name;
37 GtkWidget* player_icon; 34 GtkWidget* icon;
38 DbusmenuMenuitem* twin_item; 35 DbusmenuMenuitem* twin_item;
39};36};
4037
41#define TITLE_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TITLE_WIDGET_TYPE, TitleWidgetPrivate))38#define TITLE_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TITLE_WIDGET_TYPE, TitleWidgetPrivate))
@@ -47,17 +44,21 @@
47static void title_widget_finalize (GObject *object);44static void title_widget_finalize (GObject *object);
4845
49// keyevent consumers46// keyevent consumers
50static gboolean title_widget_button_press_event (GtkWidget *menuitem, 47static gboolean title_widget_button_press_event (GtkWidget *menuitem,
51 GdkEventButton *event);48 GdkEventButton *event);
5249
53// Dbusmenuitem properties update callback50// Dbusmenuitem properties update callback
54static void title_widget_property_update(DbusmenuMenuitem* item, gchar* property, 51static void title_widget_property_update(DbusmenuMenuitem* item, gchar* property,
55 GValue* value, gpointer userdata);52 GValue* value, gpointer userdata);
56static void title_widget_set_twin_item( TitleWidget* self,53static void title_widget_set_twin_item( TitleWidget* self,
57 DbusmenuMenuitem* twin_item);54 DbusmenuMenuitem* twin_item);
58static void title_widget_style_name_text(TitleWidget* self);55static void title_widget_style_name_text(TitleWidget* self);
5956
60G_DEFINE_TYPE (TitleWidget, title_widget, GTK_TYPE_MENU_ITEM);57static gboolean title_widget_triangle_draw_cb (GtkWidget *widget,
58 GdkEventExpose *event,
59 gpointer data);
60
61G_DEFINE_TYPE (TitleWidget, title_widget, GTK_TYPE_IMAGE_MENU_ITEM);
6162
6263
6364
@@ -65,15 +66,14 @@
65title_widget_class_init (TitleWidgetClass *klass)66title_widget_class_init (TitleWidgetClass *klass)
66{67{
67 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);68 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
68 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);69 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
6970
70 widget_class->button_press_event = title_widget_button_press_event;71 widget_class->button_press_event = title_widget_button_press_event;
71 72
72 g_type_class_add_private (klass, sizeof (TitleWidgetPrivate));73 g_type_class_add_private (klass, sizeof (TitleWidgetPrivate));
7374
74 gobject_class->dispose = title_widget_dispose;75 gobject_class->dispose = title_widget_dispose;
75 gobject_class->finalize = title_widget_finalize;76 gobject_class->finalize = title_widget_finalize;
76
77}77}
7878
79static void79static void
@@ -81,15 +81,25 @@
81{81{
82 g_debug("TitleWidget::title_widget_init");82 g_debug("TitleWidget::title_widget_init");
8383
84 TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(self);84 TitleWidgetPrivate *priv = self->priv = TITLE_WIDGET_GET_PRIVATE (self);
8585
86 GtkWidget *hbox;86 gint padding = 4;
8787 gtk_widget_style_get(GTK_WIDGET(self), "horizontal-padding", &padding, NULL);
88 hbox = gtk_hbox_new(FALSE, 0);88
89 priv->hbox = hbox;89 gint width, height;
9090 gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height);
91 priv->player_icon = indicator_image_helper("sound_icon");91
92 gtk_box_pack_start(GTK_BOX (priv->hbox), priv->player_icon, FALSE, FALSE, 0); 92 GtkWidget * icon = gtk_image_new_from_icon_name("sound_icon", GTK_ICON_SIZE_MENU);
93
94 gtk_widget_set_size_request(icon, width
95 + 5 /* ref triangle is 5x9 pixels */
96 + 2 /* padding */,
97 height);
98 gtk_misc_set_alignment(GTK_MISC(icon), 1.0 /* right aligned */, 0.5);
99 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(self), GTK_WIDGET(icon));
100 gtk_widget_show(icon);
101
102 priv->icon = icon;
93}103}
94104
95static void105static void
@@ -106,30 +116,30 @@
106116
107/* Suppress/consume keyevents */117/* Suppress/consume keyevents */
108static gboolean118static gboolean
109title_widget_button_press_event (GtkWidget *menuitem, 119title_widget_button_press_event (GtkWidget *menuitem,
110 GdkEventButton *event)120 GdkEventButton *event)
111{121{
112 g_debug("TitleWidget::menu_press_event");122 g_debug("TitleWidget::menu_press_event");
113 TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(menuitem);123 TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(menuitem);
114 124
115 GValue value = {0};125 GValue value = {0};
116 g_value_init(&value, G_TYPE_BOOLEAN);126 g_value_init(&value, G_TYPE_BOOLEAN);
117127
118 g_value_set_boolean(&value, TRUE); 128 g_value_set_boolean(&value, TRUE);
119 dbusmenu_menuitem_handle_event (priv->twin_item, "Title menu event", &value, 0);129 dbusmenu_menuitem_handle_event (priv->twin_item, "Title menu event", &value, 0);
120 130
121 return FALSE;131 return FALSE;
122}132}
123133
124static void 134static void
125title_widget_property_update(DbusmenuMenuitem* item, gchar* property, 135title_widget_property_update(DbusmenuMenuitem* item, gchar* property,
126 GValue* value, gpointer userdata)136 GValue* value, gpointer userdata)
127{137{
128 g_return_if_fail (IS_TITLE_WIDGET (userdata)); 138 g_return_if_fail (IS_TITLE_WIDGET (userdata));
129 TitleWidget* mitem = TITLE_WIDGET(userdata);139 TitleWidget* mitem = TITLE_WIDGET(userdata);
130 TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(mitem);140 TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(mitem);
131 141
132 if(g_ascii_strcasecmp(DBUSMENU_TITLE_MENUITEM_NAME, property) == 0){ 142 if(g_ascii_strcasecmp(DBUSMENU_TITLE_MENUITEM_NAME, property) == 0){
133 gtk_label_set_text(GTK_LABEL(priv->name), g_value_get_string(value));143 gtk_label_set_text(GTK_LABEL(priv->name), g_value_get_string(value));
134 title_widget_style_name_text(mitem);144 title_widget_style_name_text(mitem);
135 }145 }
@@ -139,42 +149,109 @@
139title_widget_set_twin_item(TitleWidget* self,149title_widget_set_twin_item(TitleWidget* self,
140 DbusmenuMenuitem* twin_item)150 DbusmenuMenuitem* twin_item)
141{151{
142 TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(self);152 TitleWidgetPrivate *priv = self->priv;
143 priv->twin_item = twin_item;153
144 g_signal_connect(G_OBJECT(twin_item), "property-changed", 154 priv->twin_item = twin_item;
145 G_CALLBACK(title_widget_property_update), self); 155
146 priv->name = gtk_label_new(dbusmenu_menuitem_property_get(priv->twin_item, 156 g_signal_connect (G_OBJECT (twin_item),
147 DBUSMENU_TITLE_MENUITEM_NAME));157 "property-changed",
148 gtk_misc_set_padding(GTK_MISC(priv->name), 10, 0);158 G_CALLBACK (title_widget_property_update),
149 gtk_box_pack_start (GTK_BOX (priv->hbox), priv->name, FALSE, FALSE, 0); 159 self);
150160 g_signal_connect_after (G_OBJECT (self),
151 title_widget_style_name_text(self);161 "expose_event",
152 162 G_CALLBACK (title_widget_triangle_draw_cb),
153 gtk_widget_show_all (priv->hbox);163 twin_item);
154 gtk_container_add (GTK_CONTAINER (self), priv->hbox); 164
165 gint padding = 4;
166 gtk_widget_style_get(GTK_WIDGET(self), "horizontal-padding", &padding, NULL);
167
168 // Add the application name
169 priv->hbox = gtk_hbox_new (FALSE, 0);
170
171 priv->name = gtk_label_new(dbusmenu_menuitem_property_get(priv->twin_item,
172 DBUSMENU_TITLE_MENUITEM_NAME));
173 gtk_misc_set_alignment (GTK_MISC (priv->name), 0.0, 0.5);
174 gtk_box_pack_start (GTK_BOX (priv->hbox), priv->name, FALSE, FALSE, padding);
175 gtk_widget_show (priv->name);
176
177 title_widget_style_name_text(self);
178
179 gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (priv->hbox));
180 gtk_widget_show (priv->hbox);
155}181}
156 182
157static void183static void
158title_widget_style_name_text(TitleWidget* self)184title_widget_style_name_text(TitleWidget* self)
159{185{
160 TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(self);186 TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(self);
161187
162 char* markup;188 char* markup;
189
163 markup = g_markup_printf_escaped ("<span size=\"medium\">%s</span>",190 markup = g_markup_printf_escaped ("<span size=\"medium\">%s</span>",
164 gtk_label_get_text(GTK_LABEL(priv->name)));191 gtk_label_get_text(GTK_LABEL(priv->name)));
165 gtk_label_set_markup (GTK_LABEL (priv->name), markup);192 gtk_label_set_markup (GTK_LABEL (priv->name), markup);
166 g_free(markup);193 g_free(markup);
167}194}
168 195
196static gboolean
197title_widget_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
198{
199 GtkStyle *style;
200 cairo_t *cr;
201 int x, y, arrow_width, arrow_height;
202
203 if (!GTK_IS_WIDGET (widget)) return FALSE;
204 if (!DBUSMENU_IS_MENUITEM (data)) return FALSE;
205
206 /* render the triangle indicator only if the application is running */
207 if (! dbusmenu_menuitem_property_get_bool (DBUSMENU_MENUITEM(data),
208 DBUSMENU_TITLE_MENUITEM_RUNNING)){
209 return FALSE;
210 }
211
212 /* get style */
213 style = gtk_widget_get_style (widget);
214
215 /* set arrow position / dimensions */
216 arrow_width = 5; /* the pixel-based reference triangle is 5x9 */
217 arrow_height = 9;
218 x = widget->allocation.x;
219 y = widget->allocation.y + widget->allocation.height/2.0 - (double)arrow_height/2.0;
220
221 /* initialize cairo drawing area */
222 cr = (cairo_t*) gdk_cairo_create (widget->window);
223
224 /* set line width */
225 cairo_set_line_width (cr, 1.0);
226
227 /* cairo drawing code */
228 cairo_move_to (cr, x, y);
229 cairo_line_to (cr, x, y + arrow_height);
230 cairo_line_to (cr, x + arrow_width, y + (double)arrow_height/2.0);
231 cairo_close_path (cr);
232 cairo_set_source_rgb (cr, style->fg[gtk_widget_get_state(widget)].red/65535.0,
233 style->fg[gtk_widget_get_state(widget)].green/65535.0,
234 style->fg[gtk_widget_get_state(widget)].blue/65535.0);
235 cairo_fill (cr);
236
237 /* remember to destroy cairo context to avoid leaks */
238 cairo_destroy (cr);
239
240 return FALSE;
241}
242
169 /**243 /**
170 * transport_new:244 * transport_new:
171 * @returns: a new #TitleWidget.245 * @returns: a new #TitleWidget.
172 **/246 **/
173GtkWidget* 247GtkWidget*
174title_widget_new(DbusmenuMenuitem *item)248title_widget_new(DbusmenuMenuitem *item)
175{249{
176 GtkWidget* widget = g_object_new(TITLE_WIDGET_TYPE, NULL);250 GtkWidget* widget = g_object_new (TITLE_WIDGET_TYPE,
251 NULL);
252 gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (widget), TRUE);
177 title_widget_set_twin_item((TitleWidget*)widget, item);253 title_widget_set_twin_item((TitleWidget*)widget, item);
254
178 return widget;255 return widget;
179}256}
180257
181258
=== modified file 'src/title-widget.h'
--- src/title-widget.h 2010-08-06 12:20:03 +0000
+++ src/title-widget.h 2010-09-07 20:31:00 +0000
@@ -19,7 +19,7 @@
19#ifndef __TITLE_WIDGET_H__19#ifndef __TITLE_WIDGET_H__
20#define __TITLE_WIDGET_H__20#define __TITLE_WIDGET_H__
2121
22#include <gtk/gtkmenuitem.h>22#include <gtk/gtkimagemenuitem.h>
23#include <libdbusmenu-gtk/menuitem.h>23#include <libdbusmenu-gtk/menuitem.h>
2424
25G_BEGIN_DECLS25G_BEGIN_DECLS
@@ -31,15 +31,17 @@
31#define IS_TITLE_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TITLE_WIDGET_TYPE))31#define IS_TITLE_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TITLE_WIDGET_TYPE))
32#define TITLE_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TITLE_WIDGET_TYPE, TitleWidgetClass))32#define TITLE_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TITLE_WIDGET_TYPE, TitleWidgetClass))
3333
34typedef struct _TitleWidget TitleWidget;34typedef struct _TitleWidget TitleWidget;
35typedef struct _TitleWidgetClass TitleWidgetClass;35typedef struct _TitleWidgetClass TitleWidgetClass;
36typedef struct _TitleWidgetPrivate TitleWidgetPrivate;
3637
37struct _TitleWidgetClass {38struct _TitleWidgetClass {
38 GtkMenuItemClass parent_class;39 GtkImageMenuItemClass parent_class;
39};40};
4041
41struct _TitleWidget {42struct _TitleWidget {
42 GtkMenuItem parent;43 GtkImageMenuItem parent;
44 TitleWidgetPrivate *priv;
43};45};
4446
45GType title_widget_get_type (void);47GType title_widget_get_type (void);
4648
=== modified file 'src/transport-menu-item.vala'
--- src/transport-menu-item.vala 2010-08-12 12:21:57 +0000
+++ src/transport-menu-item.vala 2010-09-07 20:31:00 +0000
@@ -28,6 +28,11 @@
28 PLAY_PAUSE,28 PLAY_PAUSE,
29 NEXT29 NEXT
30 }30 }
31
32 public enum state{
33 PLAYING,
34 PAUSED
35 }
31 36
32 public TransportMenuitem(PlayerController parent)37 public TransportMenuitem(PlayerController parent)
33 {38 {
@@ -35,9 +40,9 @@
35 this.property_set_int(MENUITEM_PLAY_STATE, 1); 40 this.property_set_int(MENUITEM_PLAY_STATE, 1);
36 }41 }
3742
38 public void change_play_state(int state)43 public void change_play_state(state update)
39 {44 {
40 this.property_set_int(MENUITEM_PLAY_STATE, state); 45 this.property_set_int(MENUITEM_PLAY_STATE, update);
41 }46 }
42 47
43 public override void handle_event(string name, GLib.Value input_value, uint timestamp)48 public override void handle_event(string name, GLib.Value input_value, uint timestamp)
@@ -54,4 +59,6 @@
54 attrs.add(MENUITEM_PLAY_STATE);59 attrs.add(MENUITEM_PLAY_STATE);
55 return attrs;60 return attrs;
56 } 61 }
62
63
57}64}
58\ No newline at end of file65\ No newline at end of file
5966
=== modified file 'vapi/common-defs.vapi'
--- vapi/common-defs.vapi 2010-09-03 13:06:00 +0000
+++ vapi/common-defs.vapi 2010-09-07 20:31:00 +0000
@@ -36,6 +36,7 @@
36namespace DbusmenuTitle{36namespace DbusmenuTitle{
37 public const string MENUITEM_TYPE;37 public const string MENUITEM_TYPE;
38 public const string MENUITEM_NAME;38 public const string MENUITEM_NAME;
39 public const string MENUITEM_RUNNING;
39}40}
4041
41[CCode (cheader_filename = "common-defs.h")]42[CCode (cheader_filename = "common-defs.h")]

Subscribers

People subscribed via source and target branches