Exemplo n.º 1
0
static DbusmenuMenuitem *
progress_ui_handler_build_unity_quicklist (NemoProgressUIHandler *self)
{
	g_return_if_fail (self);
	GList *l;

	for (l = unity_quicklist_get_launcher_entries (self->priv->unity_quicklist_handler); l; l = l->next) {
		UnityLauncherEntry *entry = l->data;

		DbusmenuMenuitem *quickmenu = dbusmenu_menuitem_new ();
		dbusmenu_menuitem_property_set (quickmenu,
		                                DBUSMENU_MENUITEM_PROP_LABEL,
			                            UNITY_QUICKLIST_SHOW_COPY_DIALOG);
		dbusmenu_menuitem_property_set_bool (quickmenu,
		                                     DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
		unity_quicklist_handler_append_menuitem (entry, quickmenu);
		g_signal_connect (quickmenu, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
		                  (GCallback) progress_ui_handler_unity_quicklist_show_activated,
			              self);

		quickmenu = dbusmenu_menuitem_new ();
		dbusmenu_menuitem_property_set (quickmenu,
			                            DBUSMENU_MENUITEM_PROP_LABEL,
				                        UNITY_QUICKLIST_CANCEL_COPY);
		dbusmenu_menuitem_property_set_bool (quickmenu,
		                                     DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
		unity_quicklist_handler_append_menuitem (entry, quickmenu);
		g_signal_connect (quickmenu, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
		                  (GCallback) progress_ui_handler_unity_quicklist_cancel_activated,
			              self);
	}
}
Exemplo n.º 2
0
/* Build the inital status items and start kicking off the async code
   for handling all the statuses */
GList *
status_items_build (StatusUpdateFunc status_update_func)
{
	int i;
	for (i = STATUS_PROVIDER_STATUS_ONLINE; i < STATUS_PROVIDER_STATUS_DISCONNECTED; i++) {
		DbusmenuMenuitem * item = dbusmenu_menuitem_new();

		dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_LABEL, _(status_strings[i]));
		dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_ICON_NAME, status_icons[i]);

		dbusmenu_menuitem_property_set_bool(item, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
		dbusmenu_menuitem_property_set_bool(item, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE);

		dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE, DBUSMENU_MENUITEM_TOGGLE_RADIO);
		dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_TOGGLE_STATE, DBUSMENU_MENUITEM_TOGGLE_STATE_UNCHECKED);

		g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(user_status_change), GINT_TO_POINTER(i));

		menuitems = g_list_append(menuitems, item);
	}

	update_func = status_update_func;

	const gchar * status_providers_env = g_getenv("INDICATOR_MESSAGES_STATUS_PROVIDER_DIR");
	if (status_providers_env == NULL) {
		g_idle_add(provider_directory_parse, STATUS_PROVIDER_DIR);
	} else {
		g_idle_add(provider_directory_parse, (gpointer)status_providers_env);
	}

	return menuitems;
}
static GObject * playlists_menuitem_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	PlaylistsMenuitem * self;
	GeeHashMap* _tmp0_;
	DbusmenuMenuitem* _tmp1_;
	DbusmenuMenuitem* _tmp2_;
	const gchar* _tmp3_ = NULL;
	DbusmenuMenuitem* _tmp4_;
	parent_class = G_OBJECT_CLASS (playlists_menuitem_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = PLAYLISTS_MENUITEM (obj);
	_tmp0_ = gee_hash_map_new (G_TYPE_INT, NULL, NULL, dbusmenu_menuitem_get_type (), (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->current_playlists);
	self->priv->current_playlists = _tmp0_;
	_tmp1_ = dbusmenu_menuitem_new ();
	_g_object_unref0 (self->root_item);
	self->root_item = _tmp1_;
	_tmp2_ = self->root_item;
	_tmp3_ = _ ("Choose Playlist");
	dbusmenu_menuitem_property_set (_tmp2_, DBUSMENU_MENUITEM_PROP_LABEL, _tmp3_);
	_tmp4_ = self->root_item;
	dbusmenu_menuitem_property_set (_tmp4_, DBUSMENU_PLAYLIST_MENUITEM_PATH, "");
	return obj;
}
DbusmenuMenuitem *addMenuItem(DbusmenuMenuitem *parent, int uid, const char * label, int type, int position) {
  // _logmsg(LOG_LEVEL_INFO, "add menu item %s (%d) [p %s]", label, uid, _getItemLabel(parent));

  DbusmenuMenuitem *item = dbusmenu_menuitem_new();

  dbusmenu_menuitem_property_set_int(item, MENUITEM_UID_PROPERTY, uid);
  dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_LABEL, label);
  if (type == ITEM_SUBMENU)
    dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY, DBUSMENU_MENUITEM_CHILD_DISPLAY_SUBMENU);
  else if (type == ITEM_CHECK)
    dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE, DBUSMENU_MENUITEM_TOGGLE_CHECK);
  else if (type == ITEM_RADIO)
    dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE, DBUSMENU_MENUITEM_TOGGLE_RADIO);

  dbusmenu_menuitem_property_set_bool(item, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);

  g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_EVENT, G_CALLBACK(_onItemEvent), NULL);
  g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_ABOUT_TO_SHOW, G_CALLBACK(_onItemAboutToShow), NULL);
  // g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_SHOW_TO_USER, G_CALLBACK(_onItemShowToUser), NULL);
  g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(_onItemActivated), NULL);
  // g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_CHILD_ADDED, G_CALLBACK(_onItemChildAdded), NULL);

  if (parent != NULL) {
    gpointer data = g_object_get_data(G_OBJECT(parent), MENUITEM_JHANDLER_PROPERTY);
    if (data == NULL)
      _logmsg(LOG_LEVEL_ERROR, "parent of item %d hasn't jhandler", uid);
    g_object_set_data(G_OBJECT(item), MENUITEM_JHANDLER_PROPERTY, data);
    if (position < 0)
      dbusmenu_menuitem_child_append(parent, item);
    else
      dbusmenu_menuitem_child_add_position(parent, item, (guint)position);
  }

  return item;
}
Exemplo n.º 5
0
static void
unity_bookmarks_handler_update_bookmarks () {

	NemoBookmark *bookmark;
	guint bookmark_count;
	guint index;
	GList *l;

	/* append new set of bookmarks */
	bookmark_count = nemo_bookmark_list_length (bookmarks);
	for (index = 0; index < bookmark_count; ++index) {

		bookmark = nemo_bookmark_list_item_at (bookmarks, index);

		if (nemo_bookmark_uri_known_not_to_exist (bookmark)) {
			continue;
		}

		for (l = unity_quicklist_get_launcher_entries (unity_quicklist_handler); l; l = l->next) {
			UnityLauncherEntry *entry = l->data;

			DbusmenuMenuitem* menuitem = dbusmenu_menuitem_new();
			gchar *bookmark_name_dbusmenu = eel_str_replace_substring (nemo_bookmark_get_name (bookmark), "_", "__");
			dbusmenu_menuitem_property_set (menuitem, "label", bookmark_name_dbusmenu);
			g_free (bookmark_name_dbusmenu);
			g_signal_connect (menuitem, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
										 (GCallback) activate_bookmark_by_quicklist,
										 bookmark);

			unity_quicklist_handler_append_menuitem (entry, menuitem);
		}
	}
}
static GObject * metadata_menuitem_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	MetadataMenuitem * self;
	gchar* _tmp0_ = NULL;
	PlayerController* _tmp1_;
	PlayerController* _tmp2_;
	GAppInfo* _tmp3_;
	GAppInfo* _tmp4_;
	const gchar* _tmp5_ = NULL;
	PlayerController* _tmp6_;
	PlayerController* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	GeeHashSet* _tmp10_ = NULL;
	GeeHashSet* _tmp11_;
	parent_class = G_OBJECT_CLASS (metadata_menuitem_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = METADATA_MENUITEM (obj);
	metadata_menuitem_clean_album_art_temp_dir ();
	_g_free0 (self->priv->previous_temp_album_art_path);
	self->priv->previous_temp_album_art_path = NULL;
	_tmp0_ = metadata_menuitem_create_album_art_temp_dir ();
	_g_free0 (metadata_menuitem_album_art_cache_dir);
	metadata_menuitem_album_art_cache_dir = _tmp0_;
	_tmp1_ = player_item_get_owner ((PlayerItem*) self);
	_tmp2_ = _tmp1_;
	_tmp3_ = player_controller_get_app_info (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = g_app_info_get_name (_tmp4_);
	dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, DBUSMENU_METADATA_MENUITEM_PLAYER_NAME, _tmp5_);
	_tmp6_ = player_item_get_owner ((PlayerItem*) self);
	_tmp7_ = _tmp6_;
	_tmp8_ = player_controller_get_icon_name (_tmp7_);
	_tmp9_ = _tmp8_;
	dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, DBUSMENU_METADATA_MENUITEM_PLAYER_ICON, _tmp9_);
	dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) self, DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING, FALSE);
	dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) self, DBUSMENU_METADATA_MENUITEM_HIDE_TRACK_DETAILS, TRUE);
	_tmp10_ = metadata_menuitem_relevant_attributes_for_ui ();
	_tmp11_ = _tmp10_;
	player_item_reset ((PlayerItem*) self, _tmp11_);
	_g_object_unref0 (_tmp11_);
	return obj;
}
void metadata_menuitem_alter_label (MetadataMenuitem* self, const gchar* new_title) {
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = new_title;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = new_title;
	dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, DBUSMENU_METADATA_MENUITEM_PLAYER_NAME, _tmp1_);
}
void playlists_menuitem_active_playlist_update (PlaylistsMenuitem* self, PlaylistDetails* detail) {
	PlaylistDetails _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* update;
	const gchar* _tmp3_;
	DbusmenuMenuitem* _tmp6_;
	const gchar* _tmp7_;
	gchar* _tmp8_ = NULL;
	gchar* _tmp9_;
	DbusmenuMenuitem* _tmp10_;
	PlaylistDetails _tmp11_;
	const char* _tmp12_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (detail != NULL);
	_tmp0_ = *detail;
	_tmp1_ = _tmp0_.name;
	_tmp2_ = g_strdup (_tmp1_);
	update = _tmp2_;
	_tmp3_ = update;
	if (g_strcmp0 (_tmp3_, "") == 0) {
		const gchar* _tmp4_ = NULL;
		gchar* _tmp5_;
		_tmp4_ = _ ("Choose Playlist");
		_tmp5_ = g_strdup (_tmp4_);
		_g_free0 (update);
		update = _tmp5_;
	}
	_tmp6_ = self->root_item;
	_tmp7_ = update;
	_tmp8_ = playlists_menuitem_truncate_item_label_if_needs_be (self, _tmp7_);
	_tmp9_ = _tmp8_;
	dbusmenu_menuitem_property_set (_tmp6_, DBUSMENU_MENUITEM_PROP_LABEL, _tmp9_);
	_g_free0 (_tmp9_);
	_tmp10_ = self->root_item;
	_tmp11_ = *detail;
	_tmp12_ = _tmp11_.path;
	dbusmenu_menuitem_property_set (_tmp10_, DBUSMENU_PLAYLIST_MENUITEM_PATH, (const gchar*) _tmp12_);
	_g_free0 (update);
}
void
sni_toggle_play_pause (int play) {
    static int play_pause_state = 1;
    DbusmenuMenuitem *play_item;

    if ((play_pause_state && play) || (!play_pause_state && !play))
        return;

    play_item = get_context_menu_item (SNI_MENU_ITEM_PLAY);

    if (play_pause_state && !play) {
        dbusmenu_menuitem_property_set (play_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Pause"));
        dbusmenu_menuitem_property_set (play_item, DBUSMENU_MENUITEM_PROP_ICON_NAME, "media-playback-pause");

        play_pause_state = 0;
    }
    else {
        dbusmenu_menuitem_property_set (play_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Play"));
        dbusmenu_menuitem_property_set (play_item, DBUSMENU_MENUITEM_PROP_ICON_NAME, "media-playback-start");

        play_pause_state = 1;
    }
}
Exemplo n.º 10
0
DbusmenuMenuitem* addSeparator(DbusmenuMenuitem * parent, int uid, int position) {
  DbusmenuMenuitem* item = dbusmenu_menuitem_new();
  dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_TYPE, "separator");
  dbusmenu_menuitem_property_set_int(item, MENUITEM_UID_PROPERTY, uid);
  dbusmenu_menuitem_property_set_bool(item, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
  if (parent != NULL) {
    if (position < 0)
      dbusmenu_menuitem_child_append(parent, item);
    else
      dbusmenu_menuitem_child_add_position(parent, item, (guint)position);
  }

  return item;
}
Exemplo n.º 11
0
AbstractLauncherIcon::MenuItemsVector TrashLauncherIcon::GetMenus()
{
  MenuItemsVector result;

  /* Empty Trash */
  glib::Object<DbusmenuMenuitem> menu_item(dbusmenu_menuitem_new());
  dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Empty Trash…"));
  dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, !empty_);
  dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true);
  empty_activated_signal_.Connect(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
  [this] (DbusmenuMenuitem*, unsigned timestamp) {
    file_manager_->EmptyTrash(timestamp);
  });

  result.push_back(menu_item);

  return result;
}
Exemplo n.º 12
0
void createMenuRootForWnd(WndInfo *wi) {
    if (wi->menuroot != NULL) {
        _releaseMenuItem(wi->menuroot);
        wi->menuroot = NULL;
    }

    wi->menuroot = dbusmenu_menuitem_new();
    if (wi->menuroot == NULL) {
        _error("can't create menuitem for new root");
        return;
    }

    g_object_set_data(G_OBJECT(wi->menuroot), MENUITEM_JHANDLER_PROPERTY, wi->jhandler);
    dbusmenu_menuitem_property_set(wi->menuroot, DBUSMENU_MENUITEM_PROP_LABEL, "DBusMenuRoot");

    if (wi->server == NULL)
        _error("can't set new root because wi->server is null");
    else
        dbusmenu_server_set_root(wi->server, wi->menuroot);
}
Exemplo n.º 13
0
WndInfo *registerWindow(guint32 windowXid, jeventcallback handler) {
  // _info("register new window");

  WndInfo *wi = (WndInfo *) malloc(sizeof(WndInfo));
  memset(wi, 0, sizeof(WndInfo));

  wi->xid = (guint32) windowXid;
  wi->menuPath = malloc(64);
  sprintf(wi->menuPath, "/com/canonical/menu/0x%x", windowXid);

  wi->menuroot = dbusmenu_menuitem_new();
  if (wi->menuroot == NULL) {
    _error("can't create menuitem for new root");
    _releaseWindow(wi);
    return NULL;
  }

  g_object_set_data(G_OBJECT(wi->menuroot), MENUITEM_JHANDLER_PROPERTY, handler);
  dbusmenu_menuitem_property_set(wi->menuroot, DBUSMENU_MENUITEM_PROP_LABEL, "DBusMenuRoot");

  wi->server = dbusmenu_server_new(wi->menuPath);
  dbusmenu_server_set_root(wi->server, wi->menuroot);

  wi->registrar = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SESSION,
                                                G_DBUS_PROXY_FLAGS_NONE,
                                                NULL,
                                                DBUS_NAME,
                                                REG_OBJECT,
                                                REG_IFACE,
                                                NULL, NULL);
  if (wi->registrar == NULL) {
    // probably need to watch for registrar on dbus
    // guint watcher = g_bus_watch_name(G_BUS_TYPE_SESSION, DBUS_NAME, G_BUS_NAME_WATCHER_FLAGS_NONE, on_registrar_available, on_registrar_unavailable);
    _error("can't obtain registrar");
    _releaseWindow(wi);
    return NULL;
  }

  char buf[1024];
  _printWndInfo(wi, buf, 1024);
  _logmsg(LOG_LEVEL_INFO, "new window info: %s", buf);

  GError *error = NULL;
  g_dbus_proxy_call_sync(
    wi->registrar,
    "RegisterWindow",
    g_variant_new("(uo)", windowXid, wi->menuPath),
    G_DBUS_CALL_FLAGS_NONE,
    -1,
    NULL,
    &error);

  if (error != NULL) {
    _logmsg(LOG_LEVEL_ERROR, "Unable to register window, error: %s", error->message);
    g_error_free(error);
    _releaseWindow(wi);
    return NULL;
  }

  wi->jhandler = handler;
  g_signal_connect(wi->registrar, "notify::g-name-owner", G_CALLBACK(_onDbusOwnerChange), wi);

  return wi;
}
void playlists_menuitem_update_individual_playlist (PlaylistsMenuitem* self, PlaylistDetails* new_detail) {
	DbusmenuMenuitem* _tmp19_;
	const gchar* _tmp20_ = NULL;
	PlaylistDetails _tmp21_;
	const char* _tmp22_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (new_detail != NULL);
	{
		GeeHashMap* _tmp0_;
		GeeCollection* _tmp1_;
		GeeCollection* _tmp2_;
		GeeCollection* _tmp3_;
		GeeIterator* _tmp4_ = NULL;
		GeeIterator* _tmp5_;
		GeeIterator* _item_it;
		_tmp0_ = self->priv->current_playlists;
		_tmp1_ = gee_abstract_map_get_values ((GeeMap*) _tmp0_);
		_tmp2_ = _tmp1_;
		_tmp3_ = _tmp2_;
		_tmp4_ = gee_iterable_iterator ((GeeIterable*) _tmp3_);
		_tmp5_ = _tmp4_;
		_g_object_unref0 (_tmp3_);
		_item_it = _tmp5_;
		while (TRUE) {
			GeeIterator* _tmp6_;
			gboolean _tmp7_ = FALSE;
			GeeIterator* _tmp8_;
			gpointer _tmp9_ = NULL;
			DbusmenuMenuitem* item;
			PlaylistDetails _tmp10_;
			const char* _tmp11_;
			DbusmenuMenuitem* _tmp12_;
			const gchar* _tmp13_ = NULL;
			_tmp6_ = _item_it;
			_tmp7_ = gee_iterator_next (_tmp6_);
			if (!_tmp7_) {
				break;
			}
			_tmp8_ = _item_it;
			_tmp9_ = gee_iterator_get (_tmp8_);
			item = (DbusmenuMenuitem*) _tmp9_;
			_tmp10_ = *new_detail;
			_tmp11_ = _tmp10_.path;
			_tmp12_ = item;
			_tmp13_ = dbusmenu_menuitem_property_get (_tmp12_, DBUSMENU_PLAYLIST_MENUITEM_PATH);
			if (g_strcmp0 (_tmp11_, _tmp13_) == 0) {
				DbusmenuMenuitem* _tmp14_;
				PlaylistDetails _tmp15_;
				const gchar* _tmp16_;
				gchar* _tmp17_ = NULL;
				gchar* _tmp18_;
				_tmp14_ = item;
				_tmp15_ = *new_detail;
				_tmp16_ = _tmp15_.name;
				_tmp17_ = playlists_menuitem_truncate_item_label_if_needs_be (self, _tmp16_);
				_tmp18_ = _tmp17_;
				dbusmenu_menuitem_property_set (_tmp14_, DBUSMENU_MENUITEM_PROP_LABEL, _tmp18_);
				_g_free0 (_tmp18_);
			}
			_g_object_unref0 (item);
		}
		_g_object_unref0 (_item_it);
	}
	_tmp19_ = self->root_item;
	_tmp20_ = dbusmenu_menuitem_property_get (_tmp19_, DBUSMENU_PLAYLIST_MENUITEM_PATH);
	_tmp21_ = *new_detail;
	_tmp22_ = _tmp21_.path;
	if (g_strcmp0 (_tmp20_, _tmp22_) == 0) {
		DbusmenuMenuitem* _tmp23_;
		PlaylistDetails _tmp24_;
		const gchar* _tmp25_;
		gchar* _tmp26_ = NULL;
		gchar* _tmp27_;
		_tmp23_ = self->root_item;
		_tmp24_ = *new_detail;
		_tmp25_ = _tmp24_.name;
		_tmp26_ = playlists_menuitem_truncate_item_label_if_needs_be (self, _tmp25_);
		_tmp27_ = _tmp26_;
		dbusmenu_menuitem_property_set (_tmp23_, DBUSMENU_MENUITEM_PROP_LABEL, _tmp27_);
		_g_free0 (_tmp27_);
	}
}
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);
	}
}
Exemplo n.º 16
0
void setItemLabel(DbusmenuMenuitem *item, const char *label) {
  dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_LABEL, label);
}
Exemplo n.º 17
0
static void metadata_menuitem_on_fetcher_completed (MetadataMenuitem* self, GByteArray* update, const gchar* property) {
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (update != NULL);
	g_return_if_fail (property != NULL);
	{
		GdkPixbufLoader* _tmp0_;
		GdkPixbufLoader* loader;
		GdkPixbufLoader* _tmp1_;
		GByteArray* _tmp2_;
		guint8* _tmp3_;
		gint _tmp3__length1;
		GdkPixbufLoader* _tmp4_;
		GdkPixbufLoader* _tmp5_;
		GdkPixbuf* _tmp6_ = NULL;
		GdkPixbuf* _tmp7_;
		GdkPixbuf* icon;
		const gchar* _tmp8_;
		gchar* _tmp9_ = NULL;
		gchar* path;
		const gchar* _tmp10_;
		gint _tmp11_ = 0;
		gint r;
		gint _tmp12_;
		_tmp0_ = gdk_pixbuf_loader_new ();
		loader = _tmp0_;
		_tmp1_ = loader;
		_tmp2_ = update;
		_tmp3_ = _tmp2_->data;
		_tmp3__length1 = (gint) _tmp2_->len;
		gdk_pixbuf_loader_write (_tmp1_, _tmp3_, (gsize) _tmp3__length1, &_inner_error_);
		if (_inner_error_ != NULL) {
			_g_object_unref0 (loader);
			goto __catch6_g_error;
		}
		_tmp4_ = loader;
		gdk_pixbuf_loader_close (_tmp4_, &_inner_error_);
		if (_inner_error_ != NULL) {
			_g_object_unref0 (loader);
			goto __catch6_g_error;
		}
		_tmp5_ = loader;
		_tmp6_ = gdk_pixbuf_loader_get_pixbuf (_tmp5_);
		_tmp7_ = _g_object_ref0 (_tmp6_);
		icon = _tmp7_;
		_tmp8_ = metadata_menuitem_album_art_cache_dir;
		_tmp9_ = g_strconcat (_tmp8_, "/downloaded-coverart-XXXXXX", NULL);
		path = _tmp9_;
		_tmp10_ = path;
		_tmp11_ = g_mkstemp (_tmp10_);
		r = _tmp11_;
		_tmp12_ = r;
		if (_tmp12_ != (-1)) {
			GdkPixbuf* _tmp13_;
			const gchar* _tmp14_;
			GdkPixbufLoader* _tmp15_;
			GdkPixbufFormat* _tmp16_ = NULL;
			gchar* _tmp17_ = NULL;
			gchar* _tmp18_;
			const gchar* _tmp19_;
			const gchar* _tmp20_;
			const gchar* _tmp21_;
			const gchar* _tmp23_;
			gchar* _tmp24_;
			_tmp13_ = icon;
			_tmp14_ = path;
			_tmp15_ = loader;
			_tmp16_ = gdk_pixbuf_loader_get_format (_tmp15_);
			_tmp17_ = gdk_pixbuf_format_get_name (_tmp16_);
			_tmp18_ = _tmp17_;
			gdk_pixbuf_save (_tmp13_, _tmp14_, _tmp18_, &_inner_error_, NULL);
			_g_free0 (_tmp18_);
			if (_inner_error_ != NULL) {
				_g_free0 (path);
				_g_object_unref0 (icon);
				_g_object_unref0 (loader);
				goto __catch6_g_error;
			}
			_tmp19_ = property;
			_tmp20_ = path;
			dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, _tmp19_, _tmp20_);
			_tmp21_ = self->priv->previous_temp_album_art_path;
			if (_tmp21_ != NULL) {
				const gchar* _tmp22_;
				_tmp22_ = self->priv->previous_temp_album_art_path;
				g_remove (_tmp22_);
			}
			_tmp23_ = path;
			_tmp24_ = g_strdup (_tmp23_);
			_g_free0 (self->priv->previous_temp_album_art_path);
			self->priv->previous_temp_album_art_path = _tmp24_;
		}
		_g_free0 (path);
		_g_object_unref0 (icon);
		_g_object_unref0 (loader);
	}
	goto __finally6;
	__catch6_g_error:
	{
		GError* e = NULL;
		GError* _tmp25_;
		const gchar* _tmp26_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp25_ = e;
		_tmp26_ = _tmp25_->message;
		g_warning ("metadata-menu-item.vala:163: Problem creating file from bytearray fetc" \
"hed from the interweb - error: %s", _tmp26_);
		_g_error_free0 (e);
	}
	__finally6:
	if (_inner_error_ != NULL) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
}
Exemplo n.º 18
0
/* Builds up the menu for us */
static void
rebuild_items (DbusmenuMenuitem *root,
               UsersServiceDbus *service)
{
  DbusmenuMenuitem *mi = NULL;
  DbusmenuMenuitem * guest_mi = NULL;
  GList *u;
  UserData *user;
  gboolean can_activate;
  gboolean can_lockscreen;
  GList *children;

  /* Make sure we have a valid GConf client, and build one
     if needed */
  ensure_gconf_client ();

  /* Check to see which menu items we're allowed to have */
  can_activate = users_service_dbus_can_activate_session (service) &&
      !gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_USER, NULL);
  can_lockscreen = !gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_SCREENSAVER, NULL);

  /* Remove the old menu items if that makes sense */
  children = dbusmenu_menuitem_take_children (root);
  g_list_foreach (children, (GFunc)g_object_unref, NULL);
  g_list_free (children);

  /* Lock screen item */
  if (can_lockscreen) {
	lock_menuitem = dbusmenu_menuitem_new();
	dbusmenu_menuitem_property_set(lock_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Lock Screen"));

	gchar * shortcut = gconf_client_get_string(gconf_client, KEY_LOCK_SCREEN, NULL);
	if (shortcut != NULL) {
		g_debug("Lock screen shortcut: %s", shortcut);
		dbusmenu_menuitem_property_set_shortcut_string(lock_menuitem, shortcut);
		g_free(shortcut);
	} else {
		g_debug("Unable to get lock screen shortcut.");
	}

	g_signal_connect(G_OBJECT(lock_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(lock_screen), NULL);
	dbusmenu_menuitem_child_append(root, lock_menuitem);
  }

  /* Set to NULL just incase we don't end up building one */
  users_service_dbus_set_guest_item(service, NULL);

  /* Build all of the user switching items */
  if (can_activate == TRUE)
    {
		if (can_lockscreen) {
			DbusmenuMenuitem * separator1 = dbusmenu_menuitem_new();
			dbusmenu_menuitem_property_set(separator1, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
			dbusmenu_menuitem_child_append(root, separator1);
		}

      if (check_guest_session ())
        {
          guest_mi = dbusmenu_menuitem_new ();
		  dbusmenu_menuitem_property_set (guest_mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE);
          dbusmenu_menuitem_property_set (guest_mi, USER_ITEM_PROP_NAME, _("Guest Session"));
          dbusmenu_menuitem_property_set_bool (guest_mi, USER_ITEM_PROP_LOGGED_IN, FALSE);
          dbusmenu_menuitem_child_append (root, guest_mi);
          g_signal_connect (G_OBJECT (guest_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_guest_session), service);
          users_service_dbus_set_guest_item(service, guest_mi);
        }

      if (check_new_session ())
        {

          switch_menuitem = dbusmenu_menuitem_new ();
		  dbusmenu_menuitem_property_set (switch_menuitem, DBUSMENU_MENUITEM_PROP_TYPE, MENU_SWITCH_TYPE);
		  dbusmenu_menuitem_property_set (switch_menuitem, MENU_SWITCH_USER, g_get_user_name());
          dbusmenu_menuitem_child_append (root, switch_menuitem);
          g_signal_connect (G_OBJECT (switch_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_new_session), NULL);
        }

		GList * users = NULL;
		users = users_service_dbus_get_user_list (service);
		guint user_count = g_list_length(users);

		if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) {
			users = g_list_sort (users, (GCompareFunc)compare_users_by_username);
		}

		for (u = users; u != NULL; u = g_list_next (u)) {
			user = u->data;
			user->service = service;

			if (user->uid == getuid()) {
				/* Hide me from the list */
				continue;
			}

			if (g_strcmp0(user->user_name, "guest") == 0) {
				/* Check to see if the guest has sessions and so therefore should
				   get a check mark. */
				if (user->sessions != NULL) {
					dbusmenu_menuitem_property_set_bool (guest_mi, USER_ITEM_PROP_LOGGED_IN, TRUE);
				}
				/* If we're showing user accounts, keep going through the list */
				if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) {
					continue;
				}
				/* If not, we can stop here */
				break;
			}

			if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) {
				mi = dbusmenu_menuitem_new ();
				dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE);
				if (user->real_name_conflict) {
					gchar * conflictedname = g_strdup_printf("%s (%s)", user->real_name, user->user_name);
					dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, conflictedname);
					g_free(conflictedname);
				} else {
					dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, user->real_name);
				}
				dbusmenu_menuitem_property_set_bool (mi, USER_ITEM_PROP_LOGGED_IN, user->sessions != NULL);
				if (user->icon_url != NULL && user->icon_url[0] != '\0' && g_str_has_prefix(user->icon_url, "file://")) {
					dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, user->icon_url + strlen("file://"));
				} else {
					dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, USER_ITEM_ICON_DEFAULT);
				}
				dbusmenu_menuitem_child_append (root, mi);
				g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_user_session), user);
				user->menuitem = mi;
			}
		}

		g_list_free(users);
	}

	/* If there were a bunch of items before us, we need a
	   separator. */
	if (can_lockscreen || can_activate) {
		DbusmenuMenuitem * separator = dbusmenu_menuitem_new();
		dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
		dbusmenu_menuitem_child_append(root, separator);
	}

	/* Start going through the session based items. */

	logout_mi = dbusmenu_menuitem_new();
	if (supress_confirmations()) {
		dbusmenu_menuitem_property_set(logout_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out"));
	} else {
		dbusmenu_menuitem_property_set(logout_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out\342\200\246"));
	}
	dbusmenu_menuitem_property_set_bool(logout_mi, DBUSMENU_MENUITEM_PROP_VISIBLE, show_logout());
	dbusmenu_menuitem_child_append(root, logout_mi);
	g_signal_connect(G_OBJECT(logout_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "logout");

	if (can_suspend && allow_suspend) {
		suspend_mi = dbusmenu_menuitem_new();
		dbusmenu_menuitem_property_set(suspend_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Suspend"));
		dbusmenu_menuitem_child_append(root, suspend_mi);
		g_signal_connect(G_OBJECT(suspend_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(machine_sleep), "Suspend");
	}

	if (can_hibernate && allow_hibernate) {
		hibernate_mi = dbusmenu_menuitem_new();
		dbusmenu_menuitem_property_set(hibernate_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Hibernate"));
		dbusmenu_menuitem_child_append(root, hibernate_mi);
		g_signal_connect(G_OBJECT(hibernate_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(machine_sleep), "Hibernate");
	}

	restart_mi = dbusmenu_menuitem_new();
	dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_TYPE, RESTART_ITEM_TYPE);
	if (supress_confirmations()) {
		dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart"));
	} else {
		dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart\342\200\246"));
	}
	dbusmenu_menuitem_property_set_bool(restart_mi, DBUSMENU_MENUITEM_PROP_VISIBLE, show_restart());
	dbusmenu_menuitem_child_append(root, restart_mi);
	g_signal_connect(G_OBJECT(restart_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "restart");

	shutdown_mi = dbusmenu_menuitem_new();
	if (supress_confirmations()) {
		dbusmenu_menuitem_property_set(shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shut Down"));
	} else {
		dbusmenu_menuitem_property_set(shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shut Down\342\200\246"));
	}
	dbusmenu_menuitem_property_set_bool(shutdown_mi, DBUSMENU_MENUITEM_PROP_VISIBLE, show_shutdown());
	dbusmenu_menuitem_child_append(root, shutdown_mi);
	g_signal_connect(G_OBJECT(shutdown_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "shutdown");

	RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi = g_new0 (RestartShutdownLogoutMenuItems, 1);
	restart_shutdown_logout_mi->logout_mi = logout_mi;
	restart_shutdown_logout_mi->restart_mi = restart_mi;
	restart_shutdown_logout_mi->shutdown_mi = shutdown_mi;

	update_menu_entries(restart_shutdown_logout_mi);

	/* now add extra launchers */
	GDir *extra_launchers_dir;
	extra_launchers_dir = g_dir_open (EXTRA_LAUNCHER_DIR, 0, NULL);
	if (extra_launchers_dir != NULL) {
		GList * launchers = NULL;

		/* Find all the desktop files we want to use */
		for (;;) {
			const gchar *extra_launcher_file;

			extra_launcher_file = g_dir_read_name (extra_launchers_dir);
			if (extra_launcher_file == NULL)
				break;
			if (!g_str_has_suffix (extra_launcher_file, ".desktop"))
				continue;

			gchar *full_path = g_build_filename (EXTRA_LAUNCHER_DIR, extra_launcher_file, NULL);
			GAppInfo * appinfo = G_APP_INFO(g_desktop_app_info_new_from_filename (full_path));
			g_free (full_path);

			launchers = g_list_prepend(launchers, appinfo);
		}
		g_dir_close(extra_launchers_dir);

		/* Sort the desktop files based on their names */
		launchers = g_list_sort(launchers, sort_app_infos);

		/* Turn each one into a separate menu item */
		GList * launcher = NULL;
		gboolean sepadded = FALSE;
		for (launcher = launchers; launcher != NULL; launcher = g_list_next(launcher)) {
			GAppInfo * appinfo = G_APP_INFO(launcher->data);

			/* Make sure we have a separator */
			if (!sepadded) {
				DbusmenuMenuitem * separator = dbusmenu_menuitem_new();
				dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
				dbusmenu_menuitem_child_append(root, separator);
				g_object_unref(separator);
				sepadded = TRUE;
			}

			/* Build the item */
			DbusmenuMenuitem * desktop_mi = dbusmenu_menuitem_new();
			dbusmenu_menuitem_property_set(desktop_mi, DBUSMENU_MENUITEM_PROP_LABEL, g_app_info_get_name(appinfo));
			g_signal_connect(G_OBJECT(desktop_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(desktop_activate_cb), appinfo);
			g_object_weak_ref(G_OBJECT(desktop_mi), (GWeakNotify)g_object_unref, appinfo);

			/* Put into the menu */
			dbusmenu_menuitem_child_append(root, desktop_mi);
		}

		g_list_free(launchers);
	}

	return;
}
Exemplo n.º 19
0
void metadata_menuitem_fetch_art (MetadataMenuitem* self, const gchar* uri, const gchar* prop) {
	const gchar* _tmp0_;
	GFile* _tmp1_ = NULL;
	GFile* art_file;
	GFile* _tmp2_;
	gboolean _tmp3_ = FALSE;
	const gchar* _tmp19_;
	const gchar* _tmp20_;
	const gchar* _tmp21_;
	const gchar* _tmp22_;
	FetchFile* _tmp23_;
	FetchFile* _tmp24_;
	FetchFile* _tmp25_;
	FetchFile* _tmp26_;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (uri != NULL);
	g_return_if_fail (prop != NULL);
	_tmp0_ = uri;
	_tmp1_ = g_file_new_for_uri (_tmp0_);
	art_file = _tmp1_;
	_tmp2_ = art_file;
	_tmp3_ = g_file_is_native (_tmp2_);
	if (_tmp3_ == TRUE) {
		GFile* _tmp4_;
		gboolean _tmp5_ = FALSE;
		gchar* path = NULL;
		_tmp4_ = art_file;
		_tmp5_ = g_file_query_exists (_tmp4_, NULL);
		if (_tmp5_ == FALSE) {
			const gchar* _tmp6_;
			_tmp6_ = prop;
			dbusmenu_menuitem_property_set_int ((DbusmenuMenuitem*) self, _tmp6_, PLAYER_ITEM_EMPTY);
			_g_object_unref0 (art_file);
			return;
		}
		{
			const gchar* _tmp7_;
			gchar* _tmp8_ = NULL;
			gchar* _tmp9_;
			gchar* _tmp10_ = NULL;
			gchar* _tmp11_;
			gchar* _tmp12_;
			const gchar* _tmp13_;
			gchar* _tmp14_ = NULL;
			gchar* _tmp15_;
			const gchar* _tmp16_;
			const gchar* _tmp17_;
			_tmp7_ = uri;
			_tmp8_ = string_strip (_tmp7_);
			_tmp9_ = _tmp8_;
			_tmp10_ = g_filename_from_uri (_tmp9_, NULL, &_inner_error_);
			_tmp11_ = _tmp10_;
			_g_free0 (_tmp9_);
			_tmp12_ = _tmp11_;
			if (_inner_error_ != NULL) {
				if (_inner_error_->domain == G_CONVERT_ERROR) {
					goto __catch5_g_convert_error;
				}
				_g_free0 (path);
				_g_object_unref0 (art_file);
				g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
				g_clear_error (&_inner_error_);
				return;
			}
			_g_free0 (path);
			path = _tmp12_;
			_tmp13_ = uri;
			_tmp14_ = string_strip (_tmp13_);
			_tmp15_ = _tmp14_;
			g_debug ("metadata-menu-item.vala:116: Populating the artwork field with %s", _tmp15_);
			_g_free0 (_tmp15_);
			_tmp16_ = prop;
			_tmp17_ = path;
			dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, _tmp16_, _tmp17_);
		}
		goto __finally5;
		__catch5_g_convert_error:
		{
			GError* e = NULL;
			const gchar* _tmp18_;
			e = _inner_error_;
			_inner_error_ = NULL;
			_tmp18_ = uri;
			g_warning ("metadata-menu-item.vala:120: Problem converting URI %s to file path", _tmp18_);
			_g_error_free0 (e);
		}
		__finally5:
		if (_inner_error_ != NULL) {
			_g_free0 (path);
			_g_object_unref0 (art_file);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
		_g_free0 (path);
		_g_object_unref0 (art_file);
		return;
	}
	_tmp19_ = metadata_menuitem_album_art_cache_dir;
	g_debug ("metadata-menu-item.vala:126: fetch_art -remotely %s", _tmp19_);
	_tmp20_ = metadata_menuitem_album_art_cache_dir;
	if (_tmp20_ == NULL) {
		_g_object_unref0 (art_file);
		return;
	}
	_tmp21_ = uri;
	_tmp22_ = prop;
	_tmp23_ = fetch_file_new (_tmp21_, _tmp22_);
	_g_object_unref0 (metadata_menuitem_fetcher);
	metadata_menuitem_fetcher = _tmp23_;
	_tmp24_ = metadata_menuitem_fetcher;
	g_signal_connect_object (_tmp24_, "failed", (GCallback) ___lambda2__fetch_file_failed, self, 0);
	_tmp25_ = metadata_menuitem_fetcher;
	g_signal_connect_object (_tmp25_, "completed", (GCallback) _metadata_menuitem_on_fetcher_completed_fetch_file_completed, self, 0);
	_tmp26_ = metadata_menuitem_fetcher;
	fetch_file_fetch_data (_tmp26_, NULL, NULL);
	_g_object_unref0 (art_file);
}