? INSTALL ? depcomp ? gnome-volume-properties.gladep ? intltool-extract.in ? intltool-merge.in ? intltool-update.in Index: gnome-volume-properties.glade =================================================================== RCS file: /cvs/gnome/gnome-volume-manager/gnome-volume-properties.glade,v retrieving revision 1.3 diff -u -u -r1.3 gnome-volume-properties.glade --- gnome-volume-properties.glade 13 Aug 2004 17:11:56 -0000 1.3 +++ gnome-volume-properties.glade 22 Jan 2005 16:09:22 -0000 @@ -80,6 +80,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -244,6 +248,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -326,6 +334,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -341,18 +353,22 @@ 12 - + True - Command: + Application: False False - GTK_JUSTIFY_RIGHT + GTK_JUSTIFY_LEFT False False 0.5 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -362,12 +378,27 @@ + + True + False + True + + + 0 + True + True + + + + True + False 10 False False True + GTK_FILE_CHOOSER_ACTION_OPEN @@ -378,7 +409,7 @@ 0 True - * + * False @@ -451,6 +482,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -530,6 +565,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -557,6 +596,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -572,6 +615,7 @@ False False True + GTK_FILE_CHOOSER_ACTION_OPEN @@ -582,7 +626,7 @@ 0 True - * + * False @@ -655,6 +699,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -737,6 +785,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -764,6 +816,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -779,6 +835,7 @@ False False True + GTK_FILE_CHOOSER_ACTION_OPEN @@ -789,7 +846,7 @@ 0 True - * + * False @@ -862,6 +919,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -941,6 +1002,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -968,6 +1033,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -983,6 +1052,7 @@ False False True + GTK_FILE_CHOOSER_ACTION_OPEN @@ -993,7 +1063,7 @@ 0 True - * + * False Index: src/properties.c =================================================================== RCS file: /cvs/gnome/gnome-volume-manager/src/properties.c,v retrieving revision 1.11 diff -u -u -r1.11 properties.c --- src/properties.c 13 Aug 2004 19:49:44 -0000 1.11 +++ src/properties.c 22 Jan 2005 16:09:22 -0000 @@ -13,6 +13,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include @@ -32,6 +36,15 @@ # define N_(String) (String) #endif +enum { + COLUMN_PIXBUF, + COLUMN_NAME, + COLUMN_COMMAND, + NUM_COLUMNS +}; + + + GtkWidget *dialog; GtkWidget *automount_drives_cb; GtkWidget *automount_media_cb; @@ -39,8 +52,9 @@ GtkWidget *autorun_cb; GtkWidget *autoplay_cda_cb; GtkWidget *command_cda_hbox; -GtkWidget *command_cda_entry; +GtkWidget *command_cda_combo; GtkWidget *command_cda_fileentry; +GtkWidget *command_cda_entry; GtkWidget *autoburn_cdr_cb; GtkWidget *command_cdr_fileentry; GtkWidget *command_cdr_entry; @@ -114,6 +128,8 @@ static void signal_response (void) { + GtkTreeIter iter; + GtkListStore *store; config.automount_drives = GTK_TOGGLE_BUTTON (automount_drives_cb)->active; config.automount_media = GTK_TOGGLE_BUTTON @@ -126,8 +142,16 @@ config.autoplay_dvd = GTK_TOGGLE_BUTTON (autoplay_dvd_cb)->active; config.autophoto = GTK_TOGGLE_BUTTON (autophoto_cb)->active; g_free (config.autoplay_cda_command); - config.autoplay_cda_command = gtk_editable_get_chars - (GTK_EDITABLE (command_cda_entry), 0, -1); + store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (command_cda_combo))); + gtk_combo_box_get_active_iter (GTK_COMBO_BOX (command_cda_combo), &iter); + gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, COLUMN_COMMAND, &config.autoplay_cda_command, -1); + if (config.autoplay_cda_command == NULL) { + config.autoplay_cda_command = gtk_editable_get_chars + (GTK_EDITABLE (command_cda_entry), 0, -1); + } else { + gtk_widget_set_sensitive (command_cda_fileentry, FALSE); + } + g_free (config.autoplay_dvd_command); config.autoplay_dvd_command = gtk_editable_get_chars (GTK_EDITABLE (command_dvd_entry), 0, -1); @@ -214,9 +238,32 @@ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (autoplay_cda_cb), config.autoplay_cda); - if (config.autoplay_cda_command != NULL) - gtk_entry_set_text (GTK_ENTRY (command_cda_entry), - config.autoplay_cda_command); + if (config.autoplay_cda_command != NULL) { + GtkTreeIter iter; + GtkListStore *store; + gboolean has_more = TRUE; + gboolean found_app = FALSE; + + store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (command_cda_combo))); + gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter); + do { + char *command; + gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, COLUMN_COMMAND, &command, -1); + if (command != NULL && !strcmp (config.autoplay_cda_command, command)) { + gtk_combo_box_set_active_iter (GTK_COMBO_BOX (command_cda_combo), &iter); + gtk_widget_set_sensitive (command_cda_fileentry, FALSE); + found_app = TRUE; + break; + } + has_more = gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter); + } while (has_more); + + if (found_app == FALSE) { + gtk_widget_set_sensitive (command_cda_fileentry, TRUE); + gtk_entry_set_text (GTK_ENTRY (command_cda_entry), + config.autoplay_cda_command); + } + } gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (autoburn_cdr_cb), config.autoburn_cdr); if (config.autoburn_cdr_command != NULL) @@ -351,6 +398,108 @@ return TRUE; } +static void +fill_combo (GtkComboBox *combo, const char *mime_type, const char *current_command) +{ + GtkListStore *store; + GtkCellRenderer *renderer; + GtkTreeIter iter, default_iter; + + GList *applications; + GnomeVFSMimeApplication *default_app; + GList *l; + gboolean has_custom = TRUE; + + store = gtk_list_store_new (NUM_COLUMNS, + GDK_TYPE_PIXBUF, + G_TYPE_STRING, + G_TYPE_STRING); + + gtk_combo_box_set_model (combo, GTK_TREE_MODEL (store)); + + renderer = gtk_cell_renderer_pixbuf_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer, "pixbuf", COLUMN_PIXBUF, NULL); + renderer = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer, "text", COLUMN_NAME, NULL); + + applications = gnome_vfs_mime_get_all_applications (mime_type); + + for (l = applications; l != NULL; l = l->next) { + GnomeVFSMimeApplication *application; + char *escaped; + const char *icon; + const char *command; + GdkPixbuf *pixbuf = NULL; + + application = l->data; + + command = gnome_vfs_mime_application_get_exec (application); + if (command == NULL) { + continue; + } + escaped = g_markup_escape_text (application->name, -1); + + icon = gnome_vfs_mime_application_get_icon (application); + if (icon != NULL) { + if (g_path_is_absolute (icon)) { + pixbuf = gdk_pixbuf_new_from_file_at_size (icon, 24, 24, NULL); + } + if (pixbuf == NULL) { + pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), + icon, 24, 0, NULL); + } + if (pixbuf == NULL && strrchr (icon, '.') != NULL) { + char *name; + name = g_strndup (icon, strlen (icon) - strlen (strrchr (icon, '.'))); + pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), + name, 24, 0, NULL); + g_free (name); + } + + if (pixbuf == NULL) { + char *filename; + filename = g_strdup_printf (DATADIR"/pixmaps/%s", icon); + pixbuf = gdk_pixbuf_new_from_file_at_size (filename, 24, 24, NULL); + g_free (filename); + } + } + + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, + COLUMN_PIXBUF, pixbuf, + COLUMN_NAME, escaped, + COLUMN_COMMAND, command, + -1); + + if (current_command != NULL && !strcmp (command, current_command)) { + default_iter = iter; + has_custom = FALSE; + } + + g_free (escaped); + if (pixbuf != NULL) + g_object_unref(pixbuf); + } + + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, + COLUMN_PIXBUF, NULL, + COLUMN_NAME, _("Custom command:"), + COLUMN_COMMAND, NULL, + -1); + if (has_custom) { + gtk_combo_box_set_active_iter (combo, &iter); + gtk_widget_set_sensitive (command_cda_fileentry, TRUE); + } else { + gtk_combo_box_set_active_iter (combo, &default_iter); + } + + gnome_vfs_mime_application_list_free (applications); +} + + #define GLADE_XML_FILE "gnome-volume-properties.glade" /* @@ -444,15 +593,11 @@ autorun_cb = glade_xml_get_widget (xml, "autorun_cb"); autoplay_cda_cb = glade_xml_get_widget (xml, "autoplay_cda_cb"); + command_cda_combo = glade_xml_get_widget (xml, "command_cda_combo"); command_cda_entry = glade_xml_get_widget (xml, "command_cda_entry"); - command_cda_fileentry = gnome_file_entry_gnome_entry (GNOME_FILE_ENTRY - (glade_xml_get_widget (xml, "command_cda_fileentry"))); + command_cda_fileentry = glade_xml_get_widget (xml, "command_cda_fileentry"); command_cda_hbox = glade_xml_get_widget (xml, "command_cda_hbox"); - - gnome_entry_set_history_id (GNOME_ENTRY (command_cda_fileentry), - "CD_CAPPLET_ID"); - gtk_combo_set_case_sensitive (GTK_COMBO (command_cda_fileentry), - FALSE); + fill_combo (GTK_COMBO_BOX (command_cda_combo), "audio/x-cd-cdda", config.autoplay_cda_command); autoplay_dvd_cb = glade_xml_get_widget (xml, "autoplay_dvd_cb"); command_dvd_entry = glade_xml_get_widget (xml, "command_dvd_entry"); @@ -496,6 +641,8 @@ GTK_SIGNAL_FUNC (signal_response), NULL); gtk_signal_connect (GTK_OBJECT (autoplay_cda_cb), "toggled", + GTK_SIGNAL_FUNC (signal_response), NULL); + gtk_signal_connect (GTK_OBJECT (command_cda_combo), "changed", GTK_SIGNAL_FUNC (signal_response), NULL); gtk_signal_connect (GTK_OBJECT (command_cda_entry), "changed", GTK_SIGNAL_FUNC (signal_response), NULL);