示例#1
0
static GSList *
panel_addto_query_applets (GSList *list)
{
	GList *applet_list, *l;

	applet_list = mate_panel_applets_manager_get_applets ();

	for (l = applet_list; l; l = g_list_next (l)) {
		MatePanelAppletInfo *info;
		const char *iid, *name, *description, *icon;
		PanelAddtoItemInfo *applet;

		info = (MatePanelAppletInfo *)l->data;

		iid = mate_panel_applet_info_get_iid (info);
		name = mate_panel_applet_info_get_name (info);
		description = mate_panel_applet_info_get_description (info);
		icon = mate_panel_applet_info_get_icon (info);

		if (!name || panel_lockdown_is_applet_disabled (iid)) {
			continue;
		}

		applet = g_new0 (PanelAddtoItemInfo, 1);
		applet->type = PANEL_ADDTO_APPLET;
		applet->name = g_strdup (name);
		applet->description = g_strdup (description);
		applet->icon = g_strdup (icon);
		applet->iid = g_strdup (iid);
		applet->static_data = FALSE;

		list = g_slist_prepend (list, applet);
	}

	g_list_free (applet_list);

	return list;
}
示例#2
0
static void
setup_options (void)
{
	MatePanelAppletsManager *manager;
	GList               *applet_list, *l;
	int                  i;
	int                  j;
	char                *prefs_path = NULL;
	char                *unique_key = NULL;
	gboolean             unique_key_found = FALSE;
	gchar              **dconf_paths;
	GtkListStore        *model;
	GtkTreeIter          iter;
	GtkCellRenderer     *renderer;

	model = gtk_list_store_new (NUMBER_COLUMNS,
				    G_TYPE_STRING,
				    G_TYPE_STRING);

	gtk_combo_box_set_model (GTK_COMBO_BOX (applet_combo),
				 GTK_TREE_MODEL (model));

	manager = g_object_new (PANEL_TYPE_APPLETS_MANAGER_DBUS, NULL);
	applet_list = MATE_PANEL_APPLETS_MANAGER_GET_CLASS (manager)->get_applets (manager);
	for (l = applet_list, i = 1; l; l = g_list_next (l), i++) {
		MatePanelAppletInfo *info = (MatePanelAppletInfo *)l->data;

		gtk_list_store_append (model, &iter);
		gtk_list_store_set (model, &iter,
				    COLUMN_TEXT, g_strdup (mate_panel_applet_info_get_name (info)),
				    COLUMN_ITEM, g_strdup (mate_panel_applet_info_get_iid (info)),
				    -1);
	}
	g_list_free (applet_list);
	g_object_unref (manager);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (applet_combo),
				    renderer, TRUE);
	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (applet_combo),
					renderer, "text", COLUMN_TEXT, NULL);

	gtk_combo_box_set_active (GTK_COMBO_BOX (applet_combo), 0);

	setup_combo (size_combo, size_items, "Size",
		     G_N_ELEMENTS (size_items));
	setup_combo (orient_combo, orient_items, "Orientation",
		     G_N_ELEMENTS (orient_items));

	for (i = 0; !unique_key_found; i++)
	{
		g_free (unique_key);
		unique_key = g_strdup_printf ("mate-panel-test-applet-%d", i);
		unique_key_found = TRUE;
		dconf_paths = mate_dconf_list_subdirs ("/tmp/", TRUE);
		for (j = 0; dconf_paths[j] != NULL; j++)
		{
			if (g_strcmp0(unique_key, dconf_paths[j]) == 0) {
				unique_key_found = FALSE;
				break;
			}
		}
		if (dconf_paths)
			g_strfreev (dconf_paths);
	}
	
	prefs_path = g_strdup_printf ("/tmp/%s/", unique_key);
	if (unique_key)
		g_free (unique_key);
	gtk_entry_set_text (GTK_ENTRY (prefs_path_entry), prefs_path);
	g_free (prefs_path);
}