diff options
author | Conor Curran <conor.curran@canonical.com> | 2010-07-12 15:34:10 +0100 |
---|---|---|
committer | Conor Curran <conor.curran@canonical.com> | 2010-07-12 15:34:10 +0100 |
commit | 8f4dd989349434361a383f54917b08efd9af2d46 (patch) | |
tree | 7fae59d6256f8b6713db9b477c92f18dd0f73532 | |
parent | b0a09afe59a904ce4b4e90e58d933ad1f0b036d9 (diff) | |
parent | c653012e7a55de1a6ecabf798a7d86e87d4affc6 (diff) | |
download | ayatana-indicator-sound-8f4dd989349434361a383f54917b08efd9af2d46.tar.gz ayatana-indicator-sound-8f4dd989349434361a383f54917b08efd9af2d46.tar.bz2 ayatana-indicator-sound-8f4dd989349434361a383f54917b08efd9af2d46.zip |
merge with the static scope problems widget side, plus positioning fixes and image url handling robustness
-rw-r--r-- | src/indicator-sound.c | 4 | ||||
-rw-r--r-- | src/mpris-controller-v2.vala | 4 | ||||
-rw-r--r-- | src/mpris-controller.vala | 40 | ||||
-rw-r--r-- | src/music-player-bridge.vala | 47 | ||||
-rw-r--r-- | src/play-button.c | 14 | ||||
-rw-r--r-- | src/player-controller.vala | 25 | ||||
-rw-r--r-- | src/player-item.vala | 23 | ||||
-rw-r--r-- | src/title-menu-item.vala | 7 | ||||
-rw-r--r-- | src/title-widget.c | 53 | ||||
-rw-r--r-- | src/transport-menu-item.vala | 2 | ||||
-rw-r--r-- | src/transport-widget.c | 47 |
11 files changed, 157 insertions, 109 deletions
diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 8be97b4..a2d9762 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -366,10 +366,10 @@ new_title_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusmenu title = title_widget_new (newitem); GtkMenuItem *menu_title_widget = GTK_MENU_ITEM(title); - dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_title_widget, parent); - gtk_widget_show_all(title); + dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_title_widget, parent); + return TRUE; } diff --git a/src/mpris-controller-v2.vala b/src/mpris-controller-v2.vala index 0392cfc..efb5084 100644 --- a/src/mpris-controller-v2.vala +++ b/src/mpris-controller-v2.vala @@ -21,8 +21,8 @@ using Gee; public class MprisControllerV2 : MprisController { - public MprisControllerV2(string name, PlayerController controller){ - base(name, controller, "org.mpris.MediaPlayer.Player"); + public MprisControllerV2(PlayerController ctrl, string inter="org.mpris.MediaPlayer.Player"){ + Object(owner: ctrl, mpris_interface: inter); } } diff --git a/src/mpris-controller.vala b/src/mpris-controller.vala index 2194d44..8dd0cc9 100644 --- a/src/mpris-controller.vala +++ b/src/mpris-controller.vala @@ -22,32 +22,42 @@ using Gee; public class MprisController : GLib.Object { - private DBus.Connection connection; - public dynamic DBus.Object mpris_player; - private PlayerController controller; - struct status { + private DBus.Connection connection; + public dynamic DBus.Object mpris_player{get; construct;} + public PlayerController owner {get; construct;} + public string mpris_interface {get; construct;} + private string name; + + + struct status { public int32 playback; //public int32 shuffle; // Not used just yet //public int32 repeat; //public int32 endless; } - public MprisController(string name, PlayerController controller, string mpris_interface="org.freedesktop.MediaPlayer"){ + public MprisController(PlayerController ctrl, string inter="org.freedesktop.MediaPlayer"){ + Object(owner: ctrl, mpris_interface: inter); + } + + construct{ try { this.connection = DBus.Bus.get (DBus.BusType.SESSION); } catch (Error e) { error("Problems connecting to the session bus - %s", e.message); } - this.controller = controller; - this.mpris_player = this.connection.get_object ("org.mpris.".concat(name.down()) , "/Player", mpris_interface); - this.mpris_player.TrackChange += onTrackChange; + this.mpris_player = this.connection.get_object ("org.mpris.".concat(this.owner.name.down()) , "/Player", this.mpris_interface); + + debug("just attempting to establish an mpris connection to %s, %s, %s", "org.mpris.".concat(this.owner.name.down()) , "/Player", this.mpris_interface); + + this.mpris_player.TrackChange += onTrackChange; this.mpris_player.StatusChange += onStatusChange; status st = this.mpris_player.GetStatus(); int play_state = st.playback; debug("GetStatusChange - play state %i", play_state); - (this.controller.custom_items[this.controller.TRANSPORT] as TransportMenuitem).change_play_state(play_state); - this.controller.custom_items[this.controller.METADATA].update(this.mpris_player.GetMetadata(), + (this.owner.custom_items[this.owner.TRANSPORT] as TransportMenuitem).change_play_state(play_state); + this.owner.custom_items[this.owner.METADATA].update(this.mpris_player.GetMetadata(), MetadataMenuitem.attributes_format()); } @@ -56,8 +66,8 @@ public class MprisController : GLib.Object private void onTrackChange(dynamic DBus.Object mpris_client, HashTable<string,Value?> ht) { debug("onTrackChange"); - this.controller.custom_items[this.controller.METADATA].reset(MetadataMenuitem.attributes_format()); - this.controller.custom_items[this.controller.METADATA].update(ht, + this.owner.custom_items[this.owner.METADATA].reset(MetadataMenuitem.attributes_format()); + this.owner.custom_items[this.owner.METADATA].update(ht, MetadataMenuitem.attributes_format()); } @@ -84,10 +94,10 @@ public class MprisController : GLib.Object } } else if(command == TransportMenuitem.action.PREVIOUS){ - this.mpris_player.previous(); + this.mpris_player.Prev(); } else if(command == TransportMenuitem.action.NEXT){ - this.mpris_player.next(); + this.mpris_player.Next(); } } @@ -107,7 +117,7 @@ public class MprisController : GLib.Object Value v = Value(typeof(int)); v.set_int(play_state); ht.insert("state", v); - this.controller.custom_items[this.controller.TRANSPORT].update(ht, TransportMenuitem.attributes_format()); + this.owner.custom_items[this.owner.TRANSPORT].update(ht, TransportMenuitem.attributes_format()); } diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala index d771192..2f87b2d 100644 --- a/src/music-player-bridge.vala +++ b/src/music-player-bridge.vala @@ -52,28 +52,34 @@ public class MusicPlayerBridge : GLib.Object warning("App string in keyfile is null therefore moving on to next player"); continue; } - try{ - DesktopAppInfo info = new DesktopAppInfo.from_filename(app); - if(info == null){ - warning("Could not create a desktopappinfo instance from app: %s", app); - continue; - } - GLib.AppInfo app_info = info as GLib.AppInfo; - PlayerController ctrl = new PlayerController(this.root_menu, - app_info.get_name(), - PlayerController.state.OFFLINE); - ctrl.set("app_info", app_info); - this.registered_clients.set(app_info.get_name().down().strip(), ctrl); - debug("Created a player controller for %s which was found in the cache file", app_info.get_name().down().strip()); - count += 1; - } - catch(Error er){ - warning("desktop path in cache is not formatted as we have anticipated"); + DesktopAppInfo info = new DesktopAppInfo.from_filename(app); + if(info == null){ + warning("Could not create a desktopappinfo instance from app: %s", app); + continue; } + GLib.AppInfo app_info = info as GLib.AppInfo; + PlayerController ctrl = new PlayerController(this.root_menu, + app_info.get_name(), + calculate_menu_position(), + PlayerController.state.OFFLINE); + ctrl.set("app_info", app_info); + this.registered_clients.set(app_info.get_name().down().strip(), ctrl); + debug("Created a player controller for %s which was found in the cache file", app_info.get_name().down().strip()); + count += 1; } break; } } + + private int calculate_menu_position() + { + if(this.registered_clients.size == 0){ + return 2; + } + else{ + return (2 + (this.registered_clients.size * 4)); + } + } public void on_server_added(Indicate.ListenerServer object, string type) { @@ -89,8 +95,13 @@ public class MusicPlayerBridge : GLib.Object } //else init a new one else{ - PlayerController ctrl = new PlayerController(root_menu, client_name, PlayerController.state.READY); + + PlayerController ctrl = new PlayerController(root_menu, + client_name, + calculate_menu_position(), + PlayerController.state.READY); registered_clients.set(client_name, ctrl); + debug("New Client of name %s has successfully registered with us", client_name); } // irregardless check that it has a desktop file if not kick off a request for it diff --git a/src/play-button.c b/src/play-button.c index 2fddbcf..d6d243c 100644 --- a/src/play-button.c +++ b/src/play-button.c @@ -29,7 +29,7 @@ Uses code from ctk #define RECT_WIDTH 130.0f #define Y 15.0f -#define X 22.0f +#define X 37.0f #define INNER_RADIUS 12.5 #define MIDDLE_RADIUS 13.5f #define OUTER_RADIUS 14.5f @@ -41,16 +41,16 @@ Uses code from ctk #define TRI_WIDTH 11.0f #define TRI_HEIGHT 13.0f #define TRI_OFFSET 6.0f -#define PREV_X 20.0f +#define PREV_X 35.0f #define PREV_Y 21.0f -#define NEXT_X 98.0f +#define NEXT_X 113.0f #define NEXT_Y 21.0f //prev_y #define PAUSE_WIDTH 21.0f #define PAUSE_HEIGHT 27.0f #define BAR_WIDTH 4.5f #define BAR_HEIGHT 24.0f #define BAR_OFFSET 10.0f -#define PAUSE_X 62.0f +#define PAUSE_X 77.0f #define PAUSE_Y 15.0f // Transport events @@ -363,15 +363,15 @@ determine_button_event(GtkWidget* button, GdkEventButton* event) g_debug("event y coordinate = %f", event->y); gint result = 0; // For now very simple rectangular collision detection - if(event->x > 40 && event->x < 80 + if(event->x > 55 && event->x < 95 && event->y > 22 && event->y < 46){ result = PREVIOUS; } - else if(event->x > 86 && event->x < 118 + else if(event->x > 101 && event->x < 133 && event->y > 20 && event->y < 47){ result = PLAY_PAUSE; } - else if(event->x > 122 && event->x < 164 + else if(event->x > 137 && event->x < 179 && event->y > 22 && event->y < 46){ result = NEXT; } diff --git a/src/player-controller.vala b/src/player-controller.vala index 3fb4750..d272d14 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -42,13 +42,16 @@ public class PlayerController : GLib.Object public ArrayList<PlayerItem> custom_items; public MprisController mpris_adaptor; public AppInfo? app_info { get; set;} + public int menu_offset { get; set;} - public PlayerController(Dbusmenu.Menuitem root, string client_name, state initial_state) + public PlayerController(Dbusmenu.Menuitem root, string client_name, int offset, state initial_state) { this.root_menu = root; this.name = format_client_name(client_name.strip()); this.custom_items = new ArrayList<PlayerItem>(); this.update_state(initial_state); + this.menu_offset = offset; + debug("offset = %i", offset); construct_widgets(); establish_mpris_connection(); update_layout(); @@ -56,7 +59,7 @@ public class PlayerController : GLib.Object public void update_state(state new_state) { - debug("update_state : new state %i", new_state); + debug("update_state - player controller %s : new state %i", this.name, new_state); this.current_state = new_state; } @@ -74,6 +77,7 @@ public class PlayerController : GLib.Object */ public void instantiate() { + debug("instantiate in player controller for %s", this.name); try{ this.app_info.launch(null, null); this.update_state(state.INSTANTIATING); @@ -89,13 +93,17 @@ public class PlayerController : GLib.Object debug("establish_mpris_connection - Not ready to connect"); return; } + if(this.name == "Vlc"){ - this.mpris_adaptor = new MprisControllerV2(this.name, this); + debug("establishing a vlc mpris controller"); + this.mpris_adaptor = new MprisController(this, "org.mpris.MediaPlayer.Player"); } else{ - this.mpris_adaptor = new MprisController(this.name, this); + this.mpris_adaptor = new MprisController(this); } + if(this.mpris_adaptor.connected() == true){ + debug("yup I'm connected"); this.update_state(state.CONNECTED); } else{ @@ -120,6 +128,10 @@ public class PlayerController : GLib.Object debug("about the set the visibility on both the transport and metadata widget to %s", visibility.to_string()); this.custom_items[TRANSPORT].property_set_bool(MENUITEM_PROP_VISIBLE, visibility); this.custom_items[METADATA].property_set_bool(MENUITEM_PROP_VISIBLE, visibility); + // DEBUG + if(this.mpris_adaptor == null){ + warning("Why is the mpris object null"); + } } @@ -129,7 +141,7 @@ public class PlayerController : GLib.Object this.custom_items.add(new PlayerItem(CLIENT_TYPES_SEPARATOR)); // Title item - TitleMenuitem title_menu_item = new TitleMenuitem(this, this.name); + TitleMenuitem title_menu_item = new TitleMenuitem(this); this.custom_items.add(title_menu_item); // Metadata item @@ -140,9 +152,8 @@ public class PlayerController : GLib.Object TransportMenuitem transport_item = new TransportMenuitem(this); this.custom_items.add(transport_item); - int offset = 2; foreach(PlayerItem item in this.custom_items){ - root_menu.child_add_position(item, offset + this.custom_items.index_of(item)); + root_menu.child_add_position(item, this.menu_offset + this.custom_items.index_of(item)); } } diff --git a/src/player-item.vala b/src/player-item.vala index 171c140..3e10b7b 100644 --- a/src/player-item.vala +++ b/src/player-item.vala @@ -55,8 +55,17 @@ public class PlayerItem : Dbusmenu.Menuitem Value? v = data.lookup(search_key); if (v.holds (typeof (string))){ - debug("with value : %s", v.get_string()); - this.property_set(property, this.sanitize_string(v.get_string())); + string update = v.get_string().strip(); + debug("with value : %s", update); + if(property.contains("arturl")){ + try{ + update = Filename.from_uri(update.strip()); + } + catch(ConvertError e){ + warning("Problem converting URI %s to file path", update); + } + } + this.property_set(property, update); } else if (v.holds (typeof (int))){ debug("with value : %i", v.get_int()); @@ -80,15 +89,5 @@ public class PlayerItem : Dbusmenu.Menuitem return true; } - public static string sanitize_string(string st) - { - string result = st.strip(); - if(result.has_prefix("file:///")){ - result = result.slice(7, result.len()); - } - debug("Sanitize string - result = %s", result); - return result; - } - } diff --git a/src/title-menu-item.vala b/src/title-menu-item.vala index 612d279..8183821 100644 --- a/src/title-menu-item.vala +++ b/src/title-menu-item.vala @@ -23,15 +23,16 @@ using Gee; public class TitleMenuitem : PlayerItem { - public TitleMenuitem(PlayerController parent, string name) + public TitleMenuitem(PlayerController parent) { Object(item_type: MENUITEM_TYPE, owner: parent); - this.property_set(MENUITEM_TEXT_NAME, name); + this.property_set(MENUITEM_TEXT_NAME, parent.name); } public override void handle_event(string name, GLib.Value input_value, uint timestamp) { - debug("handle_event with bool value %s", input_value.get_boolean().to_string()); + debug("handle_event for owner %s with owner state = %i and title menu name %s", this.owner.name, this.owner.current_state, property_get(MENUITEM_TEXT_NAME)); + if(this.owner.current_state == PlayerController.state.OFFLINE) { this.owner.instantiate(); diff --git a/src/title-widget.c b/src/title-widget.c index 1b57fe9..7e48940 100644 --- a/src/title-widget.c +++ b/src/title-widget.c @@ -27,7 +27,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <gtk/gtk.h> #include <libindicator/indicator-image-helper.h> -static DbusmenuMenuitem* twin_item; typedef struct _TitleWidgetPrivate TitleWidgetPrivate; @@ -36,6 +35,7 @@ struct _TitleWidgetPrivate GtkWidget* hbox; GtkWidget* name; GtkWidget* player_icon; + DbusmenuMenuitem* twin_item; }; #define TITLE_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TITLE_WIDGET_TYPE, TitleWidgetPrivate)) @@ -57,7 +57,10 @@ static gboolean title_widget_expose_event(GtkWidget* widget, // 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); +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); @@ -90,22 +93,9 @@ 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 = indicator_image_helper("sound_icon"); 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); - } static void @@ -126,12 +116,13 @@ title_widget_button_press_event (GtkWidget *menuitem, GdkEventButton *event) { g_debug("TitleWidget::menu_press_event"); - + TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(menuitem); + 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); + dbusmenu_menuitem_handle_event (priv->twin_item, "Title menu event", &value, 0); return TRUE; } @@ -163,12 +154,31 @@ title_widget_property_update(DbusmenuMenuitem* item, gchar* property, 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); + title_widget_style_name_text(mitem); } } static void -style_name_text(TitleWidget* self) +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); + priv->name = gtk_label_new(dbusmenu_menuitem_property_get(priv->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); + + title_widget_style_name_text(self); + + gtk_widget_show_all (priv->hbox); + gtk_container_add (GTK_CONTAINER (self), priv->hbox); +} + +static void +title_widget_style_name_text(TitleWidget* self) { TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(self); @@ -186,7 +196,8 @@ style_name_text(TitleWidget* self) GtkWidget* title_widget_new(DbusmenuMenuitem *item) { - twin_item = item; - return g_object_new(TITLE_WIDGET_TYPE, NULL); + GtkWidget* widget = g_object_new(TITLE_WIDGET_TYPE, NULL); + title_widget_set_twin_item((TitleWidget*)widget, item); + return widget; } diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala index e0710a8..8e837c2 100644 --- a/src/transport-menu-item.vala +++ b/src/transport-menu-item.vala @@ -43,7 +43,7 @@ public class TransportMenuitem : PlayerItem { int input = input_value.get_int(); debug("handle_event with value %s", input.to_string()); - // Fire and forgot - the widget would not have sent it over it didn't think it was relevant. + debug("transport owner name = %s", this.owner.name); this.owner.mpris_adaptor.transport_event((action)input); } diff --git a/src/transport-widget.c b/src/transport-widget.c index 9852b50..f02200e 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -27,15 +27,13 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <gtk/gtk.h> #include "play-button.h" - -static DbusmenuMenuitem* twin_item; - typedef struct _TransportWidgetPrivate TransportWidgetPrivate; struct _TransportWidgetPrivate { GtkWidget* hbox; GtkWidget* play_button; + DbusmenuMenuitem* twin_item; }; #define TRANSPORT_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRANSPORT_WIDGET_TYPE, TransportWidgetPrivate)) @@ -45,18 +43,24 @@ static void transport_widget_class_init (TransportWidgetClass *klass); static void transport_widget_init (TransportWidget *self); static void transport_widget_dispose (GObject *object); static void transport_widget_finalize (GObject *object); -static gboolean transport_widget_expose_event(GtkWidget* widget, GdkEventExpose* event); + +static void transport_widget_set_twin_item(TransportWidget* self, + DbusmenuMenuitem* twin_item); + +static gboolean transport_widget_expose_event(GtkWidget* widget, + GdkEventExpose* event); /* UI and dbusmenu callbacks */ -static gboolean transport_widget_button_press_event (GtkWidget *menuitem, - GdkEventButton *event); -static gboolean transport_widget_button_release_event (GtkWidget *menuitem, - GdkEventButton *event); +static gboolean transport_widget_button_press_event (GtkWidget *menuitem, + GdkEventButton *event); +static gboolean transport_widget_button_release_event (GtkWidget *menuitem, + GdkEventButton *event); static void transport_widget_property_update(DbusmenuMenuitem* item, gchar * property, GValue * value, gpointer userdata); + G_DEFINE_TYPE (TransportWidget, transport_widget, GTK_TYPE_MENU_ITEM); static void @@ -93,8 +97,6 @@ transport_widget_init (TransportWidget *self) play_button_set_style(priv->play_button, style); gtk_box_pack_start (GTK_BOX (priv->hbox), priv->play_button, FALSE, FALSE, 0); - - g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(transport_widget_property_update), self); gtk_container_add (GTK_CONTAINER (self), priv->hbox); @@ -120,14 +122,21 @@ transport_widget_expose_event(GtkWidget* widget, GdkEventExpose* event) //gtk_container_propagate_expose(GTK_CONTAINER(widget),priv->play_button, event); return TRUE; } - + +static void transport_widget_set_twin_item(TransportWidget* self, + DbusmenuMenuitem* twin_item) +{ + TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE(self); + priv->twin_item = twin_item; + g_signal_connect(G_OBJECT(priv->twin_item), "property-changed", + G_CALLBACK(transport_widget_property_update), self); +} /* keyevents */ static gboolean transport_widget_button_press_event (GtkWidget *menuitem, GdkEventButton *event) { - g_debug("TransportWidget::menu_press_event"); if(IS_TRANSPORT_WIDGET(menuitem) == FALSE){ return FALSE; } @@ -136,20 +145,15 @@ transport_widget_button_press_event (GtkWidget *menuitem, GtkWidget *parent; - // can we block emissions of "grab-notify" on parent?? parent = gtk_widget_get_parent (GTK_WIDGET (menuitem)); - gint result = determine_button_event(priv->play_button, event); - //GTK_OBJECT_FLAGS (scale) |= GTK_HAS_GRAB; - //gtk_widget_event (scale, - //((GdkEvent *)(void*)(event))); - //GTK_OBJECT_FLAGS (scale) &= ~(GTK_HAS_GRAB); + gint result = determine_button_event(priv->play_button, event); GValue value = {0}; g_value_init(&value, G_TYPE_INT); g_debug("TransportWidget::menu_press_event - going to send value %i", result); g_value_set_int(&value, result); - dbusmenu_menuitem_handle_event (twin_item, "Transport state change", &value, 0); + dbusmenu_menuitem_handle_event (priv->twin_item, "Transport state change", &value, 0); return TRUE; } @@ -191,7 +195,8 @@ transport_widget_property_update(DbusmenuMenuitem* item, gchar* property, GtkWidget* transport_widget_new(DbusmenuMenuitem *item) { - twin_item = item; - return g_object_new(TRANSPORT_WIDGET_TYPE, NULL); + GtkWidget* widget = g_object_new(TRANSPORT_WIDGET_TYPE, NULL); + transport_widget_set_twin_item((TransportWidget*)widget, item); + return widget; } |