Пример #1
0
void
panel_util_launch_from_key_file (GKeyFile   *keyfile,
				 GList      *file_list,
				 GdkScreen  *screen,
				 GError    **error)
{
	GnomeDesktopItem  *ditem;
	int                i;
	static const char *keys [] = { "Type",
				       "Exec",
				       "URL",
				       "Dev",
				       "Path",
				       "Terminal",
				       "TerminalOptions",
				       "StartupNotify",
				       "StartupWMClass",
				     };
	static const char *locale_keys [] = { "Name",
					      "GenericName",
					      "Icon",
					      "MiniIcon",
					    };

	g_return_if_fail (keyfile != NULL);

	ditem = gnome_desktop_item_new ();
	if (ditem == NULL)
		return;

	for (i = 0; i < G_N_ELEMENTS (keys); i++) {
		char *value;

		value = panel_util_key_file_get_string (keyfile,
							keys [i]);
		if (value != NULL) {
			gnome_desktop_item_set_string (ditem, keys [i], value);
			g_free (value);
		}
	}

	for (i = 0; i < G_N_ELEMENTS (locale_keys); i++) {
		char *value;

		value = panel_util_key_file_get_locale_string (keyfile,
							       locale_keys [i]);
		if (value != NULL) {
			gnome_desktop_item_set_string (ditem, locale_keys [i], value);
			g_free (value);
		}
	}

	panel_ditem_launch (ditem, file_list, screen, error);
	gnome_desktop_item_unref (ditem);
}
Пример #2
0
static void
save_entry (GtkEntry *entry, GnomeDesktopItem *item)
{
	GError *error;
	ItemEntry *item_entry;
	const char *val;

	item_entry = g_object_get_data (G_OBJECT (entry), "item_entry");
	val = gtk_entry_get_text (entry);

	if (item_entry->localized) {
		gnome_desktop_item_set_localestring (item, item_entry->field, val);
	} else {
		gnome_desktop_item_set_string (item, item_entry->field, val);
	}

	error = NULL;

	if (!gnome_desktop_item_save (item, NULL, TRUE, &error)) {
		g_warning (error->message);
		g_error_free (error);
	}
}