예제 #1
0
static void
create_page (GnomeDesktopItem *item, GtkWidget *box)
{
	GtkWidget *table;
	GList *entries;
	GnomeDesktopItemType item_type;
	GtkLabel *label;
	
	entries = NULL;

	label = g_object_get_data (G_OBJECT (box), "label");

	item_type = gnome_desktop_item_get_entry_type (item);
	
	if (item_type == GNOME_DESKTOP_ITEM_TYPE_LINK) {
		entries = g_list_prepend (entries,
					  item_entry_new (GNOME_DESKTOP_ITEM_COMMENT,
							  _("Comment"), TRUE, FALSE));
		entries = g_list_prepend (entries,
					  item_entry_new (GNOME_DESKTOP_ITEM_URL,
							  _("URL"), FALSE, TRUE));
		entries = g_list_prepend (entries,
					  item_entry_new (GNOME_DESKTOP_ITEM_GENERIC_NAME,
							  _("Description"), TRUE, FALSE));
		gtk_label_set_text (label, _("Link"));
	} else if (item_type == GNOME_DESKTOP_ITEM_TYPE_APPLICATION) {
		entries = g_list_prepend (entries,
					  item_entry_new (GNOME_DESKTOP_ITEM_COMMENT,
							  _("Comment"), TRUE, FALSE));
		entries = g_list_prepend (entries,
					  item_entry_new (GNOME_DESKTOP_ITEM_EXEC,
							  _("Command"), FALSE, FALSE));
		entries = g_list_prepend (entries,
					  item_entry_new (GNOME_DESKTOP_ITEM_GENERIC_NAME,
							  _("Description"), TRUE, FALSE));
		gtk_label_set_text (label, _("Launcher"));		
	} else {
		/* we only handle launchers and links */
		return;
	}

	gnome_desktop_item_ref (item);

	g_object_weak_ref (G_OBJECT (box),
			   box_weak_cb, item);

	table = build_table (item, entries, 2);
	g_list_free (entries);
	
	gtk_box_pack_start (GTK_BOX (box), table, FALSE, TRUE, 0);
	gtk_widget_show_all (GTK_WIDGET (box));
}
GObject *
gnome_window_manager_new (GnomeDesktopItem *it)
{
        const char *settings_lib;
        char *module_name;
        GnomeWindowManagerNewFunc wm_new_func = NULL;
        GObject *wm;
        GModule *module;
        gboolean success;

        settings_lib = gnome_desktop_item_get_string (it, "X-GNOME-WMSettingsModule");

        module_name = g_module_build_path (GNOME_WINDOW_MANAGER_MODULE_PATH,
                                           settings_lib);

        module = g_module_open (module_name, G_MODULE_BIND_LAZY);
        if (module == NULL) {
                g_warning ("Couldn't load window manager settings module `%s' (%s)", module_name, g_module_error ());
		g_free (module_name);
                return NULL;
        }

        success = g_module_symbol (module, "window_manager_new",
                                   (gpointer *) &wm_new_func);  
  
        if ((!success) || wm_new_func == NULL) {
                g_warning ("Couldn't load window manager settings module `%s`, couldn't find symbol \'window_manager_new\'", module_name);
		g_free (module_name);
                return NULL;
        }

	g_free (module_name);

        wm = (* wm_new_func) (GNOME_WINDOW_MANAGER_INTERFACE_VERSION);

        if (wm == NULL)
                return NULL;
        
        (GNOME_WINDOW_MANAGER (wm))->p->window_manager_name = g_strdup (gnome_desktop_item_get_string (it, GNOME_DESKTOP_ITEM_NAME));
        (GNOME_WINDOW_MANAGER (wm))->p->ditem = gnome_desktop_item_ref (it);
  
        return wm;
}
GnomeDesktopItem *
gnome_window_manager_get_ditem (GnomeWindowManager *wm)
{
        return gnome_desktop_item_ref (wm->p->ditem);
}