Esempio n. 1
0
static void
unity_bookmarks_handler_remove_bookmark_quicklists () {

	GList *children, *l;

	/* remove unity quicklist bookmarks to launcher entries */
	for (l = unity_quicklist_get_launcher_entries (unity_quicklist_handler); l; l = l->next) {
		UnityLauncherEntry *entry = l->data;
		DbusmenuMenuitem *ql = unity_launcher_entry_get_quicklist (entry);
		if (!ql)
			break;

		children = dbusmenu_menuitem_get_children (ql);
		while (children) {
			DbusmenuMenuitem *child = children->data;
			children = children->next;
			if (unity_quicklist_handler_menuitem_is_bookmark_item (child)) {
				g_signal_handlers_disconnect_matched (child, G_SIGNAL_MATCH_FUNC, 0, 0, 0, (GCallback) activate_bookmark_by_quicklist, 0);
				dbusmenu_menuitem_child_delete (ql, child);
				g_object_unref(child);
			}
		}
	}
}
static void specific_items_manager_on_root_changed (SpecificItemsManager* self, GObject* newroot) {
	GObject* _tmp0_;
	DbusmenuClient* _tmp19_;
	DbusmenuMenuitem* _tmp20_ = NULL;
	DbusmenuMenuitem* _tmp21_;
	DbusmenuMenuitem* root;
	DbusmenuMenuitem* _tmp22_;
	DbusmenuMenuitem* _tmp23_;
	DbusmenuMenuitem* _tmp24_;
	GList* _tmp25_ = NULL;
	GList* _tmp26_ = NULL;
	GList* children;
	GList* _tmp27_;
	g_return_if_fail (self != NULL);
	_tmp0_ = newroot;
	if (_tmp0_ == NULL) {
		GeeArrayList* _tmp15_;
		GeeArrayList* _tmp16_;
		gint _tmp17_;
		gint _tmp18_;
		g_debug ("specific-items-manager.vala:70: root disappeared -remove proxyitems");
		{
			GeeArrayList* _tmp1_;
			GeeArrayList* _tmp2_;
			GeeArrayList* _p_list;
			GeeArrayList* _tmp3_;
			gint _tmp4_;
			gint _tmp5_;
			gint _p_size;
			gint _p_index;
			_tmp1_ = self->priv->_proxy_items;
			_tmp2_ = _g_object_ref0 (_tmp1_);
			_p_list = _tmp2_;
			_tmp3_ = _p_list;
			_tmp4_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp3_);
			_tmp5_ = _tmp4_;
			_p_size = _tmp5_;
			_p_index = -1;
			while (TRUE) {
				gint _tmp6_;
				gint _tmp7_;
				gint _tmp8_;
				GeeArrayList* _tmp9_;
				gint _tmp10_;
				gpointer _tmp11_ = NULL;
				DbusmenuMenuitemProxy* p;
				PlayerController* _tmp12_;
				DbusmenuMenuitem* _tmp13_;
				DbusmenuMenuitemProxy* _tmp14_;
				_tmp6_ = _p_index;
				_p_index = _tmp6_ + 1;
				_tmp7_ = _p_index;
				_tmp8_ = _p_size;
				if (!(_tmp7_ < _tmp8_)) {
					break;
				}
				_tmp9_ = _p_list;
				_tmp10_ = _p_index;
				_tmp11_ = gee_abstract_list_get ((GeeAbstractList*) _tmp9_, _tmp10_);
				p = (DbusmenuMenuitemProxy*) _tmp11_;
				_tmp12_ = self->priv->_owner;
				_tmp13_ = _tmp12_->root_menu;
				_tmp14_ = p;
				dbusmenu_menuitem_child_delete (_tmp13_, (DbusmenuMenuitem*) _tmp14_);
				_g_object_unref0 (p);
			}
			_g_object_unref0 (_p_list);
		}
		_tmp15_ = self->priv->_proxy_items;
		gee_abstract_collection_clear ((GeeAbstractCollection*) _tmp15_);
		_tmp16_ = self->priv->_proxy_items;
		_tmp17_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp16_);
		_tmp18_ = _tmp17_;
		g_debug ("specific-items-manager.vala:75: array list size is now %i", _tmp18_);
		return;
	}
	_tmp19_ = self->priv->client;
	_tmp20_ = dbusmenu_client_get_root (_tmp19_);
	_tmp21_ = _g_object_ref0 (_tmp20_);
	root = _tmp21_;
	_tmp22_ = root;
	g_signal_connect_object (_tmp22_, "child-added", (GCallback) _specific_items_manager_on_child_added_dbusmenu_menuitem_child_added, self, 0);
	_tmp23_ = root;
	g_signal_connect_object (_tmp23_, "child-removed", (GCallback) _specific_items_manager_on_child_removed_dbusmenu_menuitem_child_removed, self, 0);
	_tmp24_ = root;
	_tmp25_ = dbusmenu_menuitem_get_children (_tmp24_);
	_tmp26_ = g_list_copy (_tmp25_);
	children = _tmp26_;
	_tmp27_ = children;
	{
		GList* child_collection = NULL;
		GList* child_it = NULL;
		child_collection = _tmp27_;
		for (child_it = child_collection; child_it != NULL; child_it = child_it->next) {
			void* child = NULL;
			child = child_it->data;
			{
				gint _tmp28_ = 0;
				gint pos;
				void* _tmp29_;
				DbusmenuMenuitem* item;
				DbusmenuMenuitem* _tmp30_;
				DbusmenuMenuitemProxy* _tmp31_;
				DbusmenuMenuitemProxy* proxy;
				GeeArrayList* _tmp32_;
				DbusmenuMenuitemProxy* _tmp33_;
				DbusmenuMenuitem* _tmp34_;
				const gchar* _tmp35_ = NULL;
				PlayerController* _tmp36_;
				DbusmenuMenuitem* _tmp37_;
				DbusmenuMenuitemProxy* _tmp38_;
				gint _tmp39_;
				_tmp28_ = specific_items_manager_figure_out_positioning (self);
				pos = _tmp28_;
				_tmp29_ = child;
				item = DBUSMENU_MENUITEM (_tmp29_);
				_tmp30_ = item;
				_tmp31_ = dbusmenu_menuitem_proxy_new (_tmp30_);
				proxy = _tmp31_;
				_tmp32_ = self->priv->_proxy_items;
				_tmp33_ = proxy;
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp32_, _tmp33_);
				_tmp34_ = item;
				_tmp35_ = dbusmenu_menuitem_property_get (_tmp34_, DBUSMENU_MENUITEM_PROP_LABEL);
				g_debug ("specific-items-manager.vala:92: Proxy item of label = %s added to coll" \
"ection", _tmp35_);
				_tmp36_ = self->priv->_owner;
				_tmp37_ = _tmp36_->root_menu;
				_tmp38_ = proxy;
				_tmp39_ = pos;
				dbusmenu_menuitem_child_add_position (_tmp37_, (DbusmenuMenuitem*) _tmp38_, (guint) _tmp39_);
				_g_object_unref0 (proxy);
			}
		}
	}
	_g_list_free0 (children);
	_g_object_unref0 (root);
}
void playlists_menuitem_update (PlaylistsMenuitem* self, PlaylistDetails* playlists, int playlists_length1) {
	PlaylistDetails* _tmp0_;
	gint _tmp0__length1;
	g_return_if_fail (self != NULL);
	_tmp0_ = playlists;
	_tmp0__length1 = playlists_length1;
	{
		PlaylistDetails* detail_collection = NULL;
		gint detail_collection_length1 = 0;
		gint _detail_collection_size_ = 0;
		gint detail_it = 0;
		detail_collection = _tmp0_;
		detail_collection_length1 = _tmp0__length1;
		for (detail_it = 0; detail_it < _tmp0__length1; detail_it = detail_it + 1) {
			PlaylistDetails _tmp1_ = {0};
			PlaylistDetails detail = {0};
			playlist_details_copy (&detail_collection[detail_it], &_tmp1_);
			detail = _tmp1_;
			{
				Block2Data* _data2_;
				gboolean _tmp2_ = FALSE;
				PlaylistDetails _tmp3_;
				gboolean _tmp4_ = FALSE;
				gboolean _tmp7_;
				DbusmenuMenuitem* _tmp8_;
				DbusmenuMenuitem* _tmp9_;
				PlaylistDetails _tmp10_;
				const gchar* _tmp11_;
				gchar* _tmp12_ = NULL;
				gchar* _tmp13_;
				DbusmenuMenuitem* _tmp14_;
				DbusmenuMenuitem* _tmp15_;
				PlaylistDetails _tmp16_;
				const char* _tmp17_;
				DbusmenuMenuitem* _tmp18_;
				DbusmenuMenuitem* _tmp19_;
				DbusmenuMenuitem* _tmp20_;
				GeeHashMap* _tmp21_;
				DbusmenuMenuitem* _tmp22_;
				gint _tmp23_;
				gint _tmp24_;
				DbusmenuMenuitem* _tmp25_;
				DbusmenuMenuitem* _tmp26_;
				DbusmenuMenuitem* _tmp27_;
				PlaylistDetails _tmp28_;
				const gchar* _tmp29_;
				_data2_ = g_slice_new0 (Block2Data);
				_data2_->_ref_count_ = 1;
				_data2_->self = g_object_ref (self);
				_tmp3_ = detail;
				_tmp4_ = playlists_menuitem_already_observed (self, &_tmp3_);
				if (_tmp4_) {
					_tmp2_ = TRUE;
				} else {
					PlaylistDetails _tmp5_;
					gboolean _tmp6_ = FALSE;
					_tmp5_ = detail;
					_tmp6_ = playlists_menuitem_is_video_related (self, &_tmp5_);
					_tmp2_ = _tmp6_;
				}
				_tmp7_ = _tmp2_;
				if (_tmp7_) {
					playlist_details_destroy (&detail);
					block2_data_unref (_data2_);
					_data2_ = NULL;
					continue;
				}
				_tmp8_ = dbusmenu_menuitem_new ();
				_data2_->menuitem = _tmp8_;
				_tmp9_ = _data2_->menuitem;
				_tmp10_ = detail;
				_tmp11_ = _tmp10_.name;
				_tmp12_ = playlists_menuitem_truncate_item_label_if_needs_be (self, _tmp11_);
				_tmp13_ = _tmp12_;
				dbusmenu_menuitem_property_set (_tmp9_, DBUSMENU_MENUITEM_PROP_LABEL, _tmp13_);
				_g_free0 (_tmp13_);
				_tmp14_ = _data2_->menuitem;
				dbusmenu_menuitem_property_set (_tmp14_, DBUSMENU_MENUITEM_PROP_ICON_NAME, "playlist-symbolic");
				_tmp15_ = _data2_->menuitem;
				_tmp16_ = detail;
				_tmp17_ = _tmp16_.path;
				dbusmenu_menuitem_property_set (_tmp15_, DBUSMENU_PLAYLIST_MENUITEM_PATH, (const gchar*) _tmp17_);
				_tmp18_ = _data2_->menuitem;
				dbusmenu_menuitem_property_set_bool (_tmp18_, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
				_tmp19_ = _data2_->menuitem;
				dbusmenu_menuitem_property_set_bool (_tmp19_, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
				_tmp20_ = _data2_->menuitem;
				g_signal_connect_data (_tmp20_, "item-activated", (GCallback) _____lambda3__dbusmenu_menuitem_item_activated, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
				_tmp21_ = self->priv->current_playlists;
				_tmp22_ = _data2_->menuitem;
				_tmp23_ = dbusmenu_menuitem_get_id (_tmp22_);
				_tmp24_ = _tmp23_;
				_tmp25_ = _data2_->menuitem;
				gee_abstract_map_set ((GeeAbstractMap*) _tmp21_, GINT_TO_POINTER (_tmp24_), _tmp25_);
				_tmp26_ = self->root_item;
				_tmp27_ = _data2_->menuitem;
				dbusmenu_menuitem_child_append (_tmp26_, _tmp27_);
				_tmp28_ = detail;
				_tmp29_ = _tmp28_.name;
				g_debug ("playlists-menu-item.vala:66: populating valid playlists %s", _tmp29_);
				playlist_details_destroy (&detail);
				block2_data_unref (_data2_);
				_data2_ = NULL;
			}
		}
	}
	{
		GeeHashMap* _tmp30_;
		GeeCollection* _tmp31_;
		GeeCollection* _tmp32_;
		GeeCollection* _tmp33_;
		GeeIterator* _tmp34_ = NULL;
		GeeIterator* _tmp35_;
		GeeIterator* _item_it;
		_tmp30_ = self->priv->current_playlists;
		_tmp31_ = gee_abstract_map_get_values ((GeeMap*) _tmp30_);
		_tmp32_ = _tmp31_;
		_tmp33_ = _tmp32_;
		_tmp34_ = gee_iterable_iterator ((GeeIterable*) _tmp33_);
		_tmp35_ = _tmp34_;
		_g_object_unref0 (_tmp33_);
		_item_it = _tmp35_;
		while (TRUE) {
			GeeIterator* _tmp36_;
			gboolean _tmp37_ = FALSE;
			GeeIterator* _tmp38_;
			gpointer _tmp39_ = NULL;
			DbusmenuMenuitem* item;
			gboolean within;
			PlaylistDetails* _tmp40_;
			gint _tmp40__length1;
			gboolean _tmp46_;
			_tmp36_ = _item_it;
			_tmp37_ = gee_iterator_next (_tmp36_);
			if (!_tmp37_) {
				break;
			}
			_tmp38_ = _item_it;
			_tmp39_ = gee_iterator_get (_tmp38_);
			item = (DbusmenuMenuitem*) _tmp39_;
			within = FALSE;
			_tmp40_ = playlists;
			_tmp40__length1 = playlists_length1;
			{
				PlaylistDetails* detail_collection = NULL;
				gint detail_collection_length1 = 0;
				gint _detail_collection_size_ = 0;
				gint detail_it = 0;
				detail_collection = _tmp40_;
				detail_collection_length1 = _tmp40__length1;
				for (detail_it = 0; detail_it < _tmp40__length1; detail_it = detail_it + 1) {
					PlaylistDetails _tmp41_ = {0};
					PlaylistDetails detail = {0};
					playlist_details_copy (&detail_collection[detail_it], &_tmp41_);
					detail = _tmp41_;
					{
						PlaylistDetails _tmp42_;
						const char* _tmp43_;
						DbusmenuMenuitem* _tmp44_;
						const gchar* _tmp45_ = NULL;
						_tmp42_ = detail;
						_tmp43_ = _tmp42_.path;
						_tmp44_ = item;
						_tmp45_ = dbusmenu_menuitem_property_get (_tmp44_, DBUSMENU_PLAYLIST_MENUITEM_PATH);
						if (g_strcmp0 (_tmp43_, _tmp45_) == 0) {
							within = TRUE;
							playlist_details_destroy (&detail);
							break;
						}
						playlist_details_destroy (&detail);
					}
				}
			}
			_tmp46_ = within;
			if (_tmp46_ == FALSE) {
				DbusmenuMenuitem* _tmp47_;
				const gchar* _tmp48_ = NULL;
				DbusmenuMenuitem* _tmp49_;
				const gchar* _tmp50_ = NULL;
				DbusmenuMenuitem* _tmp53_;
				DbusmenuMenuitem* _tmp54_;
				_tmp47_ = self->root_item;
				_tmp48_ = dbusmenu_menuitem_property_get (_tmp47_, DBUSMENU_PLAYLIST_MENUITEM_PATH);
				_tmp49_ = item;
				_tmp50_ = dbusmenu_menuitem_property_get (_tmp49_, DBUSMENU_PLAYLIST_MENUITEM_PATH);
				if (g_strcmp0 (_tmp48_, _tmp50_) == 0) {
					DbusmenuMenuitem* _tmp51_;
					const gchar* _tmp52_ = NULL;
					_tmp51_ = self->root_item;
					_tmp52_ = _ ("Choose Playlist");
					dbusmenu_menuitem_property_set (_tmp51_, DBUSMENU_MENUITEM_PROP_LABEL, _tmp52_);
				}
				_tmp53_ = self->root_item;
				_tmp54_ = item;
				dbusmenu_menuitem_child_delete (_tmp53_, _tmp54_);
			}
			_g_object_unref0 (item);
		}
		_g_object_unref0 (_item_it);
	}
}
void removeMenuItem(DbusmenuMenuitem * parent, DbusmenuMenuitem* item) { dbusmenu_menuitem_child_delete(parent, item); }
/* Builds a menu item representing a running application in the
   messaging menu */
static gboolean
new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client)
{
	gchar *cName = g_strdup (dbusmenu_menuitem_property_get(newitem, APPLICATION_MENUITEM_PROP_NAME));
	const gchar *sIconName = dbusmenu_menuitem_property_get (newitem, APPLICATION_MENUITEM_PROP_ICON);

	cd_debug ("%s (\"%s\")", __func__, cName);

#ifdef FORCE_REMOVE_DOUBLE_ENTRIES
#if (INDICATOR_OLD_NAMES == 0)
	if (newitem == NULL || !dbusmenu_menuitem_property_get_bool(newitem, DBUSMENU_MENUITEM_PROP_VISIBLE)
		#if INDICATOR_MESSAGES_HAS_LOZENGE == 1
		&& sIconName != NULL && *sIconName != '\0' // these menu 
		#endif
		)
	{
		dbusmenu_menuitem_child_delete (parent, newitem);
		cd_debug ("Not visible: %s", cName);
		g_free (cName);
		return TRUE;
	}
#endif
#endif

	GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_image_menu_item_new());

	gint padding = 4;
	gtk_widget_style_get(GTK_WIDGET(gmi), "toggle-spacing", &padding, NULL);

	GtkWidget * hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, padding);

	// Added for Cairo-Dock
	#if INDICATOR_MESSAGES_HAS_LOZENGE == 1 // we add a left margin
	if (! dbusmenu_menuitem_property_get_bool(newitem, DBUSMENU_MENUITEM_PROP_VISIBLE)
		&& (sIconName == NULL || *sIconName == '\0'))
	{
		gint width, height;
		gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height);
		gtk_widget_set_size_request(GTK_WIDGET (gmi), -1, height + 4);
		gtk_widget_set_margin_left (hbox, width + padding);
	}
	#endif
	// end

	GtkWidget * icon = gtk_image_new_from_icon_name(sIconName, GTK_ICON_SIZE_MENU);
	gtk_misc_set_alignment(GTK_MISC(icon), 1.0 /* right aligned */, 0.5);
	gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);

	/* Application name in a label */
	GtkWidget * label = gtk_label_new(cName);
	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
	gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);

	gtk_container_add(GTK_CONTAINER(gmi), hbox);
	gtk_widget_show_all (GTK_WIDGET (gmi));

	/* Attach some of the standard GTK stuff */
	dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent);

	/* Make sure we can handle the label changing */
	g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(application_prop_change_cb), label);
	g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(application_icon_change_cb), icon);
	g_signal_connect_after(G_OBJECT (gmi), "draw", G_CALLBACK (application_triangle_draw_cb), newitem);

	g_free (cName);

	return TRUE;
}