From b787f7a4484f07560f7aa9f97f6c4ae1e7f383bd Mon Sep 17 00:00:00 2001 From: Perberos Date: Sun, 13 May 2012 07:46:32 -0300 Subject: re-coding default applications --- TODO | 3 + capplets/default-applications/Makefile.am | 16 +- capplets/default-applications/mate-da-capplet.c | 1312 ++++---------------- capplets/default-applications/mate-da-capplet.h | 4 - capplets/default-applications/mate-da-item.c | 196 --- capplets/default-applications/mate-da-item.h | 101 -- capplets/default-applications/mate-da-xml.c | 506 -------- capplets/default-applications/mate-da-xml.h | 27 - .../mate-default-applications-properties.ui | 25 + .../mate-default-applications.xml.in | 700 ----------- 10 files changed, 257 insertions(+), 2633 deletions(-) delete mode 100644 capplets/default-applications/mate-da-item.c delete mode 100644 capplets/default-applications/mate-da-item.h delete mode 100644 capplets/default-applications/mate-da-xml.c delete mode 100644 capplets/default-applications/mate-da-xml.h delete mode 100644 capplets/default-applications/mate-default-applications.xml.in diff --git a/TODO b/TODO index 1b52b16a..51ae3939 100644 --- a/TODO +++ b/TODO @@ -102,4 +102,7 @@ Bugzilla - Start using it better +Default applications + - List terminal and accessbility apps + - Allow to set custom commands using .desktop files diff --git a/capplets/default-applications/Makefile.am b/capplets/default-applications/Makefile.am index 8ad7740d..906ba6ba 100644 --- a/capplets/default-applications/Makefile.am +++ b/capplets/default-applications/Makefile.am @@ -7,9 +7,7 @@ bin_SCRIPTS = mate-at-visual mate-at-mobility mate_default_applications_properties_LDADD = $(MATECC_CAPPLETS_LIBS) mate_default_applications_properties_SOURCES = \ - mate-da-capplet.c mate-da-capplet.h \ - mate-da-xml.c mate-da-xml.h \ - mate-da-item.c mate-da-item.h + mate-da-capplet.c mate-da-capplet.h @INTLTOOL_DESKTOP_RULE@ @@ -33,19 +31,13 @@ autostartdir = $(sysconfdir)/xdg/autostart autostart_in_files = mate-at-session.desktop.in autostart_DATA = $(autostart_in_files:.desktop.in=.desktop) -xmldata_in_files = mate-default-applications.xml.in -xmldatadir = $(pkgdatadir)/default-apps -xmldata_DATA = $(xmldata_in_files:.xml.in=.xml) -@INTLTOOL_XML_RULE@ - INCLUDES = \ $(MATECC_CAPPLETS_CFLAGS) \ $(DEFAULT_APPLICATIONS_CAPPLET_CFLAGS) \ -DMATELOCALEDIR=\""$(datadir)/locale"\"\ - -DMATECC_UI_DIR=\""$(uidir)"\" \ - -DMATECC_APPS_DIR=\""$(xmldatadir)"\" + -DMATECC_UI_DIR=\""$(uidir)"\" -CLEANFILES = $(MATECC_CAPPLETS_CLEANFILES) $(Desktop_in_files) $(desktop_DATA) $(xmldata_DATA) $(autostart_DATA) $(bin_SCRIPTS) -EXTRA_DIST = $(xmldata_in_files) mate-default-applications.pc.in +CLEANFILES = $(MATECC_CAPPLETS_CLEANFILES) $(Desktop_in_files) $(desktop_DATA) $(autostart_DATA) $(bin_SCRIPTS) +EXTRA_DIST = mate-default-applications.pc.in -include $(top_srcdir)/git.mk diff --git a/capplets/default-applications/mate-da-capplet.c b/capplets/default-applications/mate-da-capplet.c index 69061efd..d009e565 100644 --- a/capplets/default-applications/mate-da-capplet.c +++ b/capplets/default-applications/mate-da-capplet.c @@ -28,23 +28,39 @@ #include #include -#include "mateconf-property-editor.h" #include "mate-da-capplet.h" -#include "mate-da-xml.h" -#include "mate-da-item.h" #include "capplet-util.h" + +enum { + DA_TYPE_WEB_BROWSER, + DA_TYPE_EMAIL, + DA_TYPE_TERMINAL, + DA_TYPE_MEDIA, + DA_TYPE_VIDEO, + DA_TYPE_VISUAL, + DA_TYPE_MOBILITY, + DA_TYPE_IMAGE, + DA_TYPE_TEXT, + DA_TYPE_FILE, + DA_N_COLUMNS +}; + +/* for combo box */ enum { PIXBUF_COL, TEXT_COL, + ID_COL, + ICONAME_COL, N_COLUMNS }; -static void close_cb(GtkWidget* window, gint response, gpointer user_data) +static void +close_cb(GtkWidget* window, gint response, gpointer user_data) { if (response == GTK_RESPONSE_HELP) { - capplet_help(GTK_WINDOW (window), "prefs-preferredapps"); + capplet_help(GTK_WINDOW(window), "prefs-preferredapps"); } else { @@ -53,483 +69,180 @@ static void close_cb(GtkWidget* window, gint response, gpointer user_data) } } -static void web_radiobutton_toggled_cb(GtkWidget* togglebutton, MateDACapplet* capplet) +static void +set_changed(GtkComboBox* combo, MateDACapplet* capplet, GList* list, gint type) { - gint index; - MateDAWebItem* item; - const gchar* command; - GError* error = NULL; - - index = gtk_combo_box_get_active(GTK_COMBO_BOX(capplet->web_combo_box)); - - if (index == -1) - { - return; - } - - item = (MateDAWebItem*) g_list_nth_data(capplet->web_browsers, index); - - if (item == NULL) - { - return; - } - - if (togglebutton == capplet->new_win_radiobutton) - { - command = item->win_command; - } - else if (togglebutton == capplet->new_tab_radiobutton) - { - command = item->tab_command; - } - else - { - command = item->generic.command; - } - - mateconf_client_set_string(capplet->mateconf, DEFAULT_APPS_KEY_HTTP_EXEC, command, &error); - - if (error != NULL) - { - g_warning(_("Error saving configuration: %s"), error->message); - g_error_free(error); - } + guint index; + GAppInfo* item; - /* Para obtener la lista de elementos, y si está en la lista, agregar ese - * item. - * De lo contrario, se crea un elemento especial. */ - GList* recommended = g_app_info_get_recommended_for_type("x-scheme-handler/http"); + index = gtk_combo_box_get_active(combo); - if (recommended!= NULL) + if (index < g_list_length(list)) { - GList* app; - - for (app = recommended; app != NULL; app = app->next) + item = (GAppInfo*) g_list_nth_data(list, index); + + switch (type) { - /* nice hack bro */ - if (strcmp(item->generic.executable, g_app_info_get_executable((GAppInfo*) app->data)) == 0) - { + case DA_TYPE_WEB_BROWSER: + /* establecemos el item */ - g_app_info_set_as_default_for_type((GAppInfo*) app->data, "x-scheme-handler/http", NULL); - g_app_info_set_as_default_for_type((GAppInfo*) app->data, "x-scheme-handler/https", NULL); + g_app_info_set_as_default_for_type(item, "x-scheme-handler/http", NULL); + g_app_info_set_as_default_for_type(item, "x-scheme-handler/https", NULL); /* about:config es usado por mozilla firefox y algunos otros con * webtoolkit */ - g_app_info_set_as_default_for_type((GAppInfo*) app->data, "x-scheme-handler/about", NULL); - } + g_app_info_set_as_default_for_type(item, "x-scheme-handler/about", NULL); + break; + + case DA_TYPE_EMAIL: + /* por alguna extraña razon, solo se usa mailto, en vez de mail. */ + g_app_info_set_as_default_for_type(item, "x-scheme-handler/mailto", NULL); + break; + + case DA_TYPE_FILE: + /* falta agregar más mime-types */ + g_app_info_set_as_default_for_type(item, "inode/directory", NULL); + break; + + case DA_TYPE_TEXT: + /* falta agregar más mime-types */ + g_app_info_set_as_default_for_type(item, "text/plain", NULL); + break; + + case DA_TYPE_MEDIA: + /* por alguna extraña razon, solo se usa mailto, en vez de mail. */ + g_app_info_set_as_default_for_type(item, "audio/x-vorbis+ogg", NULL); + g_app_info_set_as_default_for_type(item, "audio/x-scpls", NULL); + g_app_info_set_as_default_for_type(item, "audio/mpeg", NULL); + g_app_info_set_as_default_for_type(item, "audio/x-wav", NULL); + g_app_info_set_as_default_for_type(item, "audio/x-mpegurl", NULL); + g_app_info_set_as_default_for_type(item, "video/webm", NULL); + break; + + case DA_TYPE_VIDEO: + /* por alguna extraña razon, solo se usa mailto, en vez de mail. */ + g_app_info_set_as_default_for_type(item, "video/mpeg", NULL); + g_app_info_set_as_default_for_type(item, "video/x-mpeg", NULL); + g_app_info_set_as_default_for_type(item, "video/msvideo", NULL); + g_app_info_set_as_default_for_type(item, "video/quicktime", NULL); + g_app_info_set_as_default_for_type(item, "video/x-avi", NULL); + g_app_info_set_as_default_for_type(item, "video/x-ogm+ogg", NULL); + g_app_info_set_as_default_for_type(item, "video/x-matroska", NULL); + g_app_info_set_as_default_for_type(item, "video/webm", NULL); + g_app_info_set_as_default_for_type(item, "video/mp4", NULL); + g_app_info_set_as_default_for_type(item, "video/x-flv", NULL); + break; + + case DA_TYPE_IMAGE: + /* por alguna extraña razon, solo se usa mailto, en vez de mail. */ + g_app_info_set_as_default_for_type(item, "image/png", NULL); + g_app_info_set_as_default_for_type(item, "image/jpeg", NULL); + g_app_info_set_as_default_for_type(item, "image/gif", NULL); + g_app_info_set_as_default_for_type(item, "image/bmp", NULL); + g_app_info_set_as_default_for_type(item, "image/tiff", NULL); + break; + + + default:; + break; } - - g_list_free_full(recommended, g_object_unref); - } - - gtk_entry_set_text(GTK_ENTRY(capplet->web_browser_command_entry), command); - - if (error != NULL) - { - g_warning(_("Error saving configuration: %s"), error->message); - g_error_free(error); } } -static void web_combo_changed_cb(GtkComboBox* combo, MateDACapplet* capplet) +/* Combo box callbacks */ +static void +web_combo_changed_cb(GtkComboBox* combo, MateDACapplet* capplet) { - guint current_index; - gboolean is_custom_active; - gboolean has_net_remote; - MateDAWebItem* item; - GtkWidget* active = NULL; - - current_index = gtk_combo_box_get_active(combo); - - if (current_index < g_list_length(capplet->web_browsers)) - { - item = (MateDAWebItem*) g_list_nth_data(capplet->web_browsers, current_index); - has_net_remote = item->netscape_remote; - is_custom_active = FALSE; - } - else - { - has_net_remote = FALSE; - is_custom_active = TRUE; - } - - /* Si, aun falta para poder crear personalizables... */ - has_net_remote = FALSE; - is_custom_active = FALSE; - gtk_widget_set_sensitive(capplet->default_radiobutton, has_net_remote); - gtk_widget_set_sensitive(capplet->new_win_radiobutton, has_net_remote); - gtk_widget_set_sensitive(capplet->new_tab_radiobutton, has_net_remote); - - gtk_widget_set_sensitive(capplet->web_browser_command_entry, is_custom_active); - gtk_widget_set_sensitive(capplet->web_browser_command_label, is_custom_active); - gtk_widget_set_sensitive(capplet->web_browser_terminal_checkbutton, is_custom_active); - - if (has_net_remote) - { - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(capplet->new_win_radiobutton))) - { - active = capplet->new_win_radiobutton; - } - else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(capplet->new_tab_radiobutton))) - { - active = capplet->new_tab_radiobutton; - } - else - { - active = capplet->default_radiobutton; - } - } - - web_radiobutton_toggled_cb(active, capplet); + set_changed(combo, capplet, capplet->web_browsers, DA_TYPE_WEB_BROWSER); } -/* FIXME: Refactor these two functions below into one... */ -static void mail_combo_changed_cb(GtkComboBox* combo, MateDACapplet* capplet) +static void +mail_combo_changed_cb(GtkComboBox* combo, MateDACapplet* capplet) { - guint current_index; - gboolean is_custom_active; - - current_index = gtk_combo_box_get_active(combo); - is_custom_active = (current_index >= g_list_length(capplet->mail_readers)); - - if (current_index != -1) - { - MateDAItem* item = (MateDAItem*) g_list_nth_data(capplet->mail_readers, current_index); - - if (item != NULL) - { - /* Para obtener la lista de elementos, y si está en la lista, agregar ese - * item. - * De lo contrario, se crea un elemento especial. */ - GList* recommended = g_app_info_get_recommended_for_type("x-scheme-handler/mailto"); - - if (recommended!= NULL) - { - GList* app; - - for (app = recommended; app != NULL; app = app->next) - { - /* nice hack bro */ - if (strcmp(item->executable, g_app_info_get_executable((GAppInfo*) app->data)) == 0) - { - /* por alguna extraña razon, solo se usa mailto, en vez de mail. */ - g_app_info_set_as_default_for_type((GAppInfo*) app->data, "x-scheme-handler/mailto", NULL); - } - } - - g_list_free_full(recommended, g_object_unref); - } - } - } - - /* Si, aun falta para poder crear personalizables... */ - is_custom_active = FALSE; - gtk_widget_set_sensitive(capplet->mail_reader_command_entry, is_custom_active); - gtk_widget_set_sensitive(capplet->mail_reader_command_label, is_custom_active); - gtk_widget_set_sensitive(capplet->mail_reader_terminal_checkbutton, is_custom_active); + set_changed(combo, capplet, capplet->mail_readers, DA_TYPE_EMAIL); } -static void file_combo_changed_cb(GtkComboBox* combo, MateDACapplet* capplet) +static void +file_combo_changed_cb(GtkComboBox* combo, MateDACapplet* capplet) { - guint current_index; - gboolean is_custom_active; - - current_index = gtk_combo_box_get_active(combo); - is_custom_active = (current_index >= g_list_length(capplet->file_managers)); - - if (current_index != -1) - { - MateDAItem* item = (MateDAItem*) g_list_nth_data(capplet->file_managers, current_index); - - if (item != NULL) - { - /* Para obtener la lista de elementos, y si está en la lista, agregar ese - * item. - * De lo contrario, se crea un elemento especial. */ - GList* recommended = g_app_info_get_recommended_for_type("inode/directory"); - - if (recommended!= NULL) - { - GList* app; - - for (app = recommended; app != NULL; app = app->next) - { - /* nice hack bro */ - if (strcmp(item->executable, g_app_info_get_executable((GAppInfo*) app->data)) == 0) - { - /* falta agregar más mime-types */ - g_app_info_set_as_default_for_type((GAppInfo*) app->data, "inode/directory", NULL); - } - } - - g_list_free_full(recommended, g_object_unref); - } - } - } - - /* Si, aun falta para poder crear personalizables... */ - is_custom_active = FALSE; - gtk_widget_set_sensitive(capplet->file_manager_command_entry, is_custom_active); - gtk_widget_set_sensitive(capplet->file_manager_command_label, is_custom_active); - gtk_widget_set_sensitive(capplet->file_manager_terminal_checkbutton, is_custom_active); + set_changed(combo, capplet, capplet->file_managers, DA_TYPE_FILE); } -static void text_combo_changed_cb(GtkComboBox* combo, MateDACapplet* capplet) +static void +text_combo_changed_cb(GtkComboBox* combo, MateDACapplet* capplet) { - guint current_index; - gboolean is_custom_active; - - current_index = gtk_combo_box_get_active(combo); - is_custom_active = (current_index >= g_list_length(capplet->text_editors)); - - if (current_index != -1) - { - MateDAItem* item = (MateDAItem*) g_list_nth_data(capplet->text_editors, current_index); - - if (item != NULL) - { - /* Para obtener la lista de elementos, y si está en la lista, agregar ese - * item. - * De lo contrario, se crea un elemento especial. */ - GList* recommended = g_app_info_get_recommended_for_type("text/plain"); - - if (recommended!= NULL) - { - GList* app; - - for (app = recommended; app != NULL; app = app->next) - { - /* nice hack bro */ - if (strcmp(item->executable, g_app_info_get_executable((GAppInfo*) app->data)) == 0) - { - /* falta agregar más mime-types */ - g_app_info_set_as_default_for_type((GAppInfo*) app->data, "text/plain", NULL); - } - } - - g_list_free_full(recommended, g_object_unref); - } - } - } - - /* Si, aun falta para poder crear personalizables... */ - is_custom_active = FALSE; - gtk_widget_set_sensitive(capplet->text_editor_command_entry, is_custom_active); - gtk_widget_set_sensitive(capplet->text_editor_command_label, is_custom_active); - gtk_widget_set_sensitive(capplet->text_editor_terminal_checkbutton, is_custom_active); + set_changed(combo, capplet, capplet->text_editors, DA_TYPE_TEXT); } -static void media_combo_changed_cb(GtkComboBox* combo, MateDACapplet* capplet) +static void +media_combo_changed_cb(GtkComboBox* combo, MateDACapplet* capplet) { - guint current_index; - gboolean is_custom_active; - - current_index = gtk_combo_box_get_active (combo); - is_custom_active = (current_index >= g_list_length(capplet->media_players)); - - if (current_index != -1) - { - MateDAItem* item = (MateDAItem*) g_list_nth_data(capplet->media_players, current_index); - - if (item != NULL) - { - /* Para obtener la lista de elementos, y si está en la lista, agregar ese - * item. - * De lo contrario, se crea un elemento especial. */ - GList* recommended = g_app_info_get_recommended_for_type("audio/x-vorbis+ogg"); - - if (recommended!= NULL) - { - GList* app; - - for (app = recommended; app != NULL; app = app->next) - { - /* nice hack bro */ - if (strcmp(item->executable, g_app_info_get_executable((GAppInfo*) app->data)) == 0) - { - /* por alguna extraña razon, solo se usa mailto, en vez de mail. */ - g_app_info_set_as_default_for_type((GAppInfo*) app->data, "audio/x-vorbis+ogg", NULL); - g_app_info_set_as_default_for_type((GAppInfo*) app->data, "audio/x-scpls", NULL); - g_app_info_set_as_default_for_type((GAppInfo*) app->data, "audio/mpeg", NULL); - g_app_info_set_as_default_for_type((GAppInfo*) app->data, "audio/x-wav", NULL); - g_app_info_set_as_default_for_type((GAppInfo*) app->data, "audio/x-mpegurl", NULL); - g_app_info_set_as_default_for_type((GAppInfo*) app->data, "video/webm", NULL); - } - } - - g_list_free_full(recommended, g_object_unref); - } - } - } - - /* Si, aun falta para poder crear personalizables... */ - is_custom_active = FALSE; - gtk_widget_set_sensitive(capplet->media_player_command_entry, is_custom_active); - gtk_widget_set_sensitive(capplet->media_player_command_label, is_custom_active); - gtk_widget_set_sensitive(capplet->media_player_terminal_checkbutton, is_custom_active); + set_changed(combo, capplet, capplet->media_players, DA_TYPE_TEXT); } -static void video_combo_changed_cb(GtkComboBox* combo, MateDACapplet* capplet) +static void +video_combo_changed_cb(GtkComboBox* combo, MateDACapplet* capplet) { - guint current_index; - gboolean is_custom_active; - - current_index = gtk_combo_box_get_active (combo); - is_custom_active = (current_index >= g_list_length(capplet->video_players)); - - if (current_index != -1) - { - MateDAItem* item = (MateDAItem*) g_list_nth_data(capplet->video_players, current_index); - - if (item != NULL) - { - /* Para obtener la lista de elementos, y si está en la lista, agregar ese - * item. - * De lo contrario, se crea un elemento especial. */ - GList* recommended = g_app_info_get_recommended_for_type("video/x-ogm+ogg"); - - if (recommended!= NULL) - { - GList* app; - - for (app = recommended; app != NULL; app = app->next) - { - /* nice hack bro */ - if (strcmp(item->executable, g_app_info_get_executable((GAppInfo*) app->data)) == 0) - { - /* por alguna extraña razon, solo se usa mailto, en vez de mail. */ - g_app_info_set_as_default_for_type((GAppInfo*) app->data, "video/mpeg", NULL); - g_app_info_set_as_default_for_type((GAppInfo*) app->data, "video/x-mpeg", NULL); - g_app_info_set_as_default_for_type((GAppInfo*) app->data, "video/msvideo", NULL); - g_app_info_set_as_default_for_type((GAppInfo*) app->data, "video/quicktime", NULL); - g_app_info_set_as_default_for_type((GAppInfo*) app->data, "video/x-avi", NULL); - g_app_info_set_as_default_for_type((GAppInfo*) app->data, "video/x-ogm+ogg", NULL); - g_app_info_set_as_default_for_type((GAppInfo*) app->data, "video/x-matroska", NULL); - g_app_info_set_as_default_for_type((GAppInfo*) app->data, "video/webm", NULL); - g_app_info_set_as_default_for_type((GAppInfo*) app->data, "video/mp4", NULL); - g_app_info_set_as_default_for_type((GAppInfo*) app->data, "video/x-flv", NULL); - } - } - - g_list_free_full(recommended, g_object_unref); - } - } - } - - /* Si, aun falta para poder crear personalizables... */ - is_custom_active = FALSE; - gtk_widget_set_sensitive(capplet->video_player_command_entry, is_custom_active); - gtk_widget_set_sensitive(capplet->video_player_command_label, is_custom_active); - gtk_widget_set_sensitive(capplet->video_player_terminal_checkbutton, is_custom_active); + set_changed(combo, capplet, capplet->video_players, DA_TYPE_TEXT); } -static void terminal_combo_changed_cb(GtkComboBox* combo, MateDACapplet* capplet) -{ - guint current_index; - gboolean is_custom_active; - - current_index = gtk_combo_box_get_active(combo); - is_custom_active = (current_index >= g_list_length(capplet->terminals)); - gtk_widget_set_sensitive(capplet->terminal_command_entry, is_custom_active); - gtk_widget_set_sensitive(capplet->terminal_command_label, is_custom_active); - gtk_widget_set_sensitive(capplet->terminal_exec_flag_entry, is_custom_active); - gtk_widget_set_sensitive(capplet->terminal_exec_flag_label, is_custom_active); +static void +terminal_combo_changed_cb(GtkComboBox* combo, MateDACapplet* capplet) +{ + set_changed(combo, capplet, capplet->terminals, DA_TYPE_TERMINAL); } -static void visual_combo_changed_cb(GtkComboBox* combo, MateDACapplet* capplet) +static void +visual_combo_changed_cb(GtkComboBox* combo, MateDACapplet* capplet) { - guint current_index; - gboolean is_custom_active; - - current_index = gtk_combo_box_get_active(combo); - is_custom_active = (current_index >= g_list_length(capplet->visual_ats)); - - gtk_widget_set_sensitive(capplet->visual_command_entry, is_custom_active); - gtk_widget_set_sensitive(capplet->visual_command_label, is_custom_active); + set_changed(combo, capplet, capplet->visual_ats, DA_TYPE_VISUAL); } -static void mobility_combo_changed_cb(GtkComboBox* combo, MateDACapplet* capplet) +static void +mobility_combo_changed_cb(GtkComboBox* combo, MateDACapplet* capplet) { - guint current_index; - gboolean is_custom_active; - - current_index = gtk_combo_box_get_active (combo); - is_custom_active = (current_index >= g_list_length (capplet->mobility_ats)); - - gtk_widget_set_sensitive (capplet->mobility_command_entry, is_custom_active); - gtk_widget_set_sensitive (capplet->mobility_command_label, is_custom_active); + set_changed(combo, capplet, capplet->mobility_ats, DA_TYPE_MOBILITY); } -static void image_combo_changed_cb(GtkComboBox* combo, MateDACapplet* capplet) +static void +image_combo_changed_cb(GtkComboBox* combo, MateDACapplet* capplet) { - guint current_index; - gboolean is_custom_active; - - current_index = gtk_combo_box_get_active(combo); - is_custom_active = (current_index >= g_list_length(capplet->image_viewers)); - - if (current_index != -1) - { - MateDAItem* item = (MateDAItem*) g_list_nth_data(capplet->image_viewers, current_index); - - if (item != NULL) - { - /* Para obtener la lista de elementos, y si está en la lista, agregar ese - * item. - * De lo contrario, se crea un elemento especial. */ - GList* recommended = g_app_info_get_recommended_for_type("image/png"); - - if (recommended!= NULL) - { - GList* app; - - for (app = recommended; app != NULL; app = app->next) - { - /* nice hack bro */ - if (strcmp(item->executable, g_app_info_get_executable((GAppInfo*) app->data)) == 0) - { - /* por alguna extraña razon, solo se usa mailto, en vez de mail. */ - g_app_info_set_as_default_for_type((GAppInfo*) app->data, "image/png", NULL); - g_app_info_set_as_default_for_type((GAppInfo*) app->data, "image/jpeg", NULL); - g_app_info_set_as_default_for_type((GAppInfo*) app->data, "image/gif", NULL); - g_app_info_set_as_default_for_type((GAppInfo*) app->data, "image/bmp", NULL); - g_app_info_set_as_default_for_type((GAppInfo*) app->data, "image/tiff", NULL); - } - } - - g_list_free_full(recommended, g_object_unref); - } - } - } - - gtk_widget_set_sensitive(capplet->image_viewer_command_entry, is_custom_active); - gtk_widget_set_sensitive(capplet->image_viewer_command_label, is_custom_active); - gtk_widget_set_sensitive(capplet->image_viewer_terminal_checkbutton, is_custom_active); + set_changed(combo, capplet, capplet->image_viewers, DA_TYPE_IMAGE); } -static void refresh_combo_box_icons(GtkIconTheme* theme, GtkComboBox* combo_box, GList* app_list) +static void +refresh_combo_box_icons(GtkIconTheme* theme, GtkComboBox* combo_box, GList* app_list) { - GList *entry; - MateDAItem *item; - GtkTreeModel *model; - GtkTreeIter iter; - GdkPixbuf *pixbuf; - - for (entry = app_list; entry != NULL; entry = g_list_next (entry)) { - item = (MateDAItem *) entry->data; + GtkTreeIter iter; + GtkTreeModel* model; + gboolean valid; + GdkPixbuf* pixbuf; + gchar* icon_name; + + model = gtk_combo_box_get_model(combo_box); - model = gtk_combo_box_get_model (combo_box); + valid = gtk_tree_model_get_iter_first(model, &iter); + + while (valid) + { + gtk_tree_model_get(model, &iter, + ICONAME_COL, &icon_name, + -1); - if (item->icon_path && gtk_tree_model_get_iter_from_string (model, &iter, item->icon_path)) { - pixbuf = gtk_icon_theme_load_icon (theme, item->icon_name, 22, 0, NULL); + pixbuf = gtk_icon_theme_load_icon(theme, icon_name, 22, 0, NULL); - gtk_list_store_set (GTK_LIST_STORE (model), &iter, + gtk_list_store_set(GTK_LIST_STORE(model), &iter, PIXBUF_COL, pixbuf, -1); - if (pixbuf) - g_object_unref (pixbuf); - } + if (pixbuf) + { + g_object_unref(pixbuf); + } + + g_free(icon_name); + + valid = gtk_tree_model_iter_next(model, &iter); } } @@ -550,7 +263,9 @@ static struct { {"terminal_image", "terminal"}, }; -static void theme_changed_cb(GtkIconTheme* theme, MateDACapplet* capplet) +/* Esta funcion se llama cuando se cambia o actualizan los iconos */ +static void +theme_changed_cb(GtkIconTheme* theme, MateDACapplet* capplet) { GObject* icon; gint i; @@ -559,11 +274,12 @@ static void theme_changed_cb(GtkIconTheme* theme, MateDACapplet* capplet) { icon = gtk_builder_get_object(capplet->builder, icons[i].name); - GdkPixbuf* pixbuf = gtk_icon_theme_load_icon(theme, icons[i].icon, 48, 0, NULL); + GdkPixbuf* pixbuf = gtk_icon_theme_load_icon(theme, icons[i].icon, 32, 0, NULL); + gtk_image_set_from_pixbuf(GTK_IMAGE(icon), pixbuf); + if (pixbuf) { - gtk_image_set_from_pixbuf(GTK_IMAGE(icon), pixbuf); g_object_unref(pixbuf); } } @@ -578,7 +294,8 @@ static void theme_changed_cb(GtkIconTheme* theme, MateDACapplet* capplet) refresh_combo_box_icons(theme, GTK_COMBO_BOX(capplet->text_combo_box), capplet->text_editors); } -static void screen_changed_cb(GtkWidget* widget, GdkScreen* screen, MateDACapplet* capplet) +static void +screen_changed_cb(GtkWidget* widget, GdkScreen* screen, MateDACapplet* capplet) { GtkIconTheme* theme; @@ -595,366 +312,28 @@ static void screen_changed_cb(GtkWidget* widget, GdkScreen* screen, MateDACapple capplet->icon_theme = theme; } -static gint generic_item_comp(const void* list_item, const void* command) -{ - return (strcmp(((MateDAItem*) list_item)->command, (char*) command)); -} - -static int web_item_comp(const void* item, const void* command) -{ - MateDAWebItem* web_list_item; - - web_list_item = (MateDAWebItem*) item; - - if (strcmp (web_list_item->generic.command, (char*) command) == 0) - { - return 0; - } - - if (web_list_item->netscape_remote) - { - if (strcmp (web_list_item->tab_command, (char*) command) == 0) - { - return 0; - } - - if (strcmp (web_list_item->win_command, (char*) command) == 0) - { - return 0; - } - } - - return (strcmp(web_list_item->generic.command, (char*) command)); -} - -static void web_mateconf_changed_cb(MateConfPropertyEditor* peditor, gchar* key, MateConfValue* value, MateDACapplet* capplet) -{ - MateConfChangeSet *cs; - GError *error = NULL; - GList *list_entry; - - /* This function is used to update HTTPS,ABOUT and UNKNOWN handlers, which - * should also use the same value as HTTP - */ - - if (strcmp (key, DEFAULT_APPS_KEY_HTTP_EXEC) == 0) - { - gchar *short_browser, *pos; - const gchar *value_str = mateconf_value_get_string (value); - - cs = mateconf_change_set_new (); - - mateconf_change_set_set (cs, DEFAULT_APPS_KEY_HTTPS_EXEC, value); - mateconf_change_set_set (cs, DEFAULT_APPS_KEY_UNKNOWN_EXEC, value); - mateconf_change_set_set (cs, DEFAULT_APPS_KEY_ABOUT_EXEC, value); - pos = strstr (value_str, " "); - if (pos == NULL) - short_browser = g_strdup (value_str); - else - short_browser = g_strndup (value_str, pos - value_str); - mateconf_change_set_set_string (cs, DEFAULT_APPS_KEY_BROWSER_EXEC, short_browser); - g_free (short_browser); - - list_entry = g_list_find_custom (capplet->web_browsers, - value_str, - (GCompareFunc) web_item_comp); - - if (list_entry) { - MateDAWebItem *item = (MateDAWebItem *) list_entry->data; - - mateconf_change_set_set_bool (cs, DEFAULT_APPS_KEY_BROWSER_NREMOTE, item->netscape_remote); - } - - mateconf_client_commit_change_set (capplet->mateconf, cs, TRUE, &error); - - if (error != NULL) { - g_warning (_("Error saving configuration: %s"), error->message); - g_error_free (error); - error = NULL; - } - - mateconf_change_set_unref (cs); - } - else if (strcmp (key, DEFAULT_APPS_KEY_HTTP_NEEDS_TERM) == 0) - { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (capplet->web_browser_terminal_checkbutton), - mateconf_value_get_bool (value)); - - cs = mateconf_change_set_new (); - - mateconf_change_set_set (cs, DEFAULT_APPS_KEY_HTTPS_NEEDS_TERM, value); - mateconf_change_set_set (cs, DEFAULT_APPS_KEY_UNKNOWN_NEEDS_TERM, value); - mateconf_change_set_set (cs, DEFAULT_APPS_KEY_ABOUT_NEEDS_TERM, value); - mateconf_change_set_set (cs, DEFAULT_APPS_KEY_BROWSER_NEEDS_TERM, value); - - mateconf_client_commit_change_set (capplet->mateconf, cs, TRUE, &error); - - if (error != NULL) { - g_warning (_("Error saving configuration: %s"), error->message); - g_error_free (error); - error = NULL; - } - - mateconf_change_set_unref (cs); - } -} - -static void web_browser_update_radio_buttons(MateDACapplet* capplet, const gchar* command) -{ - GList *entry; - gboolean has_net_remote; - - entry = g_list_find_custom (capplet->web_browsers, command, (GCompareFunc) web_item_comp); - - if (entry) { - MateDAWebItem *item = (MateDAWebItem *) entry->data; - - has_net_remote = item->netscape_remote; - - if (has_net_remote) { - /* disable "toggle" signal emitting, thus preventing calling this function twice */ - g_signal_handlers_block_matched (capplet->default_radiobutton, G_SIGNAL_MATCH_FUNC, 0, - 0, NULL, G_CALLBACK (web_radiobutton_toggled_cb), NULL); - g_signal_handlers_block_matched (capplet->new_tab_radiobutton, G_SIGNAL_MATCH_FUNC, 0, - 0, NULL, G_CALLBACK (web_radiobutton_toggled_cb), NULL); - g_signal_handlers_block_matched (capplet->new_win_radiobutton,G_SIGNAL_MATCH_FUNC, 0, - 0, NULL, G_CALLBACK (web_radiobutton_toggled_cb), NULL); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (capplet->default_radiobutton), - strcmp (item->generic.command, command) == 0); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (capplet->new_tab_radiobutton), - strcmp (item->tab_command, command) == 0); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (capplet->new_win_radiobutton), - strcmp (item->win_command, command) == 0); - - g_signal_handlers_unblock_matched (capplet->default_radiobutton, G_SIGNAL_MATCH_FUNC, 0, - 0, NULL, G_CALLBACK (web_radiobutton_toggled_cb), NULL); - g_signal_handlers_unblock_matched (capplet->new_tab_radiobutton, G_SIGNAL_MATCH_FUNC, 0, - 0, NULL, G_CALLBACK (web_radiobutton_toggled_cb), NULL); - g_signal_handlers_unblock_matched (capplet->new_win_radiobutton, G_SIGNAL_MATCH_FUNC, 0, - 0, NULL, G_CALLBACK (web_radiobutton_toggled_cb), NULL); - } - } - else { - has_net_remote = FALSE; - } - - gtk_widget_set_sensitive (capplet->default_radiobutton, has_net_remote); - gtk_widget_set_sensitive (capplet->new_win_radiobutton, has_net_remote); - gtk_widget_set_sensitive (capplet->new_tab_radiobutton, has_net_remote); -} - -static MateConfValue* web_combo_conv_to_widget (MateConfPropertyEditor *peditor, const MateConfValue *value) -{ - MateConfValue *ret; - GList *entry, *handlers; - const gchar *command; - gint index; - MateDACapplet *capplet; - - g_object_get (G_OBJECT (peditor), "data", &capplet, NULL); - - command = mateconf_value_get_string (value); - handlers = capplet->web_browsers; - - if (handlers) - { - entry = g_list_find_custom (handlers, command, (GCompareFunc) web_item_comp); - - if (entry) - { - index = g_list_position (handlers, entry); - } - else - { - index = g_list_length (handlers) + 1; - } - } - else - { - /* if the item has no handlers lsit then select the Custom item */ - index = 1; - } - - web_browser_update_radio_buttons (capplet, command); - - ret = mateconf_value_new (MATECONF_VALUE_INT); - mateconf_value_set_int (ret, index); - - return ret; -} - -static MateConfValue* web_combo_conv_from_widget (MateConfPropertyEditor *peditor, const MateConfValue *value) -{ - MateConfValue *ret; - GList *handlers; - gint index; - MateDAWebItem *item; - const gchar *command; - MateDACapplet *capplet; - - g_object_get (G_OBJECT (peditor), "data", &capplet, NULL); - - index = mateconf_value_get_int (value); - handlers = capplet->web_browsers; - - item = g_list_nth_data (handlers, index); - - ret = mateconf_value_new (MATECONF_VALUE_STRING); - if (!item) - { - /* if item was not found, this is probably the "Custom" item */ - /* XXX: returning "" as the value here is not ideal, but required to - * prevent the combo box from jumping back to the previous value if the - * user has selected Custom */ - mateconf_value_set_string (ret, ""); - return ret; - } - else - { - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (capplet->new_win_radiobutton)) && item->netscape_remote == TRUE) - command = item->win_command; - else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (capplet->new_tab_radiobutton)) && item->netscape_remote == TRUE) - command = item->tab_command; - else - command = item->generic.command; - - mateconf_value_set_string (ret, command); - return ret; - } -} - -static MateConfValue* combo_conv_to_widget (MateConfPropertyEditor *peditor, const MateConfValue *value) -{ - MateConfValue *ret; - GList *entry, *handlers; - const gchar *command; - gint index; - - g_object_get (G_OBJECT (peditor), "data", &handlers, NULL); - - command = mateconf_value_get_string (value); - - if (handlers) - { - entry = g_list_find_custom (handlers, command, (GCompareFunc) generic_item_comp); - if (entry) - index = g_list_position (handlers, entry); - else - index = g_list_length (handlers) + 1; - } - else - { - /* if the item has no handlers lsit then select the Custom item */ - index = 1; - } - - ret = mateconf_value_new (MATECONF_VALUE_INT); - mateconf_value_set_int (ret, index); - return ret; -} - -static MateConfValue* combo_conv_from_widget (MateConfPropertyEditor *peditor, const MateConfValue *value) -{ - MateConfValue *ret; - GList *handlers; - gint index; - MateDAItem *item; - - g_object_get (G_OBJECT (peditor), "data", &handlers, NULL); - index = mateconf_value_get_int (value); - - item = g_list_nth_data (handlers, index); - ret = mateconf_value_new (MATECONF_VALUE_STRING); - - if (!item) - { - /* if item was not found, this is probably the "Custom" item */ - - /* XXX: returning "" as the value here is not ideal, but required to - * prevent the combo box from jumping back to the previous value if the - * user has selected Custom */ - mateconf_value_set_string (ret, ""); - return ret; - } - else - { - mateconf_value_set_string (ret, item->command); - return ret; - } -} - -static MateConfValue* combo_conv_from_widget_term_flag (MateConfPropertyEditor *peditor, const MateConfValue *value) -{ - MateConfValue *ret; - GList *handlers; - gint index; - MateDATermItem *item; - - g_object_get (G_OBJECT (peditor), "data", &handlers, NULL); - index = mateconf_value_get_int (value); - - item = g_list_nth_data (handlers, index); - ret = mateconf_value_new (MATECONF_VALUE_STRING); - - if (!item) - { - /* if item was not found, this is probably the "Custom" item */ - - /* XXX: returning "" as the value here is not ideal, but required to - * prevent the combo box from jumping back to the previous value if the - * user has selected Custom */ - mateconf_value_set_string (ret, ""); - return ret; - } - else - { - mateconf_value_set_string (ret, item->exec_flag); - return ret; - } -} - -static MateConfValue* combo_conv_to_widget_term_flag(MateConfPropertyEditor* peditor, const MateConfValue* value) -{ - GtkComboBox* combo = GTK_COMBO_BOX(mateconf_property_editor_get_ui_control(peditor)); - - MateConfValue* ret = mateconf_value_new(MATECONF_VALUE_INT); - - mateconf_value_set_int(ret, gtk_combo_box_get_active (combo)); - - return ret; -} - -static gboolean is_separator(GtkTreeModel* model, GtkTreeIter* iter, gpointer sep_index) -{ - GtkTreePath* path = gtk_tree_model_get_path(model, iter); - - gboolean result = gtk_tree_path_get_indices(path)[0] == GPOINTER_TO_INT(sep_index); - - gtk_tree_path_free(path); - - return result; -} - -static void fill_combo_box (GtkIconTheme* theme, GtkComboBox* combo_box, GList* app_list) +static void +fill_combo_box(GtkIconTheme* theme, GtkComboBox* combo_box, GList* app_list, gchar* mime) { + guint index = 0; GList* entry; GtkTreeModel* model; GtkCellRenderer* renderer; GtkTreeIter iter; GdkPixbuf* pixbuf; + GAppInfo* default_app; + + default_app = g_app_info_get_default_for_type(mime, FALSE); if (theme == NULL) { theme = gtk_icon_theme_get_default(); } - gtk_combo_box_set_row_separator_func(combo_box, is_separator, GINT_TO_POINTER(g_list_length(app_list)), NULL); - - model = GTK_TREE_MODEL(gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_STRING)); + model = GTK_TREE_MODEL(gtk_list_store_new(4, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING)); gtk_combo_box_set_model(combo_box, model); - renderer = gtk_cell_renderer_pixbuf_new (); + renderer = gtk_cell_renderer_pixbuf_new(); /* not all cells have a pixbuf, this prevents the combo box to shrink */ gtk_cell_renderer_set_fixed_size(renderer, -1, 22); @@ -965,52 +344,56 @@ static void fill_combo_box (GtkIconTheme* theme, GtkComboBox* combo_box, GList* renderer = gtk_cell_renderer_text_new(); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, TRUE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), renderer, + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo_box), renderer, TRUE); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo_box), renderer, "text", TEXT_COL, NULL); - for (entry = app_list; entry != NULL; entry = g_list_next (entry)) + for (entry = app_list; entry != NULL; entry = g_list_next(entry)) { - MateDAItem* item = (MateDAItem*) entry->data; - - pixbuf = gtk_icon_theme_load_icon(theme, item->icon_name, 22, 0, NULL); + GAppInfo* item = (GAppInfo*) entry->data; + + // icon + GIcon* icon = g_app_info_get_icon(item); + gchar* icon_name = g_icon_to_string(icon); + + if (icon_name == NULL) + { + icon_name = g_strdup("binary"); // default icon + } + + pixbuf = gtk_icon_theme_load_icon(theme, icon_name, 22, 0, NULL); gtk_list_store_append(GTK_LIST_STORE(model), &iter); gtk_list_store_set(GTK_LIST_STORE(model), &iter, PIXBUF_COL, pixbuf, - TEXT_COL, item->name, + TEXT_COL, g_app_info_get_display_name(item), + ID_COL, g_app_info_get_id(item), + ICONAME_COL, icon_name, -1); - item->icon_path = gtk_tree_model_get_string_from_iter(model, &iter); - if (pixbuf) { g_object_unref(pixbuf); } + + /* set the index */ + if (default_app != NULL && g_app_info_equal(item, default_app)) + { + gtk_combo_box_set_active(combo_box, index); + } + + g_free(icon_name); + + index++; } - - gtk_list_store_append(GTK_LIST_STORE(model), &iter); - gtk_list_store_set(GTK_LIST_STORE(model), &iter, -1); - gtk_list_store_append(GTK_LIST_STORE(model), &iter); - gtk_list_store_set(GTK_LIST_STORE(model), &iter, - PIXBUF_COL, NULL, - TEXT_COL, _("Custom"), - -1); } -/* not used -static GtkWidget* _gtk_builder_get_widget(GtkBuilder* builder, const gchar* name) -{ - return GTK_WIDGET(gtk_builder_get_object(builder, name)); -}*/ - - -static void show_dialog(MateDACapplet* capplet, const gchar* start_page) +static void +show_dialog(MateDACapplet* capplet, const gchar* start_page) { #define get_widget(name) GTK_WIDGET(gtk_builder_get_object(builder, name)) - GObject* obj; GtkBuilder* builder; guint builder_result; @@ -1041,50 +424,6 @@ static void show_dialog(MateDACapplet* capplet, const gchar* start_page) g_signal_connect(capplet->window, "response", G_CALLBACK(close_cb), NULL); - capplet->web_browser_command_entry = get_widget("web_browser_command_entry"); - capplet->web_browser_command_label = get_widget("web_browser_command_label"); - capplet->web_browser_terminal_checkbutton = get_widget("web_browser_terminal_checkbutton"); - capplet->default_radiobutton = get_widget("web_browser_default_radiobutton"); - capplet->new_win_radiobutton = get_widget("web_browser_new_win_radiobutton"); - capplet->new_tab_radiobutton = get_widget("web_browser_new_tab_radiobutton"); - - capplet->mail_reader_command_entry = get_widget("mail_reader_command_entry"); - capplet->mail_reader_command_label = get_widget("mail_reader_command_label"); - capplet->mail_reader_terminal_checkbutton = get_widget("mail_reader_terminal_checkbutton"); - - capplet->terminal_command_entry = get_widget("terminal_command_entry"); - capplet->terminal_command_label = get_widget("terminal_command_label"); - capplet->terminal_exec_flag_entry = get_widget("terminal_exec_flag_entry"); - capplet->terminal_exec_flag_label = get_widget("terminal_exec_flag_label"); - - capplet->media_player_command_entry = get_widget("media_player_command_entry"); - capplet->media_player_command_label = get_widget("media_player_command_label"); - capplet->media_player_terminal_checkbutton = get_widget("media_player_terminal_checkbutton"); - - capplet->video_player_command_entry = get_widget("video_command_entry"); - capplet->video_player_command_label = get_widget("video_command_label"); - capplet->video_player_terminal_checkbutton = get_widget("video_terminal_checkbox"); - - capplet->visual_command_entry = get_widget("visual_command_entry"); - capplet->visual_command_label = get_widget("visual_command_label"); - capplet->visual_startup_checkbutton = get_widget("visual_start_checkbutton"); - - capplet->image_viewer_command_entry = get_widget("image_command_entry"); - capplet->image_viewer_command_label = get_widget("image_command_label"); - capplet->image_viewer_terminal_checkbutton = get_widget("image_terminal_checkbox"); - - capplet->text_editor_command_entry = get_widget("text_command_entry"); - capplet->text_editor_command_label = get_widget("text_command_label"); - capplet->text_editor_terminal_checkbutton = get_widget("text_terminal_checkbox"); - - capplet->file_manager_command_entry = get_widget("filemanager_command_entry"); - capplet->file_manager_command_label = get_widget("filemanager_command_label"); - capplet->file_manager_terminal_checkbutton = get_widget("filemanager_terminal_checkbox"); - - capplet->mobility_command_entry = get_widget("mobility_command_entry"); - capplet->mobility_command_label = get_widget("mobility_command_label"); - capplet->mobility_startup_checkbutton = get_widget("mobility_start_checkbutton"); - capplet->web_combo_box = get_widget("web_browser_combobox"); capplet->mail_combo_box = get_widget("mail_reader_combobox"); capplet->term_combo_box = get_widget("terminal_combobox"); @@ -1100,16 +439,28 @@ static void show_dialog(MateDACapplet* capplet, const gchar* start_page) g_signal_connect(capplet->window, "screen-changed", G_CALLBACK(screen_changed_cb), capplet); screen_changed_cb(capplet->window, gdk_screen_get_default(), capplet); - fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->web_combo_box), capplet->web_browsers); - fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->mail_combo_box), capplet->mail_readers); - fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->term_combo_box), capplet->terminals); - fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->media_combo_box), capplet->media_players); - fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->video_combo_box), capplet->video_players); - fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->visual_combo_box), capplet->visual_ats); - fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->mobility_combo_box), capplet->mobility_ats); - fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->image_combo_box), capplet->image_viewers); - fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->text_combo_box), capplet->text_editors); - fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->file_combo_box), capplet->file_managers); + // lists + capplet->web_browsers = g_app_info_get_all_for_type("x-scheme-handler/http"); + capplet->mail_readers = g_app_info_get_all_for_type("x-scheme-handler/mailto"); + //capplet->terminals = g_app_info_get_all_for_type("inode/directory"); + capplet->media_players = g_app_info_get_all_for_type("audio/x-vorbis+ogg"); + capplet->video_players = g_app_info_get_all_for_type("video/x-ogm+ogg"); + //capplet->visual_ats = g_app_info_get_all_for_type("inode/directory"); + //capplet->mobility_ats = g_app_info_get_all_for_type("inode/directory"); + capplet->text_editors = g_app_info_get_all_for_type("text/plain"); + capplet->image_viewers = g_app_info_get_all_for_type("image/png"); + capplet->file_managers = g_app_info_get_all_for_type("inode/directory"); + + fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->web_combo_box), capplet->web_browsers, "x-scheme-handler/http"); + fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->mail_combo_box), capplet->mail_readers, "x-scheme-handler/mailto"); + //fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->term_combo_box), capplet->terminals, ""); + fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->media_combo_box), capplet->media_players, "audio/x-vorbis+ogg"); + fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->video_combo_box), capplet->video_players, "video/x-ogm+ogg"); + //fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->visual_combo_box), capplet->visual_ats, NULL); + //fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->mobility_combo_box), capplet->mobility_ats, NULL); + fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->image_combo_box), capplet->image_viewers, "image/png"); + fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->text_combo_box), capplet->text_editors, "text/plain"); + fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->file_combo_box), capplet->file_managers, "inode/directory"); g_signal_connect(capplet->web_combo_box, "changed", G_CALLBACK(web_combo_changed_cb), capplet); g_signal_connect(capplet->mail_combo_box, "changed", G_CALLBACK(mail_combo_changed_cb), capplet); @@ -1123,215 +474,7 @@ static void show_dialog(MateDACapplet* capplet, const gchar* start_page) g_signal_connect(capplet->file_combo_box, "changed", G_CALLBACK(file_combo_changed_cb), capplet); - g_signal_connect(capplet->default_radiobutton, "toggled", G_CALLBACK(web_radiobutton_toggled_cb), capplet); - g_signal_connect(capplet->new_win_radiobutton, "toggled", G_CALLBACK(web_radiobutton_toggled_cb), capplet); - g_signal_connect(capplet->new_tab_radiobutton, "toggled", G_CALLBACK(web_radiobutton_toggled_cb), capplet); - - /* Setup MateConfPropertyEditors */ - - /* Web Browser */ - mateconf_peditor_new_combo_box (NULL, - DEFAULT_APPS_KEY_HTTP_EXEC, - capplet->web_combo_box, - "conv-from-widget-cb", web_combo_conv_from_widget, - "conv-to-widget-cb", web_combo_conv_to_widget, - "data", capplet, - NULL); - - obj = mateconf_peditor_new_string (NULL, - DEFAULT_APPS_KEY_HTTP_EXEC, - capplet->web_browser_command_entry, - NULL); - g_signal_connect (obj, "value-changed", G_CALLBACK (web_mateconf_changed_cb), capplet); - - obj = mateconf_peditor_new_boolean (NULL, - DEFAULT_APPS_KEY_HTTP_NEEDS_TERM, - capplet->web_browser_terminal_checkbutton, - NULL); - g_signal_connect (obj, "value-changed", G_CALLBACK (web_mateconf_changed_cb), capplet); - - /* Mailer */ - mateconf_peditor_new_combo_box (NULL, - DEFAULT_APPS_KEY_MAILER_EXEC, - capplet->mail_combo_box, - "conv-from-widget-cb", combo_conv_from_widget, - "conv-to-widget-cb", combo_conv_to_widget, - "data", capplet->mail_readers, - NULL); - - mateconf_peditor_new_string (NULL, - DEFAULT_APPS_KEY_MAILER_EXEC, - capplet->mail_reader_command_entry, - NULL); - - mateconf_peditor_new_boolean (NULL, - DEFAULT_APPS_KEY_MAILER_NEEDS_TERM, - capplet->mail_reader_terminal_checkbutton, - NULL); - - /* Media player */ - mateconf_peditor_new_combo_box (NULL, - DEFAULT_APPS_KEY_MEDIA_EXEC, - capplet->media_combo_box, - "conv-from-widget-cb", combo_conv_from_widget, - "conv-to-widget-cb", combo_conv_to_widget, - "data", capplet->media_players, - NULL); - - mateconf_peditor_new_string (NULL, - DEFAULT_APPS_KEY_MEDIA_EXEC, - capplet->media_player_command_entry, - NULL); - - mateconf_peditor_new_boolean (NULL, - DEFAULT_APPS_KEY_MEDIA_NEEDS_TERM, - capplet->media_player_terminal_checkbutton, - NULL); - - /* Video player */ - mateconf_peditor_new_combo_box (NULL, - DEFAULT_APPS_KEY_VIDEO_EXEC, - capplet->video_combo_box, - "conv-from-widget-cb", combo_conv_from_widget, - "conv-to-widget-cb", combo_conv_to_widget, - "data", capplet->video_players, - NULL); - - mateconf_peditor_new_string (NULL, - DEFAULT_APPS_KEY_VIDEO_EXEC, - capplet->video_player_command_entry, - NULL); - - mateconf_peditor_new_boolean (NULL, - DEFAULT_APPS_KEY_VIDEO_NEEDS_TERM, - capplet->video_player_terminal_checkbutton, - NULL); - - /* Image viewer */ - mateconf_peditor_new_combo_box(NULL, - DEFAULT_APPS_KEY_IMAGE_EXEC, - capplet->image_combo_box, - "conv-from-widget-cb", combo_conv_from_widget, - "conv-to-widget-cb", combo_conv_to_widget, - "data", capplet->image_viewers, - NULL); - - mateconf_peditor_new_string (NULL, - DEFAULT_APPS_KEY_IMAGE_EXEC, - capplet->image_viewer_command_entry, - NULL); - - mateconf_peditor_new_boolean (NULL, - DEFAULT_APPS_KEY_IMAGE_NEEDS_TERM, - capplet->image_viewer_terminal_checkbutton, - NULL); - - /* File manager */ - mateconf_peditor_new_combo_box(NULL, - DEFAULT_APPS_KEY_FILE_EXEC, - capplet->file_combo_box, - "conv-from-widget-cb", combo_conv_from_widget, - "conv-to-widget-cb", combo_conv_to_widget, - "data", capplet->file_managers, - NULL); - - mateconf_peditor_new_string (NULL, - DEFAULT_APPS_KEY_FILE_EXEC, - capplet->file_manager_command_entry, - NULL); - - mateconf_peditor_new_boolean (NULL, - DEFAULT_APPS_KEY_FILE_NEEDS_TERM, - capplet->file_manager_terminal_checkbutton, - NULL); - - - /* Text editors */ - mateconf_peditor_new_combo_box(NULL, - DEFAULT_APPS_KEY_TEXT_EXEC, - capplet->text_combo_box, - "conv-from-widget-cb", combo_conv_from_widget, - "conv-to-widget-cb", combo_conv_to_widget, - "data", capplet->text_editors, - NULL); - - mateconf_peditor_new_string (NULL, - DEFAULT_APPS_KEY_TEXT_EXEC, - capplet->text_editor_command_entry, - NULL); - - mateconf_peditor_new_boolean (NULL, - DEFAULT_APPS_KEY_TEXT_NEEDS_TERM, - capplet->text_editor_terminal_checkbutton, - NULL); - - - /* Terminal */ - mateconf_peditor_new_combo_box (NULL, - DEFAULT_APPS_KEY_TERMINAL_EXEC, - capplet->term_combo_box, - "conv-from-widget-cb", combo_conv_from_widget, - "conv-to-widget-cb", combo_conv_to_widget, - "data", capplet->terminals, - NULL); - - mateconf_peditor_new_combo_box (NULL, - DEFAULT_APPS_KEY_TERMINAL_EXEC_ARG, - capplet->term_combo_box, - "conv-from-widget-cb", combo_conv_from_widget_term_flag, - "conv-to-widget-cb", combo_conv_to_widget_term_flag, - "data", capplet->terminals, - NULL); - - mateconf_peditor_new_string (NULL, - DEFAULT_APPS_KEY_TERMINAL_EXEC, - capplet->terminal_command_entry, - NULL); - mateconf_peditor_new_string (NULL, - DEFAULT_APPS_KEY_TERMINAL_EXEC_ARG, - capplet->terminal_exec_flag_entry, - NULL); - - - /* Visual */ - mateconf_peditor_new_combo_box (NULL, - DEFAULT_APPS_KEY_VISUAL_EXEC, - capplet->visual_combo_box, - "conv-from-widget-cb", combo_conv_from_widget, - "conv-to-widget-cb", combo_conv_to_widget, - "data", capplet->visual_ats, - NULL); - - mateconf_peditor_new_string (NULL, - DEFAULT_APPS_KEY_VISUAL_EXEC, - capplet->visual_command_entry, - NULL); - - mateconf_peditor_new_boolean (NULL, - DEFAULT_APPS_KEY_VISUAL_STARTUP, - capplet->visual_startup_checkbutton, - NULL); - - - /* Mobility */ - mateconf_peditor_new_combo_box (NULL, - DEFAULT_APPS_KEY_MOBILITY_EXEC, - capplet->mobility_combo_box, - "conv-from-widget-cb", combo_conv_from_widget, - "conv-to-widget-cb", combo_conv_to_widget, - "data", capplet->mobility_ats, - NULL); - - mateconf_peditor_new_string (NULL, - DEFAULT_APPS_KEY_MOBILITY_EXEC, - capplet->mobility_command_entry, - NULL); - - mateconf_peditor_new_boolean (NULL, - DEFAULT_APPS_KEY_MOBILITY_STARTUP, - capplet->mobility_startup_checkbutton, - NULL); - + /* TODO: fix the name icon */ gtk_window_set_icon_name(GTK_WINDOW (capplet->window), "preferences-desktop-default-applications"); if (start_page != NULL) @@ -1345,13 +488,16 @@ static void show_dialog(MateDACapplet* capplet, const gchar* start_page) if (w != NULL) { - GtkNotebook *nb; + GtkNotebook* nb; gint pindex; - nb = GTK_NOTEBOOK (get_widget("preferred_apps_notebook")); - pindex = gtk_notebook_page_num (nb, w); + nb = GTK_NOTEBOOK(get_widget("preferred_apps_notebook")); + pindex = gtk_notebook_page_num(nb, w); + if (pindex != -1) - gtk_notebook_set_current_page (nb, pindex); + { + gtk_notebook_set_current_page(nb, pindex); + } } g_free(page_name); @@ -1362,7 +508,8 @@ static void show_dialog(MateDACapplet* capplet, const gchar* start_page) #undef get_widget } -int main(int argc, char** argv) +int +main(int argc, char** argv) { gchar* start_page = NULL; @@ -1383,23 +530,14 @@ int main(int argc, char** argv) GOptionContext* context = g_option_context_new(_("- MATE Default Applications")); g_option_context_add_main_entries(context, option_entries, GETTEXT_PACKAGE); - capplet_init (context, &argc, &argv); + capplet_init(context, &argc, &argv); MateDACapplet* capplet = g_new0(MateDACapplet, 1); - capplet->mateconf = mateconf_client_get_default(); - mateconf_client_add_dir(capplet->mateconf, "/desktop/mate/url-handlers", MATECONF_CLIENT_PRELOAD_RECURSIVE, NULL); - mateconf_client_add_dir(capplet->mateconf, "/desktop/mate/applications", MATECONF_CLIENT_PRELOAD_RECURSIVE, NULL); - - mate_da_xml_load_list(capplet); show_dialog(capplet, start_page); g_free(start_page); gtk_main(); - g_object_unref(capplet->mateconf); - - mate_da_xml_free(capplet); - return 0; } diff --git a/capplets/default-applications/mate-da-capplet.h b/capplets/default-applications/mate-da-capplet.h index 2dc7487f..04f11811 100644 --- a/capplets/default-applications/mate-da-capplet.h +++ b/capplets/default-applications/mate-da-capplet.h @@ -23,7 +23,6 @@ #define _MATE_DA_CAPPLET_H_ #include -#include // Set http, https, about, and unknown keys to the chosen web browser. #define DEFAULT_APPS_KEY_HTTP_PATH "/desktop/mate/url-handlers/http" @@ -160,9 +159,6 @@ typedef struct _MateDACapplet { GtkWidget* mobility_command_label; GtkWidget* mobility_startup_checkbutton; - - MateConfClient* mateconf; - GList* web_browsers; GList* mail_readers; GList* terminals; diff --git a/capplets/default-applications/mate-da-item.c b/capplets/default-applications/mate-da-item.c deleted file mode 100644 index ab3803de..00000000 --- a/capplets/default-applications/mate-da-item.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Authors: Luca Cavalli - * - * Copyright 2005-2006 Luca Cavalli - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License - * as published by the Free Software Foundation - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - -#include "mate-da-capplet.h" -#include "mate-da-item.h" - -MateDAWebItem* mate_da_web_item_new(void) -{ - MateDAWebItem* item = g_new0(MateDAWebItem, 1); - - return item; -} - -MateDASimpleItem* mate_da_simple_item_new(void) -{ - MateDASimpleItem* item = g_new0(MateDASimpleItem, 1); - - return item; -} - -MateDATermItem* mate_da_term_item_new(void) -{ - MateDATermItem* item = g_new0(MateDATermItem, 1); - - return item; -} - -MateDAVisualItem* mate_da_visual_item_new(void) -{ - MateDAVisualItem* item = g_new0(MateDAVisualItem, 1); - - return item; -} - -MateDAImageItem* mate_da_image_item_new(void) -{ - MateDAImageItem* item = g_new0(MateDAImageItem, 1); - - return item; -} - -MateDATextItem* mate_da_text_item_new(void) -{ - MateDATextItem* item = g_new0(MateDATextItem, 1); - - return item; -} - -MateDAFileItem* mate_da_file_item_new(void) -{ - MateDAFileItem* item = g_new0(MateDAFileItem, 1); - - return item; -} - -MateDAMobilityItem* mate_da_mobility_item_new(void) -{ - MateDAMobilityItem* item = g_new0(MateDAMobilityItem, 1); - - return item; -} - -void mate_da_web_item_free(MateDAWebItem* item) -{ - if (item != NULL) - { - g_free(item->generic.name); - g_free(item->generic.executable); - g_free(item->generic.command); - g_free(item->generic.icon_name); - g_free(item->generic.icon_path); - - g_free(item->tab_command); - g_free(item->win_command); - - g_free(item); - } -} - -void mate_da_simple_item_free(MateDASimpleItem* item) -{ - if (item != NULL) - { - g_free(item->generic.name); - g_free(item->generic.executable); - g_free(item->generic.command); - g_free(item->generic.icon_name); - g_free(item->generic.icon_path); - - g_free(item); - } -} - -void mate_da_image_item_free(MateDAImageItem* item) -{ - if (item != NULL) - { - g_free(item->generic.name); - g_free(item->generic.executable); - g_free(item->generic.command); - g_free(item->generic.icon_name); - g_free(item->generic.icon_path); - - g_free(item); - } -} - -void mate_da_text_item_free(MateDATextItem* item) -{ - if (item != NULL) - { - g_free(item->generic.name); - g_free(item->generic.executable); - g_free(item->generic.command); - g_free(item->generic.icon_name); - g_free(item->generic.icon_path); - - g_free(item); - } -} - -void mate_da_file_item_free(MateDAFileItem* item) -{ - if (item != NULL) - { - g_free(item->generic.name); - g_free(item->generic.executable); - g_free(item->generic.command); - g_free(item->generic.icon_name); - g_free(item->generic.icon_path); - - g_free(item); - } -} - -void mate_da_term_item_free(MateDATermItem* item) -{ - if (item != NULL) - { - g_free(item->generic.name); - g_free(item->generic.executable); - g_free(item->generic.command); - g_free(item->generic.icon_name); - g_free(item->generic.icon_path); - - g_free(item->exec_flag); - - g_free(item); - } -} - -void mate_da_visual_item_free(MateDAVisualItem* item) -{ - if (item != NULL) - { - g_free(item->generic.name); - g_free(item->generic.executable); - g_free(item->generic.command); - g_free(item->generic.icon_name); - g_free(item->generic.icon_path); - - g_free(item); - } -} - -void mate_da_mobility_item_free (MateDAMobilityItem *item) -{ - if (item != NULL) - { - g_free(item->generic.name); - g_free(item->generic.executable); - g_free(item->generic.command); - g_free(item->generic.icon_name); - g_free(item->generic.icon_path); - - g_free(item); - } -} - diff --git a/capplets/default-applications/mate-da-item.h b/capplets/default-applications/mate-da-item.h deleted file mode 100644 index b6a3b573..00000000 --- a/capplets/default-applications/mate-da-item.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Authors: Luca Cavalli - * - * Copyright 2005-2006 Luca Cavalli - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License - * as published by the Free Software Foundation - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - -#ifndef _MATE_DA_ITEM_H_ -#define _MATE_DA_ITEM_H_ - -#include - -typedef struct _MateDAItem { - gchar* name; - gchar* executable; - gchar* command; - gchar* icon_name; - gchar* icon_path; -} MateDAItem; - -typedef struct _MateDAWebItem { - MateDAItem generic; - gboolean run_in_terminal; - gboolean netscape_remote; - gchar* tab_command; - gchar* win_command; -} MateDAWebItem; - -typedef struct _MateDASimpleItem { - MateDAItem generic; - gboolean run_in_terminal; -} MateDASimpleItem; - -typedef struct _MateDAImageItem { - MateDAItem generic; - gboolean run_in_terminal; -} MateDAImageItem; - -typedef struct _MateDATextItem { - MateDAItem generic; - gboolean run_in_terminal; -} MateDATextItem; - -typedef struct _MateDAFileItem { - MateDAItem generic; - gboolean run_in_terminal; -} MateDAFileItem; - -typedef struct _MateDATermItem { - MateDAItem generic; - gchar* exec_flag; -} MateDATermItem; - -typedef struct _MateDAVisualItem { - MateDAItem generic; - gboolean run_at_startup; -} MateDAVisualItem; - -typedef struct _MateDAMobilityItem { - MateDAItem generic; - gboolean run_at_startup; -} MateDAMobilityItem; - -MateDAWebItem* mate_da_web_item_new(void); -void mate_da_web_item_free(MateDAWebItem* item); - -MateDATermItem* mate_da_term_item_new(void); -void mate_da_term_item_free(MateDATermItem* item); - -MateDASimpleItem* mate_da_simple_item_new(void); -void mate_da_simple_item_free(MateDASimpleItem* item); - -MateDAVisualItem* mate_da_visual_item_new(void); -void mate_da_visual_item_free(MateDAVisualItem* item); - -MateDAImageItem* mate_da_image_item_new(void); -void mate_da_image_item_free(MateDAImageItem* item); - -MateDATextItem* mate_da_text_item_new(void); -void mate_da_text_item_free(MateDATextItem* item); - -MateDAFileItem* mate_da_file_item_new(void); -void mate_da_file_item_free(MateDAFileItem* item); - -MateDAMobilityItem* mate_da_mobility_item_new(void); -void mate_da_mobility_item_free(MateDAMobilityItem* item); - -#endif diff --git a/capplets/default-applications/mate-da-xml.c b/capplets/default-applications/mate-da-xml.c deleted file mode 100644 index 46b31789..00000000 --- a/capplets/default-applications/mate-da-xml.c +++ /dev/null @@ -1,506 +0,0 @@ -/* - * Authors: Luca Cavalli - * - * Copyright 2005-2006 Luca Cavalli - * Copyright 2010 Perberos - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License - * as published by the Free Software Foundation - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - -#include -#include -#include -#include - -#include "mate-da-capplet.h" -#include "mate-da-xml.h" -#include "mate-da-item.h" - - -static gboolean mate_da_xml_get_bool(const xmlNode* parent, const gchar* val_name) -{ - xmlNode* element; - gboolean ret_val = FALSE; - xmlChar* xml_val_name; - gint len; - - if (parent != NULL && parent->children != NULL && val_name == NULL) - { - xml_val_name = xmlCharStrdup(val_name); - len = xmlStrlen(xml_val_name); - - for (element = parent->children; element != NULL; element = element->next) - { - if (!xmlStrncmp(element->name, xml_val_name, len)) - { - xmlChar* cont = xmlNodeGetContent(element); - - if (!xmlStrcasecmp(cont, (const xmlChar*) "true") || !xmlStrcasecmp(cont, (const xmlChar*) "1")) - { - ret_val = TRUE; - } - else - { - ret_val = FALSE; - } - - xmlFree(cont); - } - } - - xmlFree(xml_val_name); - } - - return ret_val; -} - -static gchar* mate_da_xml_get_string(const xmlNode* parent, const gchar* val_name) -{ - const gchar* const* sys_langs; - xmlChar* node_lang; - xmlNode* element; - gchar* ret_val = NULL; - xmlChar* xml_val_name; - gint len; - gint i; - - if (parent != NULL && parent->children != NULL && val_name != NULL) - { - #if GLIB_CHECK_VERSION (2, 6, 0) - sys_langs = g_get_language_names(); - #endif - - xml_val_name = xmlCharStrdup(val_name); - len = xmlStrlen(xml_val_name); - - for (element = parent->children; element != NULL; element = element->next) - { - if (!xmlStrncmp(element->name, xml_val_name, len)) - { - node_lang = xmlNodeGetLang(element); - - if (node_lang == NULL) - { - ret_val = (gchar *) xmlNodeGetContent(element); - } - else - { - for (i = 0; sys_langs[i] != NULL; i++) - { - if (!strcmp(sys_langs[i], (char*) node_lang)) - { - ret_val = (gchar*) xmlNodeGetContent(element); - /* since sys_langs is sorted from most desirable to - * least desirable, exit at first match */ - break; - } - } - } - - xmlFree(node_lang); - } - } - - xmlFree(xml_val_name); - } - - return ret_val; -} - -static gboolean is_executable_valid(gchar* executable) -{ - gchar* path = g_find_program_in_path(executable); - - if (path) - { - g_free (path); - return TRUE; - } - - return FALSE; -} - -static void mate_da_xml_load_xml(MateDACapplet* capplet, const gchar* filename) -{ - xmlDoc* xml_doc; - xmlNode* root; - xmlNode* section; - xmlNode* element; - gchar* executable; - MateDAWebItem* web_item; - MateDASimpleItem* mail_item; - MateDASimpleItem* media_item; - MateDATermItem* term_item; - MateDAVisualItem* visual_item; - MateDAMobilityItem* mobility_item; - MateDAImageItem* image_item; - MateDATextItem* text_item; - MateDAFileItem* file_item; - MateDASimpleItem* video_item; - - xml_doc = xmlParseFile(filename); - - if (!xml_doc) - { - return; - } - - root = xmlDocGetRootElement(xml_doc); - - for (section = root->children; section != NULL; section = section->next) - { - if (!xmlStrncmp(section->name, (const xmlChar*) "web-browsers", strlen("web-browsers"))) - { - for (element = section->children; element != NULL; element = element->next) - { - if (!xmlStrncmp (element->name, (const xmlChar*) "web-browser", strlen("web-browser"))) - { - executable = mate_da_xml_get_string (element, "executable"); - - if (is_executable_valid (executable)) - { - web_item = mate_da_web_item_new(); - - web_item->generic.name = mate_da_xml_get_string(element, "name"); - web_item->generic.executable = executable; - web_item->generic.command = mate_da_xml_get_string(element, "command"); - web_item->generic.icon_name = mate_da_xml_get_string(element, "icon-name"); - - web_item->run_in_terminal = mate_da_xml_get_bool(element, "run-in-terminal"); - web_item->netscape_remote = mate_da_xml_get_bool(element, "netscape-remote"); - if (web_item->netscape_remote) - { - web_item->tab_command = mate_da_xml_get_string(element, "tab-command"); - web_item->win_command = mate_da_xml_get_string(element, "win-command"); - } - - capplet->web_browsers = g_list_append(capplet->web_browsers, web_item); - } - else - { - g_free(executable); - } - } - } - } - else if (!xmlStrncmp(section->name, (const xmlChar*) "mail-readers", strlen("mail-readers"))) - { - for (element = section->children; element != NULL; element = element->next) - { - if (!xmlStrncmp (element->name, (const xmlChar*) "mail-reader", strlen("mail-reader"))) - { - executable = mate_da_xml_get_string(element, "executable"); - - if (is_executable_valid(executable)) - { - mail_item = mate_da_simple_item_new(); - - mail_item->generic.name = mate_da_xml_get_string(element, "name"); - mail_item->generic.executable = executable; - mail_item->generic.command = mate_da_xml_get_string(element, "command"); - mail_item->generic.icon_name = mate_da_xml_get_string(element, "icon-name"); - - mail_item->run_in_terminal = mate_da_xml_get_bool(element, "run-in-terminal"); - - capplet->mail_readers = g_list_append(capplet->mail_readers, mail_item); - } - else - { - g_free (executable); - } - } - } - } - else if (!xmlStrncmp(section->name, (const xmlChar*) "terminals", strlen("terminals"))) - { - for (element = section->children; element != NULL; element = element->next) - { - if (!xmlStrncmp (element->name, (const xmlChar*) "terminal", strlen("terminal"))) - { - executable = mate_da_xml_get_string(element, "executable"); - - if (is_executable_valid(executable)) - { - term_item = mate_da_term_item_new(); - - term_item->generic.name = mate_da_xml_get_string(element, "name"); - term_item->generic.executable = executable; - term_item->generic.command = mate_da_xml_get_string(element, "command"); - term_item->generic.icon_name = mate_da_xml_get_string(element, "icon-name"); - - term_item->exec_flag = mate_da_xml_get_string(element, "exec-flag"); - - capplet->terminals = g_list_append(capplet->terminals, term_item); - } - else - { - g_free(executable); - } - } - } - } - else if (!xmlStrncmp(section->name, (const xmlChar*) "music-players", strlen("music-players"))) - { - for (element = section->children; element != NULL; element = element->next) - { - if (!xmlStrncmp (element->name, (const xmlChar*) "music-player", strlen("music-player"))) - { - executable = mate_da_xml_get_string(element, "executable"); - - if (is_executable_valid(executable)) - { - media_item = mate_da_simple_item_new(); - - media_item->generic.name = mate_da_xml_get_string (element, "name"); - media_item->generic.executable = executable; - media_item->generic.command = mate_da_xml_get_string (element, "command"); - media_item->generic.icon_name = mate_da_xml_get_string (element, "icon-name"); - - media_item->run_in_terminal = mate_da_xml_get_bool (element, "run-in-terminal"); - - capplet->media_players = g_list_append (capplet->media_players, media_item); - } - else - { - g_free(executable); - } - } - } - } - else if (!xmlStrncmp(section->name, (const xmlChar*) "video-players", strlen("video-players"))) - { - for (element = section->children; element != NULL; element = element->next) - { - if (!xmlStrncmp (element->name, (const xmlChar*) "video-player", strlen("video-player"))) - { - executable = mate_da_xml_get_string(element, "executable"); - - if (is_executable_valid(executable)) - { - video_item = mate_da_simple_item_new(); - - video_item->generic.name = mate_da_xml_get_string (element, "name"); - video_item->generic.executable = executable; - video_item->generic.command = mate_da_xml_get_string (element, "command"); - video_item->generic.icon_name = mate_da_xml_get_string (element, "icon-name"); - - video_item->run_in_terminal = mate_da_xml_get_bool (element, "run-in-terminal"); - - capplet->video_players = g_list_append (capplet->video_players, video_item); - } - else - { - g_free(executable); - } - } - } - } - else if (!xmlStrncmp(section->name, (const xmlChar*) "image-viewers", strlen("image-viewers"))) - { - for (element = section->children; element != NULL; element = element->next) - { - if (!xmlStrncmp(element->name, (const xmlChar*) "image-viewer", strlen("image-viewer"))) - { - executable = mate_da_xml_get_string(element, "executable"); - - if (is_executable_valid(executable)) - { - image_item = mate_da_image_item_new(); - - image_item->generic.name = mate_da_xml_get_string(element, "name"); - image_item->generic.executable = executable; - image_item->generic.command = mate_da_xml_get_string(element, "command"); - image_item->generic.icon_name = mate_da_xml_get_string(element, "icon-name"); - - image_item->run_in_terminal = mate_da_xml_get_bool(element, "run-in-terminal"); - - capplet->image_viewers = g_list_append(capplet->image_viewers, image_item); - } - else - { - g_free(executable); - } - } - } - } - else if (!xmlStrncmp(section->name, (const xmlChar*) "text-editors", strlen("text-editors"))) - { - for (element = section->children; element != NULL; element = element->next) - { - if (!xmlStrncmp(element->name, (const xmlChar*) "text-editor", strlen("text-editor"))) - { - executable = mate_da_xml_get_string(element, "executable"); - - if (is_executable_valid(executable)) - { - text_item = mate_da_text_item_new(); - - text_item->generic.name = mate_da_xml_get_string(element, "name"); - text_item->generic.executable = executable; - text_item->generic.command = mate_da_xml_get_string(element, "command"); - text_item->generic.icon_name = mate_da_xml_get_string(element, "icon-name"); - - text_item->run_in_terminal = mate_da_xml_get_bool(element, "run-in-terminal"); - - capplet->text_editors = g_list_append(capplet->text_editors, text_item); - } - else - { - g_free(executable); - } - } - } - } - else if (!xmlStrncmp(section->name, (const xmlChar*) "file-managers", strlen("file-managers"))) - { - for (element = section->children; element != NULL; element = element->next) - { - if (!xmlStrncmp(element->name, (const xmlChar*) "file-manager", strlen("file-manager"))) - { - executable = mate_da_xml_get_string(element, "executable"); - - if (is_executable_valid(executable)) - { - file_item = mate_da_file_item_new(); - - file_item->generic.name = mate_da_xml_get_string(element, "name"); - file_item->generic.executable = executable; - file_item->generic.command = mate_da_xml_get_string(element, "command"); - file_item->generic.icon_name = mate_da_xml_get_string(element, "icon-name"); - - file_item->run_in_terminal = mate_da_xml_get_bool(element, "run-in-terminal"); - - capplet->file_managers = g_list_append(capplet->file_managers, file_item); - } - else - { - g_free(executable); - } - } - } - } - else if (!xmlStrncmp(section->name, (const xmlChar*) "a11y-visual", strlen("a11y-visual"))) - { - for (element = section->children; element != NULL; element = element->next) - { - if (!xmlStrncmp (element->name, (const xmlChar*) "visual", strlen("visual"))) - { - executable = mate_da_xml_get_string (element,"executable"); - - if (is_executable_valid (executable)) - { - visual_item = mate_da_visual_item_new(); - - visual_item->generic.name = mate_da_xml_get_string(element, "name"); - visual_item->generic.executable = executable; - visual_item->generic.command = mate_da_xml_get_string(element, "command"); - visual_item->generic.icon_name = mate_da_xml_get_string(element, "icon-name"); - - visual_item->run_at_startup = mate_da_xml_get_bool(element, "run-at-startup"); - - capplet->visual_ats = g_list_append(capplet->visual_ats, visual_item); - } - else - { - g_free(executable); - } - } - } - } - else if (!xmlStrncmp(section->name, (const xmlChar*) "a11y-mobility", strlen("a11y-mobility"))) - { - for (element = section->children; element != NULL; element = element->next) - { - if (!xmlStrncmp(element->name, (const xmlChar*) "mobility", strlen("mobility"))) - { - executable = mate_da_xml_get_string(element,"executable"); - - if (is_executable_valid (executable)) - { - mobility_item = mate_da_mobility_item_new (); - - mobility_item->generic.name = mate_da_xml_get_string (element, "name"); - mobility_item->generic.executable = executable; - mobility_item->generic.command = mate_da_xml_get_string (element, "command"); - mobility_item->generic.icon_name = mate_da_xml_get_string (element, "icon-name"); - - mobility_item->run_at_startup = mate_da_xml_get_bool (element, "run-at-startup"); - - capplet->mobility_ats = g_list_append (capplet->mobility_ats, mobility_item); - } - else - { - g_free (executable); - } - } - } - } - } - - xmlFreeDoc(xml_doc); -} - -void mate_da_xml_load_list(MateDACapplet* capplet) -{ - GDir* app_dir = g_dir_open(MATECC_APPS_DIR, 0, NULL); - - if (app_dir != NULL) - { - const gchar* extra_file; - gchar* filename; - - while ((extra_file = g_dir_read_name(app_dir)) != NULL) - { - filename = g_build_filename(MATECC_APPS_DIR, extra_file, NULL); - - if (g_str_has_suffix(filename, ".xml")) - { - mate_da_xml_load_xml(capplet, filename); - } - - g_free(filename); - } - - g_dir_close(app_dir); - } -} - -void mate_da_xml_free(MateDACapplet* capplet) -{ - g_list_foreach(capplet->web_browsers, (GFunc) mate_da_web_item_free, NULL); - g_list_foreach(capplet->mail_readers, (GFunc) mate_da_simple_item_free, NULL); - g_list_foreach(capplet->terminals, (GFunc) mate_da_term_item_free, NULL); - g_list_foreach(capplet->media_players, (GFunc) mate_da_simple_item_free, NULL); - g_list_foreach(capplet->video_players, (GFunc) mate_da_simple_item_free, NULL); - g_list_foreach(capplet->visual_ats, (GFunc) mate_da_visual_item_free, NULL); - g_list_foreach(capplet->mobility_ats, (GFunc) mate_da_mobility_item_free, NULL); - g_list_foreach(capplet->image_viewers, (GFunc) mate_da_image_item_free, NULL); - g_list_foreach(capplet->text_editors, (GFunc) mate_da_text_item_free, NULL); - g_list_foreach(capplet->file_managers, (GFunc) mate_da_file_item_free, NULL); - - g_list_free(capplet->web_browsers); - g_list_free(capplet->mail_readers); - g_list_free(capplet->terminals); - g_list_free(capplet->media_players); - g_list_free(capplet->video_players); - g_list_free(capplet->visual_ats); - g_list_free(capplet->mobility_ats); - g_list_free(capplet->image_viewers); - g_list_free(capplet->text_editors); - g_list_free(capplet->file_managers); - - g_object_unref(capplet->builder); - g_free(capplet); -} diff --git a/capplets/default-applications/mate-da-xml.h b/capplets/default-applications/mate-da-xml.h deleted file mode 100644 index 2016b930..00000000 --- a/capplets/default-applications/mate-da-xml.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Authors: Luca Cavalli - * - * Copyright 2005-2006 Luca Cavalli - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License - * as published by the Free Software Foundation - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - -#ifndef _MATE_DA_XML_H_ -#define _MATE_DA_XML_H_ - -void mate_da_xml_load_list(MateDACapplet* capplet); -void mate_da_xml_free(MateDACapplet* capplet); - -#endif diff --git a/capplets/default-applications/mate-default-applications-properties.ui b/capplets/default-applications/mate-default-applications-properties.ui index 0da56bc6..aa40c74b 100644 --- a/capplets/default-applications/mate-default-applications-properties.ui +++ b/capplets/default-applications/mate-default-applications-properties.ui @@ -68,6 +68,8 @@ 0 + + 1 @@ -249,6 +252,8 @@ 0 + + 1 @@ -503,6 +509,7 @@ 0 + 1 @@ -615,6 +623,7 @@ True 6 + True @@ -624,6 +633,7 @@ 0 + 1 @@ -744,6 +755,8 @@ 0 + + 1 @@ -886,6 +900,7 @@ 0 + 1 @@ -1007,6 +1023,7 @@ 0 + 1 @@ -1141,6 +1159,8 @@ 0 + + 1 @@ -1293,6 +1314,7 @@ 1 + 1 @@ -1406,6 +1429,7 @@ 1 + 1 diff --git a/capplets/default-applications/mate-default-applications.xml.in b/capplets/default-applications/mate-default-applications.xml.in deleted file mode 100644 index 5d828e57..00000000 --- a/capplets/default-applications/mate-default-applications.xml.in +++ /dev/null @@ -1,700 +0,0 @@ - - - - - - - - - - <_name>Opera - opera - opera %s - opera - false - true - opera -newpage %s - opera -newwindow %s - - - - <_name>Debian Sensible Browser - sensible-browser - sensible-browser %s - - false - false - - - - <_name>Epiphany Web Browser - epiphany - epiphany %s - web-browser - false - true - epiphany --new-tab %s - epiphany --new-window %s - - - - <_name>Galeon - galeon - galeon %s - galeon - false - true - galeon -n %s - galeon -w %s - - - - <_name>Encompass - encompass - encompass %s - encompass - false - false - - - - <_name>Firebird - mozilla-firebird - mozilla-firebird %s - - false - true - mozilla-firebird -remote "openurl(%s,new-tab)" - mozilla-firebird -remote "openurl(%s,new-window)" - - - - <_name>Firefox - firefox - firefox %s - firefox - false - true - firefox -new-tab "%s" - firefox -new-window "%s" - - - - <_name>Iceweasel - iceweasel - iceweasel %s - iceweasel - false - true - iceweasel -new-tab "%s" - iceweasel -new-window "%s" - - - - <_name>Mozilla 1.6 - mozilla-1.6 - mozilla-1.6 %s - mozilla-icon - false - true - mozilla-1.6 -remote "openurl(%s,new-tab)" - mozilla-1.6 -remote "openurl(%s,new-window)" - - - - <_name>Mozilla - mozilla - mozilla %s - mozilla-icon - false - true - mozilla -remote "openurl(%s,new-tab)" - mozilla -remote "openurl(%s,new-window)" - - - - <_name>SeaMonkey - seamonkey - seamonkey %s - seamonkey - false - true - seamonkey -remote "openurl(%s,new-tab)" - seamonkey -remote "openurl(%s,new-window)" - - - - <_name>Iceape - iceape - iceape %s - iceape - false - true - iceape -remote "openurl(%s,new-tab)" - iceape -remote "openurl(%s,new-window)" - - - - <_name>Netscape Communicator - netscape - netscape %s - netscape - false - true - netscape -remote "openurl(%s,new-tab)" - netscape -remote "openurl(%s,new-window)" - - - - <_name>Konqueror - konqueror - konqueror %s - konqueror - false - false - - - - <_name>Midori - midori - midori %s - midori - false - false - - - - <_name>Chromium - chromium - chromium %s - chromium - false - false - - - - <_name>Chromium - chromium-browser - chromium-browser %s - chromium - false - false - - - - <_name>Google Chrome - google-chrome - google-chrome %s - google-chrome - false - false - - - - - - - - <_name>Thunderbird - thunderbird - thunderbird %s - thunderbird - false - - - - <_name>Evolution Mail Reader - evolution - evolution %s - evolution - false - - - - <_name>Balsa - balsa - balsa -m %s - mate-balsa2 - false - - - - <_name>KMail - kmail - kmail %s - kmail - false - - - - <_name>Icedove - icedove - icedove %s - icedove - false - - - - <_name>Mozilla Thunderbird - mozilla-thunderbird - mozilla-thunderbird %s - thunderbird - false - - - - <_name>Mozilla Mail - mozilla - mozilla -mail %s - mozilla-mail-icon - false - - - - <_name>SeaMonkey Mail - seamonkey - seamonkey -mail %s - seamonkey - false - - - - <_name>Iceape Mail - iceape - iceape -mail %s - iceape - false - - - - <_name>Mutt - mutt - mutt %s - application-x-executable - true - - - - <_name>Claws Mail - claws-mail - claws-mail --compose %s - claws-mail - false - - - - <_name>Sylpheed - sylpheed - sylpheed --compose %s - sylpheed - false - - - - - - - - <_name>MATE file manager - caja - false - caja %s - file-manager - - - - <_name>Nautilus - nautilus - false - nautilus %s - nautilus - - - - <_name>Thunar - Thunar - false - thunar %s - Thunar - - - - - - - <_name>Debian Terminal Emulator - x-terminal-emulator - x-terminal-emulator - application-x-executable - -e - - - - <_name>MATE Terminal - mate-terminal - mate-terminal - utilities-terminal - -x - - - - <_name>GNOME Terminal - gnome-terminal - gnome-terminal - gnome-terminal - -x - - - - <_name>Terminator - terminator - terminator - terminator - -x - - - - <_name>Standard XTerminal - xterm - xterm - application-x-executable - -e - - - - <_name>NXterm - nxterm - nxterm - application-x-executable - -e - - - - <_name>RXVT - rxvt - rxvt - application-x-executable - -e - - - - <_name>aterm - aterm - aterm - application-x-executable - -e - - - - <_name>ETerm - ETerm - ETerm - application-x-executable - -e - - - - <_name>Konsole - konsole - konsole - konsole - -e - - - - <_name>Terminal - terminal - terminal - utilities-terminal - -e - - - - <_name>Sakura - sakura - sakura - terminal-tango - -e - - - - - - - <_name>MATE image viewer - eom - eog %s - eom - false - - - - <_name>Eye of GNOME - eog - eog %s - eog - false - - - - <_name>Shotwell - shotwell - shotwell %s - shotwell - false - - - - <_name>MComix - mcomix - mcomix %s - mcomix - false - - - - <_name>gThumb - gthumb - gthumb %s - gthumb - false - - - - <_name>Gwenview - gwenview - gwenview %s - gwenview - false - - - - <_name>Ristretto - ristretto - ristretto %s - ristretto - false - - - - - - - - - <_name>DeaDBeeF - deadbeef - deadbeef %s - deadbeef - false - - - - <_name>VLC - vlc - vlc %s - vlc - false - - - - <_name>Rhythmbox Music Player - rhythmbox - rhythmbox - rhythmbox - false - - - - <_name>Totem Movie Player - totem - totem - totem - false - - - - <_name>Banshee Music Player - banshee - banshee - music-player-banshee - false - - - - <_name>Muine Music Player - muine - muine - muine - false - - - - - <_name>Listen - listen - listen - listen - false - - - - - - - - - <_name>VLC - vlc - vlc %s - vlc - false - - - - <_name>Totem Movie Player - totem - totem - totem - false - - - - - - - - <_name>Gedit - gedit - gedit %s - accessories-text-editor - false - - - - <_name>MATE text editor - pluma - pluma %s - accessories-text-editor - false - - - - - - <_name>leafpad - leafpad - leafpad %s - leafpad - false - - - - - - - - - - - <_name>Orca - orca - orca - orca - false - - - <_name>Orca with Magnifier - orca - orca -e magnifier - orca - false - - - <_name>Linux Screen Reader - lsr - lsr - lsr - false - - - <_name>Linux Screen Reader with Magnifier - lsr - lsr -p mag - lsr - false - - - <_name>Gnopernicus - gnopernicus - gnopernicus - icon-accessibility - false - - - <_name>Gnopernicus with Magnifier - gnopernicus - gnopernicus -m - icon-accessibility - false - - - <_name>MATE Magnifier without Screen Reader - magnifier - magnifier -m - mate-searchtool - false - - - <_name>KDE Magnifier without Screen Reader - kmag - kmag - mate-searchtool - false - - - - - - - <_name>MATE OnScreen Keyboard - gok - gok - accessibility-keyboard-capplet - false - - - <_name>Dasher - dasher - dasher - mate-searchtool - false - - - onBoard - onboard - onboard - onboard - false - - - - -- cgit v1.2.1