From 097271c479a329cdc53cb0be03e1d8b819344624 Mon Sep 17 00:00:00 2001 From: Stefano Karapetsas Date: Fri, 16 May 2014 10:47:04 +0200 Subject: default-applications: Add support for office applications --- capplets/default-applications/mate-da-capplet.c | 58 ++++++ capplets/default-applications/mate-da-capplet.h | 6 + .../mate-default-applications-properties.ui | 224 ++++++++++++++++++++- 3 files changed, 286 insertions(+), 2 deletions(-) diff --git a/capplets/default-applications/mate-da-capplet.c b/capplets/default-applications/mate-da-capplet.c index 7461fe0b..e9bcee9d 100644 --- a/capplets/default-applications/mate-da-capplet.c +++ b/capplets/default-applications/mate-da-capplet.c @@ -45,6 +45,9 @@ enum { DA_TYPE_IMAGE, DA_TYPE_TEXT, DA_TYPE_FILE, + DA_TYPE_DOCUMENT, + DA_TYPE_WORD, + DA_TYPE_SPREADSHEET, DA_N_COLUMNS }; @@ -123,6 +126,22 @@ set_changed(GtkComboBox* combo, MateDACapplet* capplet, GList* list, gint type) g_app_info_set_as_default_for_type(item, "image/tiff", NULL); break; + case DA_TYPE_DOCUMENT: + g_app_info_set_as_default_for_type(item, "application/pdf", NULL); + break; + + case DA_TYPE_WORD: + g_app_info_set_as_default_for_type(item, "application/vnd.oasis.opendocument.text", NULL); + g_app_info_set_as_default_for_type(item, "application/msword", NULL); + g_app_info_set_as_default_for_type(item, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", NULL); + break; + + case DA_TYPE_SPREADSHEET: + g_app_info_set_as_default_for_type(item, "application/vnd.oasis.opendocument.spreadsheet", NULL); + g_app_info_set_as_default_for_type(item, "application/vnd.ms-excel", NULL); + g_app_info_set_as_default_for_type(item, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", NULL); + break; + case DA_TYPE_TERMINAL: g_settings_set_string (capplet->terminal_settings, TERMINAL_KEY, g_app_info_get_executable (item)); break; @@ -160,6 +179,9 @@ close_cb(GtkWidget* window, gint response, MateDACapplet* capplet) set_changed(GTK_COMBO_BOX(capplet->visual_combo_box), capplet, capplet->visual_ats, DA_TYPE_VISUAL); set_changed(GTK_COMBO_BOX(capplet->mobility_combo_box), capplet, capplet->mobility_ats, DA_TYPE_MOBILITY); set_changed(GTK_COMBO_BOX(capplet->image_combo_box), capplet, capplet->image_viewers, DA_TYPE_IMAGE); + set_changed(GTK_COMBO_BOX(capplet->document_combo_box), capplet, capplet->document_viewers, DA_TYPE_DOCUMENT); + set_changed(GTK_COMBO_BOX(capplet->word_combo_box), capplet, capplet->word_editors, DA_TYPE_WORD); + set_changed(GTK_COMBO_BOX(capplet->spreadsheet_combo_box), capplet, capplet->spreadsheet_editors, DA_TYPE_SPREADSHEET); gtk_widget_destroy(window); gtk_main_quit(); @@ -227,6 +249,24 @@ image_combo_changed_cb(GtkComboBox* combo, MateDACapplet* capplet) set_changed(combo, capplet, capplet->image_viewers, DA_TYPE_IMAGE); } +static void +document_combo_changed_cb(GtkComboBox* combo, MateDACapplet* capplet) +{ + set_changed(combo, capplet, capplet->document_viewers, DA_TYPE_DOCUMENT); +} + +static void +word_combo_changed_cb(GtkComboBox* combo, MateDACapplet* capplet) +{ + set_changed(combo, capplet, capplet->word_editors, DA_TYPE_WORD); +} + +static void +spreadsheet_combo_changed_cb(GtkComboBox* combo, MateDACapplet* capplet) +{ + set_changed(combo, capplet, capplet->spreadsheet_editors, DA_TYPE_SPREADSHEET); +} + static void refresh_combo_box_icons(GtkIconTheme* theme, GtkComboBox* combo_box, GList* app_list) { @@ -281,6 +321,9 @@ static struct { {"video_image", "video-x-generic"}, {"text_image", "text-editor"}, {"terminal_image", "terminal"}, + {"document_image", "application-pdf"}, + {"word_image", "office-document"}, + {"spreadsheet_image", "office-spreadsheet"}, }; /* Callback for icon theme change */ @@ -313,6 +356,9 @@ theme_changed_cb(GtkIconTheme* theme, MateDACapplet* capplet) refresh_combo_box_icons(theme, GTK_COMBO_BOX(capplet->mobility_combo_box), capplet->mobility_ats); refresh_combo_box_icons(theme, GTK_COMBO_BOX(capplet->file_combo_box), capplet->file_managers); refresh_combo_box_icons(theme, GTK_COMBO_BOX(capplet->text_combo_box), capplet->text_editors); + refresh_combo_box_icons(theme, GTK_COMBO_BOX(capplet->document_combo_box), capplet->document_viewers); + refresh_combo_box_icons(theme, GTK_COMBO_BOX(capplet->word_combo_box), capplet->word_editors); + refresh_combo_box_icons(theme, GTK_COMBO_BOX(capplet->spreadsheet_combo_box), capplet->spreadsheet_editors); } static void @@ -518,6 +564,9 @@ show_dialog(MateDACapplet* capplet, const gchar* start_page) capplet->text_combo_box = get_widget("text_combobox"); capplet->file_combo_box = get_widget("filemanager_combobox"); capplet->image_combo_box = get_widget("image_combobox"); + capplet->document_combo_box = get_widget("document_combobox"); + capplet->word_combo_box = get_widget("word_combobox"); + capplet->spreadsheet_combo_box = get_widget("spreadsheet_combobox"); capplet->visual_startup_checkbutton = get_widget("visual_start_checkbutton"); capplet->mobility_startup_checkbutton = get_widget("mobility_start_checkbutton"); @@ -533,6 +582,9 @@ show_dialog(MateDACapplet* capplet, const gchar* start_page) 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"); + capplet->document_viewers = g_app_info_get_all_for_type("application/pdf"); + capplet->word_editors = g_app_info_get_all_for_type("application/vnd.oasis.opendocument.text"); + capplet->spreadsheet_editors = g_app_info_get_all_for_type("application/vnd.oasis.opendocument.spreadsheet"); capplet->visual_ats = NULL; capplet->visual_ats = fill_list_from_desktop_file (capplet->visual_ats, APPLICATIONSDIR "/orca.desktop"); @@ -571,6 +623,9 @@ show_dialog(MateDACapplet* capplet, const gchar* start_page) fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->file_combo_box), capplet->file_managers, "inode/directory"); fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->visual_combo_box), capplet->visual_ats, "visual"); fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->mobility_combo_box), capplet->mobility_ats, "mobility"); + fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->document_combo_box), capplet->document_viewers, "application/pdf"); + fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->word_combo_box), capplet->word_editors, "application/vnd.oasis.opendocument.text"); + fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->spreadsheet_combo_box), capplet->spreadsheet_editors, "application/vnd.oasis.opendocument.spreadsheet"); 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); @@ -582,6 +637,9 @@ show_dialog(MateDACapplet* capplet, const gchar* start_page) g_signal_connect(capplet->image_combo_box, "changed", G_CALLBACK(image_combo_changed_cb), capplet); g_signal_connect(capplet->text_combo_box, "changed", G_CALLBACK(text_combo_changed_cb), capplet); g_signal_connect(capplet->file_combo_box, "changed", G_CALLBACK(file_combo_changed_cb), capplet); + g_signal_connect(capplet->document_combo_box, "changed", G_CALLBACK(document_combo_changed_cb), capplet); + g_signal_connect(capplet->word_combo_box, "changed", G_CALLBACK(word_combo_changed_cb), capplet); + g_signal_connect(capplet->spreadsheet_combo_box, "changed", G_CALLBACK(spreadsheet_combo_changed_cb), capplet); g_settings_bind (capplet->mobility_settings, MOBILITY_STARTUP_KEY, capplet->mobility_startup_checkbutton, "active", G_SETTINGS_BIND_DEFAULT); g_settings_bind (capplet->visual_settings, VISUAL_STARTUP_KEY, capplet->visual_startup_checkbutton, "active", G_SETTINGS_BIND_DEFAULT); diff --git a/capplets/default-applications/mate-da-capplet.h b/capplets/default-applications/mate-da-capplet.h index cd9f2afc..5a7d7ec0 100644 --- a/capplets/default-applications/mate-da-capplet.h +++ b/capplets/default-applications/mate-da-capplet.h @@ -52,6 +52,9 @@ typedef struct _MateDACapplet { GtkWidget* file_combo_box; GtkWidget* text_combo_box; GtkWidget* image_combo_box; + GtkWidget* document_combo_box; + GtkWidget* word_combo_box; + GtkWidget* spreadsheet_combo_box; /* Web Browser * at the moment default,new_win,new_tab arent used */ @@ -119,6 +122,9 @@ typedef struct _MateDACapplet { GList* file_managers; GList* text_editors; GList* image_viewers; + GList* document_viewers; + GList* word_editors; + GList* spreadsheet_editors; /* Settings objects */ GSettings* terminal_settings; diff --git a/capplets/default-applications/mate-default-applications-properties.ui b/capplets/default-applications/mate-default-applications-properties.ui index 1b3963a0..d374ccfd 100644 --- a/capplets/default-applications/mate-default-applications-properties.ui +++ b/capplets/default-applications/mate-default-applications-properties.ui @@ -714,6 +714,226 @@ False + + + + True + 12 + 18 + + + + + True + 6 + + + True + 0 + Document Viewer + + + + + + False + False + 0 + + + + + True + 12 + + + True + 0 + + + False + False + 0 + + + + + True + 6 + + + True + + + False + 0 + + + + + 1 + + + + + 1 + + + + + False + 0 + + + + + + + + True + 6 + + + True + 0 + Word Processor + + + + + + False + False + 0 + + + + + True + 12 + + + True + 0 + + + False + False + 0 + + + + + True + 6 + + + True + + + False + 0 + + + + + 1 + + + + + 1 + + + + + False + 1 + + + + + + + + True + 6 + + + True + 0 + Spreadsheet Editor + + + + + + False + False + 0 + + + + + True + 12 + + + True + 0 + + + False + False + 0 + + + + + True + 6 + + + True + + + False + 0 + + + + + 1 + + + + + 1 + + + + + False + 2 + + + + + + 3 + + + + + True + Office + + + 2 + False + + + True @@ -873,7 +1093,7 @@ - 3 + 4 @@ -882,7 +1102,7 @@ Accessibility - 3 + 4 False -- cgit v1.2.1