/* specific-items-manager.c generated by valac 0.12.1, the Vala compiler * generated from specific-items-manager.vala, do not modify */ /* Copyright 2011 Canonical Ltd. Authors: Conor Curran This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include #include #include #include #include #include #include #include #include #include #include #include #define TYPE_SPECIFIC_ITEMS_MANAGER (specific_items_manager_get_type ()) #define SPECIFIC_ITEMS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SPECIFIC_ITEMS_MANAGER, SpecificItemsManager)) #define SPECIFIC_ITEMS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SPECIFIC_ITEMS_MANAGER, SpecificItemsManagerClass)) #define IS_SPECIFIC_ITEMS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SPECIFIC_ITEMS_MANAGER)) #define IS_SPECIFIC_ITEMS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SPECIFIC_ITEMS_MANAGER)) #define SPECIFIC_ITEMS_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SPECIFIC_ITEMS_MANAGER, SpecificItemsManagerClass)) typedef struct _SpecificItemsManager SpecificItemsManager; typedef struct _SpecificItemsManagerClass SpecificItemsManagerClass; typedef struct _SpecificItemsManagerPrivate SpecificItemsManagerPrivate; #define TYPE_PLAYER_CONTROLLER (player_controller_get_type ()) #define PLAYER_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PLAYER_CONTROLLER, PlayerController)) #define PLAYER_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PLAYER_CONTROLLER, PlayerControllerClass)) #define IS_PLAYER_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PLAYER_CONTROLLER)) #define IS_PLAYER_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PLAYER_CONTROLLER)) #define PLAYER_CONTROLLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PLAYER_CONTROLLER, PlayerControllerClass)) typedef struct _PlayerController PlayerController; typedef struct _PlayerControllerClass PlayerControllerClass; #define SPECIFIC_ITEMS_MANAGER_TYPE_CATEGORY (specific_items_manager_category_get_type ()) #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) #define _g_free0(var) (var = (g_free (var), NULL)) typedef struct _PlayerControllerPrivate PlayerControllerPrivate; #define TYPE_PLAYER_ITEM (player_item_get_type ()) #define PLAYER_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PLAYER_ITEM, PlayerItem)) #define PLAYER_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PLAYER_ITEM, PlayerItemClass)) #define IS_PLAYER_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PLAYER_ITEM)) #define IS_PLAYER_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PLAYER_ITEM)) #define PLAYER_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PLAYER_ITEM, PlayerItemClass)) typedef struct _PlayerItem PlayerItem; typedef struct _PlayerItemClass PlayerItemClass; #define TYPE_MPRIS2_CONTROLLER (mpris2_controller_get_type ()) #define MPRIS2_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MPRIS2_CONTROLLER, Mpris2Controller)) #define MPRIS2_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MPRIS2_CONTROLLER, Mpris2ControllerClass)) #define IS_MPRIS2_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MPRIS2_CONTROLLER)) #define IS_MPRIS2_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MPRIS2_CONTROLLER)) #define MPRIS2_CONTROLLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MPRIS2_CONTROLLER, Mpris2ControllerClass)) typedef struct _Mpris2Controller Mpris2Controller; typedef struct _Mpris2ControllerClass Mpris2ControllerClass; #define _g_list_free0(var) ((var == NULL) ? NULL : (var = (g_list_free (var), NULL))) struct _SpecificItemsManager { GObject parent_instance; SpecificItemsManagerPrivate * priv; }; struct _SpecificItemsManagerClass { GObjectClass parent_class; }; struct _SpecificItemsManagerPrivate { PlayerController* _owner; gchar* dbus_path; DbusmenuClient* client; GeeArrayList* _proxy_items; gint of_type; }; typedef enum { SPECIFIC_ITEMS_MANAGER_CATEGORY_TRACK, SPECIFIC_ITEMS_MANAGER_CATEGORY_PLAYER } SpecificItemsManagercategory; struct _PlayerController { GObject parent_instance; PlayerControllerPrivate * priv; gint current_state; DbusmenuMenuitem* root_menu; GeeArrayList* custom_items; Mpris2Controller* mpris_bridge; gboolean* use_playlists; }; struct _PlayerControllerClass { GObjectClass parent_class; }; static gpointer specific_items_manager_parent_class = NULL; GType specific_items_manager_get_type (void) G_GNUC_CONST; GType player_controller_get_type (void) G_GNUC_CONST; #define SPECIFIC_ITEMS_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_SPECIFIC_ITEMS_MANAGER, SpecificItemsManagerPrivate)) enum { SPECIFIC_ITEMS_MANAGER_DUMMY_PROPERTY, SPECIFIC_ITEMS_MANAGER_PROXY_ITEMS }; GType specific_items_manager_category_get_type (void) G_GNUC_CONST; SpecificItemsManager* specific_items_manager_new (PlayerController* controller, const gchar* path, SpecificItemsManagercategory which_type); SpecificItemsManager* specific_items_manager_construct (GType object_type, PlayerController* controller, const gchar* path, SpecificItemsManagercategory which_type); static void specific_items_manager_set_owner (SpecificItemsManager* self, PlayerController* value); static PlayerController* specific_items_manager_get_owner (SpecificItemsManager* self); const gchar* player_controller_get_dbus_name (PlayerController* self); static void specific_items_manager_on_root_changed (SpecificItemsManager* self, GObject* newroot); static void _specific_items_manager_on_root_changed_dbusmenu_client_root_changed (DbusmenuClient* _sender, GObject* newroot, gpointer self); static gint specific_items_manager_figure_out_positioning (SpecificItemsManager* self); gint player_controller_get_menu_offset (PlayerController* self); #define PLAYER_CONTROLLER_WIDGET_QUANTITY 4 GeeArrayList* specific_items_manager_get_proxy_items (SpecificItemsManager* self); gint player_controller_track_specific_count (PlayerController* self); GType player_item_get_type (void) G_GNUC_CONST; GType mpris2_controller_get_type (void) G_GNUC_CONST; static gboolean _bool_equal (const gboolean* s1, const gboolean* s2); static void specific_items_manager_on_child_added (SpecificItemsManager* self, GObject* child, guint position); static void _specific_items_manager_on_child_added_dbusmenu_menuitem_child_added (DbusmenuMenuitem* _sender, GObject* child, guint position, gpointer self); static void specific_items_manager_on_child_removed (SpecificItemsManager* self, GObject* child); static void _specific_items_manager_on_child_removed_dbusmenu_menuitem_child_removed (DbusmenuMenuitem* _sender, GObject* child, gpointer self); static void specific_items_manager_set_proxy_items (SpecificItemsManager* self, GeeArrayList* value); static GObject * specific_items_manager_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties); static void specific_items_manager_finalize (GObject* obj); static void _vala_specific_items_manager_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); static void _vala_specific_items_manager_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec); GType specific_items_manager_category_get_type (void) { static volatile gsize specific_items_manager_category_type_id__volatile = 0; if (g_once_init_enter (&specific_items_manager_category_type_id__volatile)) { static const GEnumValue values[] = {{SPECIFIC_ITEMS_MANAGER_CATEGORY_TRACK, "SPECIFIC_ITEMS_MANAGER_CATEGORY_TRACK", "track"}, {SPECIFIC_ITEMS_MANAGER_CATEGORY_PLAYER, "SPECIFIC_ITEMS_MANAGER_CATEGORY_PLAYER", "player"}, {0, NULL, NULL}}; GType specific_items_manager_category_type_id; specific_items_manager_category_type_id = g_enum_register_static ("SpecificItemsManagercategory", values); g_once_init_leave (&specific_items_manager_category_type_id__volatile, specific_items_manager_category_type_id); } return specific_items_manager_category_type_id__volatile; } static void _specific_items_manager_on_root_changed_dbusmenu_client_root_changed (DbusmenuClient* _sender, GObject* newroot, gpointer self) { specific_items_manager_on_root_changed (self, newroot); } SpecificItemsManager* specific_items_manager_construct (GType object_type, PlayerController* controller, const gchar* path, SpecificItemsManagercategory which_type) { SpecificItemsManager * self = NULL; gchar* _tmp0_; const gchar* _tmp1_ = NULL; DbusmenuClient* _tmp2_ = NULL; g_return_val_if_fail (controller != NULL, NULL); g_return_val_if_fail (path != NULL, NULL); self = (SpecificItemsManager*) g_object_new (object_type, NULL); self->priv->of_type = (gint) which_type; specific_items_manager_set_owner (self, controller); _tmp0_ = g_strdup (path); _g_free0 (self->priv->dbus_path); self->priv->dbus_path = _tmp0_; _tmp1_ = player_controller_get_dbus_name (self->priv->_owner); _tmp2_ = dbusmenu_client_new (_tmp1_, self->priv->dbus_path); _g_object_unref0 (self->priv->client); self->priv->client = _tmp2_; g_signal_connect_object (self->priv->client, "root-changed", (GCallback) _specific_items_manager_on_root_changed_dbusmenu_client_root_changed, self, 0); return self; } SpecificItemsManager* specific_items_manager_new (PlayerController* controller, const gchar* path, SpecificItemsManagercategory which_type) { return specific_items_manager_construct (TYPE_SPECIFIC_ITEMS_MANAGER, controller, path, which_type); } static gboolean _bool_equal (const gboolean* s1, const gboolean* s2) { if (s1 == s2) { return TRUE; } if (s1 == NULL) { return FALSE; } if (s2 == NULL) { return FALSE; } return (*s1) == (*s2); } static gint specific_items_manager_figure_out_positioning (SpecificItemsManager* self) { gint result = 0; gint _result_; g_return_val_if_fail (self != NULL, 0); _result_ = 0; if (self->priv->of_type == SPECIFIC_ITEMS_MANAGER_CATEGORY_TRACK) { gint _tmp0_; gint _tmp1_; _tmp0_ = player_controller_get_menu_offset (self->priv->_owner); _tmp1_ = gee_collection_get_size ((GeeCollection*) self->priv->_proxy_items); _result_ = (_tmp0_ + PLAYER_CONTROLLER_WIDGET_QUANTITY) + _tmp1_; } else { if (self->priv->of_type == SPECIFIC_ITEMS_MANAGER_CATEGORY_PLAYER) { gint _tmp2_; gint _tmp3_; gint pos; gint _tmp4_ = 0; gboolean _tmp5_; _tmp2_ = player_controller_get_menu_offset (self->priv->_owner); _tmp3_ = player_controller_track_specific_count (self->priv->_owner); pos = (_tmp2_ + PLAYER_CONTROLLER_WIDGET_QUANTITY) + _tmp3_; _tmp5_ = TRUE; if (_bool_equal (self->priv->_owner->use_playlists, &_tmp5_) == TRUE) { _tmp4_ = 1; } else { _tmp4_ = 0; } pos = pos + _tmp4_; _result_ = pos; } } g_debug ("specific-items-manager.vala:63: !!!!! Menu pos of type %i is = %i", self->priv->of_type, _result_); result = _result_; return result; } static gpointer _g_object_ref0 (gpointer self) { return self ? g_object_ref (self) : NULL; } static void _specific_items_manager_on_child_added_dbusmenu_menuitem_child_added (DbusmenuMenuitem* _sender, GObject* child, guint position, gpointer self) { specific_items_manager_on_child_added (self, child, position); } static void _specific_items_manager_on_child_removed_dbusmenu_menuitem_child_removed (DbusmenuMenuitem* _sender, GObject* child, gpointer self) { specific_items_manager_on_child_removed (self, child); } static void specific_items_manager_on_root_changed (SpecificItemsManager* self, GObject* newroot) { DbusmenuMenuitem* _tmp4_ = NULL; DbusmenuMenuitem* _tmp5_; DbusmenuMenuitem* root; GList* _tmp6_ = NULL; GList* _tmp7_ = NULL; GList* children; g_return_if_fail (self != NULL); if (newroot == NULL) { gint _tmp3_; g_debug ("specific-items-manager.vala:70: root disappeared -remove proxyitems"); { GeeArrayList* _tmp0_; GeeArrayList* _p_list; gint _tmp1_; gint _p_size; gint _p_index; _tmp0_ = _g_object_ref0 (self->priv->_proxy_items); _p_list = _tmp0_; _tmp1_ = gee_collection_get_size ((GeeCollection*) _p_list); _p_size = _tmp1_; _p_index = -1; while (TRUE) { gpointer _tmp2_ = NULL; DbusmenuMenuitemProxy* p; _p_index = _p_index + 1; if (!(_p_index < _p_size)) { break; } _tmp2_ = gee_abstract_list_get ((GeeAbstractList*) _p_list, _p_index); p = (DbusmenuMenuitemProxy*) _tmp2_; dbusmenu_menuitem_child_delete (self->priv->_owner->root_menu, (DbusmenuMenuitem*) p); _g_object_unref0 (p); } _g_object_unref0 (_p_list); } gee_abstract_collection_clear ((GeeAbstractCollection*) self->priv->_proxy_items); _tmp3_ = gee_collection_get_size ((GeeCollection*) self->priv->_proxy_items); g_debug ("specific-items-manager.vala:75: array list size is now %i", _tmp3_); return; } _tmp4_ = dbusmenu_client_get_root (self->priv->client); _tmp5_ = _g_object_ref0 (_tmp4_); root = _tmp5_; g_signal_connect_object (root, "child-added", (GCallback) _specific_items_manager_on_child_added_dbusmenu_menuitem_child_added, self, 0); g_signal_connect_object (root, "child-removed", (GCallback) _specific_items_manager_on_child_removed_dbusmenu_menuitem_child_removed, self, 0); _tmp6_ = dbusmenu_menuitem_get_children (root); _tmp7_ = g_list_copy (_tmp6_); children = _tmp7_; { GList* child_collection; GList* child_it; child_collection = children; for (child_it = child_collection; child_it != NULL; child_it = child_it->next) { void* child; child = child_it->data; { gint _tmp8_; gint pos; DbusmenuMenuitem* item; DbusmenuMenuitemProxy* _tmp9_ = NULL; DbusmenuMenuitemProxy* proxy; const gchar* _tmp10_ = NULL; _tmp8_ = specific_items_manager_figure_out_positioning (self); pos = _tmp8_; item = DBUSMENU_MENUITEM (child); _tmp9_ = dbusmenu_menuitem_proxy_new (item); proxy = _tmp9_; gee_abstract_collection_add ((GeeAbstractCollection*) self->priv->_proxy_items, proxy); _tmp10_ = dbusmenu_menuitem_property_get (item, DBUSMENU_MENUITEM_PROP_LABEL); g_debug ("specific-items-manager.vala:92: Proxy item of label = %s added to coll" \ "ection", _tmp10_); dbusmenu_menuitem_child_add_position (self->priv->_owner->root_menu, (DbusmenuMenuitem*) proxy, (guint) pos); _g_object_unref0 (proxy); } } } _g_list_free0 (children); _g_object_unref0 (root); } static void specific_items_manager_on_child_added (SpecificItemsManager* self, GObject* child, guint position) { g_return_if_fail (self != NULL); g_return_if_fail (child != NULL); g_debug ("specific-items-manager.vala:101: On child added Specific root node"); } static void specific_items_manager_on_child_removed (SpecificItemsManager* self, GObject* child) { g_return_if_fail (self != NULL); g_return_if_fail (child != NULL); g_debug ("specific-items-manager.vala:106: On child removed Specific root node"); } static PlayerController* specific_items_manager_get_owner (SpecificItemsManager* self) { PlayerController* result; g_return_val_if_fail (self != NULL, NULL); result = self->priv->_owner; return result; } static void specific_items_manager_set_owner (SpecificItemsManager* self, PlayerController* value) { PlayerController* _tmp0_; g_return_if_fail (self != NULL); _tmp0_ = _g_object_ref0 (value); _g_object_unref0 (self->priv->_owner); self->priv->_owner = _tmp0_; } GeeArrayList* specific_items_manager_get_proxy_items (SpecificItemsManager* self) { GeeArrayList* result; g_return_val_if_fail (self != NULL, NULL); result = self->priv->_proxy_items; return result; } static void specific_items_manager_set_proxy_items (SpecificItemsManager* self, GeeArrayList* value) { GeeArrayList* _tmp0_; g_return_if_fail (self != NULL); _tmp0_ = _g_object_ref0 (value); _g_object_unref0 (self->priv->_proxy_items); self->priv->_proxy_items = _tmp0_; g_object_notify ((GObject *) self, "proxy-items"); } static GObject * specific_items_manager_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) { GObject * obj; GObjectClass * parent_class; SpecificItemsManager * self; GeeArrayList* _tmp0_ = NULL; GeeArrayList* _tmp1_; parent_class = G_OBJECT_CLASS (specific_items_manager_parent_class); obj = parent_class->constructor (type, n_construct_properties, construct_properties); self = SPECIFIC_ITEMS_MANAGER (obj); _tmp0_ = gee_array_list_new (DBUSMENU_TYPE_MENUITEM_PROXY, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL); _tmp1_ = _tmp0_; specific_items_manager_set_proxy_items (self, _tmp1_); _g_object_unref0 (_tmp1_); return obj; } static void specific_items_manager_class_init (SpecificItemsManagerClass * klass) { specific_items_manager_parent_class = g_type_class_peek_parent (klass); g_type_class_add_private (klass, sizeof (SpecificItemsManagerPrivate)); G_OBJECT_CLASS (klass)->get_property = _vala_specific_items_manager_get_property; G_OBJECT_CLASS (klass)->set_property = _vala_specific_items_manager_set_property; G_OBJECT_CLASS (klass)->constructor = specific_items_manager_constructor; G_OBJECT_CLASS (klass)->finalize = specific_items_manager_finalize; g_object_class_install_property (G_OBJECT_CLASS (klass), SPECIFIC_ITEMS_MANAGER_PROXY_ITEMS, g_param_spec_object ("proxy-items", "proxy-items", "proxy-items", GEE_TYPE_ARRAY_LIST, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); } static void specific_items_manager_instance_init (SpecificItemsManager * self) { self->priv = SPECIFIC_ITEMS_MANAGER_GET_PRIVATE (self); } static void specific_items_manager_finalize (GObject* obj) { SpecificItemsManager * self; self = SPECIFIC_ITEMS_MANAGER (obj); _g_object_unref0 (self->priv->_owner); _g_free0 (self->priv->dbus_path); _g_object_unref0 (self->priv->client); _g_object_unref0 (self->priv->_proxy_items); G_OBJECT_CLASS (specific_items_manager_parent_class)->finalize (obj); } GType specific_items_manager_get_type (void) { static volatile gsize specific_items_manager_type_id__volatile = 0; if (g_once_init_enter (&specific_items_manager_type_id__volatile)) { static const GTypeInfo g_define_type_info = { sizeof (SpecificItemsManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) specific_items_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SpecificItemsManager), 0, (GInstanceInitFunc) specific_items_manager_instance_init, NULL }; GType specific_items_manager_type_id; specific_items_manager_type_id = g_type_register_static (G_TYPE_OBJECT, "SpecificItemsManager", &g_define_type_info, 0); g_once_init_leave (&specific_items_manager_type_id__volatile, specific_items_manager_type_id); } return specific_items_manager_type_id__volatile; } static void _vala_specific_items_manager_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { SpecificItemsManager * self; self = SPECIFIC_ITEMS_MANAGER (object); switch (property_id) { case SPECIFIC_ITEMS_MANAGER_PROXY_ITEMS: g_value_set_object (value, specific_items_manager_get_proxy_items (self)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } } static void _vala_specific_items_manager_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) { SpecificItemsManager * self; self = SPECIFIC_ITEMS_MANAGER (object); switch (property_id) { case SPECIFIC_ITEMS_MANAGER_PROXY_ITEMS: specific_items_manager_set_proxy_items (self, g_value_get_object (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } }