diff options
author | Stefano Karapetsas <[email protected]> | 2014-11-03 15:04:19 +0100 |
---|---|---|
committer | Stefano Karapetsas <[email protected]> | 2014-11-03 15:04:19 +0100 |
commit | df913aef213e9314e8037944fdb9a44f6dc7f9cf (patch) | |
tree | f99b8f2d6565d3961db6dbf9fb88eb42ac5e6179 | |
parent | 3600fc2b4208a17217750bbce3e1928e760307fd (diff) | |
download | caja-df913aef213e9314e8037944fdb9a44f6dc7f9cf.tar.bz2 caja-df913aef213e9314e8037944fdb9a44f6dc7f9cf.tar.xz |
Add about dialog for extensions
-rw-r--r-- | libcaja-private/caja-extensions.c | 10 | ||||
-rw-r--r-- | libcaja-private/caja-extensions.h | 4 | ||||
-rw-r--r-- | src/caja-file-management-properties.c | 62 | ||||
-rw-r--r-- | src/caja-file-management-properties.ui | 4 |
4 files changed, 73 insertions, 7 deletions
diff --git a/libcaja-private/caja-extensions.c b/libcaja-private/caja-extensions.c index f553df13..cc167c5c 100644 --- a/libcaja-private/caja-extensions.c +++ b/libcaja-private/caja-extensions.c @@ -44,6 +44,10 @@ extension_new (gchar *filename, gboolean state, GObject *module) ext->filename = filename; ext->name = NULL; ext->description = NULL; + ext->author = NULL; + ext->copyright = NULL; + ext->version = NULL; + ext->website = NULL; ext->state = state; ext->module = module; @@ -53,7 +57,11 @@ extension_new (gchar *filename, gboolean state, GObject *module) { ext->name = g_key_file_get_locale_string (extension_file, CAJA_EXTENSION_GROUP, "Name", NULL, NULL); ext->description = g_key_file_get_locale_string (extension_file, CAJA_EXTENSION_GROUP, "Description", NULL, NULL); - ext->icon = g_key_file_get_locale_string (extension_file, CAJA_EXTENSION_GROUP, "Icon", NULL, NULL); + ext->icon = g_key_file_get_string (extension_file, CAJA_EXTENSION_GROUP, "Icon", NULL); + ext->author = g_key_file_get_string_list (extension_file, CAJA_EXTENSION_GROUP, "Author", NULL, NULL); + ext->copyright = g_key_file_get_string (extension_file, CAJA_EXTENSION_GROUP, "Copyright", NULL); + ext->version = g_key_file_get_string (extension_file, CAJA_EXTENSION_GROUP, "Version", NULL); + ext->website = g_key_file_get_string (extension_file, CAJA_EXTENSION_GROUP, "Website", NULL); } g_key_file_free (extension_file); g_free (extension_filename); diff --git a/libcaja-private/caja-extensions.h b/libcaja-private/caja-extensions.h index 5efcb569..01b3c819 100644 --- a/libcaja-private/caja-extensions.h +++ b/libcaja-private/caja-extensions.h @@ -32,6 +32,10 @@ typedef struct _Extension { gchar *name; gchar *description; gchar *icon; + gchar **author; + gchar *copyright; + gchar *version; + gchar *website; gboolean state; GObject *module; }Extension; diff --git a/src/caja-file-management-properties.c b/src/caja-file-management-properties.c index 9df0695b..1484aba7 100644 --- a/src/caja-file-management-properties.c +++ b/src/caja-file-management-properties.c @@ -43,6 +43,8 @@ #include <libcaja-private/caja-autorun.h> +#include <libmate-desktop/mate-aboutdialog.h> + /* string enum preferences */ #define CAJA_FILE_MANAGEMENT_PROPERTIES_DEFAULT_VIEW_WIDGET "default_view_combobox" #define CAJA_FILE_MANAGEMENT_PROPERTIES_ICON_VIEW_ZOOM_WIDGET "icon_view_zoom_combobox" @@ -613,6 +615,51 @@ out: g_free (x_content_type); } +static gulong extension_about_id = 0; + +static void +extension_about_clicked (GtkButton *button, Extension *ext) +{ + MateAboutDialog *extension_about_dialog; + + extension_about_dialog = mate_about_dialog_new(); + mate_about_dialog_set_program_name (extension_about_dialog, ext->name); + mate_about_dialog_set_comments (extension_about_dialog, ext->description); + mate_about_dialog_set_logo_icon_name (extension_about_dialog, ext->icon); + mate_about_dialog_set_copyright (extension_about_dialog, ext->copyright); + mate_about_dialog_set_authors (extension_about_dialog, ext->author); + mate_about_dialog_set_version (extension_about_dialog, ext->version); + mate_about_dialog_set_website (extension_about_dialog, ext->website); + gtk_window_set_title (GTK_WINDOW(extension_about_dialog), _("About Extension")); + gtk_dialog_run (GTK_DIALOG (extension_about_dialog)); + gtk_widget_destroy (extension_about_dialog); +} + +static void +extension_list_selection_changed (GtkTreeSelection *selection, GtkButton *about_button) +{ + GtkTreeModel *model; + GtkTreeIter iter; + Extension *ext; + + gtk_widget_set_sensitive (about_button, FALSE); + + if (extension_about_id > 0) + { + g_signal_handler_disconnect (about_button, extension_about_id); + extension_about_id = 0; + } + + if (!gtk_tree_selection_get_selected (selection, &model, &iter)) + return; + + gtk_tree_model_get (model, &iter, EXT_STRUCT_COLUMN, &ext, -1); + if (ext != NULL) { + gtk_widget_set_sensitive (about_button, TRUE); + extension_about_id = g_signal_connect (about_button, "clicked", G_CALLBACK (extension_about_clicked), ext); + } +} + static void extension_state_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data) { @@ -628,8 +675,6 @@ extension_state_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer g_object_get (G_OBJECT (cell), "active", &new_state, NULL); gtk_tree_model_get_iter_from_string (model, &iter, path_str); - - new_state ^= 1; if (&iter != NULL) @@ -762,16 +807,18 @@ caja_file_management_properties_dialog_setup_extension_page (GtkBuilder *builder GtkCellRendererToggle *toggle; GtkListStore *store; GtkTreeView *view; + GtkTreeSelection *selection; GtkTreeIter iter; GtkIconTheme *icon_theme; GdkPixbuf *ext_pixbuf_icon; + GtkButton *about_button; gchar *ext_text_info; GList *extensions; int i; - + extensions = caja_extensions_get_list (); - + view = GTK_TREE_VIEW ( gtk_builder_get_object (builder, "extension_view")); store = GTK_LIST_STORE ( @@ -826,6 +873,13 @@ caja_file_management_properties_dialog_setup_extension_page (GtkBuilder *builder if (ext_pixbuf_icon) g_object_unref (ext_pixbuf_icon); } + + about_button = GTK_BUTTON (gtk_builder_get_object (builder, "about_extension_button")); + selection = gtk_tree_view_get_selection (view); + gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); + g_signal_connect (selection, "changed", + G_CALLBACK (extension_list_selection_changed), + about_button); } static void diff --git a/src/caja-file-management-properties.ui b/src/caja-file-management-properties.ui index dbba67dd..cca1a364 100644 --- a/src/caja-file-management-properties.ui +++ b/src/caja-file-management-properties.ui @@ -2480,7 +2480,7 @@ <property name="spacing">8</property> <property name="layout_style">end</property> <child> - <object class="GtkButton" id="button1"> + <object class="GtkButton" id="about_extension_button"> <property name="label" translatable="yes">_About Extension</property> <property name="visible">True</property> <property name="sensitive">False</property> @@ -2496,7 +2496,7 @@ </packing> </child> <child> - <object class="GtkButton" id="button2"> + <object class="GtkButton" id="configure_extension_button"> <property name="label" translatable="yes">C_onfigure Extension</property> <property name="visible">True</property> <property name="sensitive">False</property> |