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; }
static void fm_ditem_page_exec_drag_data_received (GtkWidget *widget, GdkDragContext *context, int x, int y, GtkSelectionData *selection_data, guint info, guint time, GtkEntry *entry) { char **uris; gboolean exactly_one; NautilusFile *file; GnomeDesktopItem *item; char *uri; const char *exec; uris = g_strsplit (selection_data->data, "\r\n", 0); exactly_one = uris[0] != NULL && (uris[1] == NULL || uris[1][0] == '\0'); if (!exactly_one) { g_strfreev (uris); return; } file = nautilus_file_get_by_uri (uris[0]); g_return_if_fail (file != NULL); uri = nautilus_file_get_uri (file); if (nautilus_file_is_mime_type (file, "application/x-desktop")) { item = gnome_desktop_item_new_from_uri (uri, GNOME_DESKTOP_ITEM_LOAD_ONLY_IF_EXISTS, NULL); if (item != NULL && gnome_desktop_item_get_entry_type (item) == GNOME_DESKTOP_ITEM_TYPE_APPLICATION) { exec = gnome_desktop_item_get_string (item, GNOME_DESKTOP_ITEM_EXEC); gtk_entry_set_text (entry, exec?exec:""); gnome_desktop_item_unref (item); gtk_widget_grab_focus (GTK_WIDGET (entry)); } } else { gtk_entry_set_text (entry, uri?uri:""); } g_free (uri); nautilus_file_unref (file); g_strfreev (uris); }
static GtkWidget * build_table (GnomeDesktopItem *item, GList *entries, int length) { GtkWidget *table; GtkWidget *label; GtkWidget *entry; GList *l; const char *val; int i; table = gtk_table_new (length, 2, FALSE); i = 0; for (l = entries; l; l = l->next) { ItemEntry *item_entry = (ItemEntry *)l->data; char *label_text; label_text = g_strdup_printf ("<b>%s:</b>", item_entry->description); label = gtk_label_new (label_text); gtk_label_set_use_markup (GTK_LABEL (label), TRUE); g_free (label_text); gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); entry = gtk_entry_new (); if (item_entry->localized) { val = gnome_desktop_item_get_localestring (item, item_entry->field); } else { val = gnome_desktop_item_get_string (item, item_entry->field); } gtk_entry_set_text (GTK_ENTRY (entry), val?val:""); gtk_table_attach (GTK_TABLE (table), label, 0, 1, i, i+1, GTK_FILL, GTK_FILL, 4, 4); gtk_table_attach (GTK_TABLE (table), entry, 1, 2, i, i+1, GTK_EXPAND|GTK_FILL, GTK_EXPAND|GTK_FILL, 4, 4); g_signal_connect (entry, "activate", G_CALLBACK (entry_activate_cb), item); g_signal_connect (entry, "focus_out_event", G_CALLBACK (entry_focus_out_cb), item); g_object_set_data_full (G_OBJECT (entry), "item_entry", item_entry, (GDestroyNotify)item_entry_free); if (item_entry->filename) { gtk_drag_dest_set (GTK_WIDGET (entry), GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP, target_table, G_N_ELEMENTS (target_table), GDK_ACTION_COPY | GDK_ACTION_MOVE); g_signal_connect (entry, "drag_data_received", G_CALLBACK (fm_ditem_page_url_drag_data_received), entry); } else if (strcmp (item_entry->field, GNOME_DESKTOP_ITEM_EXEC) == 0) { gtk_drag_dest_set (GTK_WIDGET (entry), GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP, target_table, G_N_ELEMENTS (target_table), GDK_ACTION_COPY | GDK_ACTION_MOVE); g_signal_connect (entry, "drag_data_received", G_CALLBACK (fm_ditem_page_exec_drag_data_received), entry); } i++; } gtk_widget_show_all (table); return table; }