Example #1
0
/* Update status from all the providers */
static void
update_status (void)
{
	StatusProviderStatus status = STATUS_PROVIDER_STATUS_DISCONNECTED;
	GList * provider;

	for (provider = status_providers; provider != NULL; provider = g_list_next(provider)) {
		StatusProviderStatus localstatus = status_provider_get_status(STATUS_PROVIDER(provider->data));

		if (localstatus < status) {
			status = localstatus;
		}
	}

	if (status == current_status) {
		return;
	}

	current_status = status;

	if (update_func != NULL) {
		update_func();
	}

	GList * menu;
	int i;
	for (menu = menuitems, i = 0; menu != NULL && i < STATUS_PROVIDER_STATUS_DISCONNECTED; menu = g_list_next(menu), i++) {
		/* If we're the seleced status or if we're disconnected
		   show the user that we're offline */
		if (i == current_status || (current_status == STATUS_PROVIDER_STATUS_DISCONNECTED && i == STATUS_PROVIDER_STATUS_OFFLINE)) {
			dbusmenu_menuitem_property_set_int(DBUSMENU_MENUITEM(menu->data), DBUSMENU_MENUITEM_PROP_TOGGLE_STATE, DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED);
		} else {
			dbusmenu_menuitem_property_set_int(DBUSMENU_MENUITEM(menu->data), DBUSMENU_MENUITEM_PROP_TOGGLE_STATE, DBUSMENU_MENUITEM_TOGGLE_STATE_UNCHECKED);
		}

		if (current_status == STATUS_PROVIDER_STATUS_DISCONNECTED) {
			dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(menu->data), DBUSMENU_MENUITEM_PROP_ENABLED, FALSE);
		} else {
			dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(menu->data), DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
		}
	}

	return;
}
/* Draws a triangle on the left, using fg[STATE_TYPE] color. */
static gboolean
application_triangle_draw_cb (GtkWidget *widget, cairo_t *ctx, gpointer data)
{
	int x, y, arrow_width, arrow_height;

	if (!GTK_IS_WIDGET (widget)) return FALSE;
	if (!DBUSMENU_IS_MENUITEM (data)) return FALSE;

	/* render the triangle indicator only if the application is running */
	if (! dbusmenu_menuitem_property_get_bool (DBUSMENU_MENUITEM(data), APPLICATION_MENUITEM_PROP_RUNNING))
		return FALSE;;

	arrow_width = 5; /* the pixel-based reference triangle is 5x9 */
	arrow_height = 9;
	
	/* get style + arrow position */
	double red, green, blue;
	GtkStyleContext *style = gtk_widget_get_style_context (widget);
	GdkRGBA color;
	gtk_style_context_get_color (style, gtk_widget_get_state(widget), &color);
	red = color.red;
	green = color.green;
	blue = color.blue;
	x = 0;  // the context is already translated so that (0;0) is the top-left corner of the widget.
	y = gtk_widget_get_allocated_height (widget)/2.0 - (double)arrow_height/2.0;

	cairo_set_line_width (ctx, 1.0);

	/* cairo drawing code */
	cairo_move_to (ctx, x, y);
	cairo_line_to (ctx, x, y + arrow_height);
	cairo_line_to (ctx, x + arrow_width, y + (double)arrow_height/2.0);
	cairo_close_path (ctx);
	cairo_set_source_rgb (ctx, red, green, blue);
	cairo_fill (ctx);

	return FALSE;
}
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);
}