From ff12c2d9036c10a14e95e617184f357547340be8 Mon Sep 17 00:00:00 2001 From: Jehan Date: Tue, 3 Jul 2018 18:31:43 +0200 Subject: [PATCH] app: a skeleton for the extension GUI. This is using GTK+3 widgets, so I make sure to keep it well separated from core code. The gimp-2-10 version will have to rework the GUI, but the GtkListBox and GtkSwitch are nice and make things easier, so it is worth using them here). --- app/actions/dialogs-actions.c | 8 +- app/dialogs/Makefile.am | 2 + app/dialogs/dialogs-constructors.c | 9 ++ app/dialogs/dialogs-constructors.h | 4 + app/dialogs/dialogs.c | 2 + app/dialogs/extensions-dialog.c | 164 +++++++++++++++++++++++++++++ app/dialogs/extensions-dialog.h | 28 +++++ app/widgets/gimphelp-ids.h | 5 + menus/image-menu.xml.in | 1 + 9 files changed, 222 insertions(+), 1 deletion(-) create mode 100644 app/dialogs/extensions-dialog.c create mode 100644 app/dialogs/extensions-dialog.h diff --git a/app/actions/dialogs-actions.c b/app/actions/dialogs-actions.c index c95fb36a0e..3c1499df35 100644 --- a/app/actions/dialogs-actions.c +++ b/app/actions/dialogs-actions.c @@ -293,7 +293,13 @@ static const GimpStringActionEntry dialogs_toplevel_actions[] = NC_("dialogs-action", "_Search and Run a Command"), "slash", NC_("dialogs-action", "Search commands by keyword, and run them"), "gimp-action-search-dialog", - GIMP_HELP_ACTION_SEARCH_DIALOG } + GIMP_HELP_ACTION_SEARCH_DIALOG }, + + { "dialogs-extensions", GIMP_ICON_PLUGIN, + NC_("dialogs-action", "Manage _Extensions"), NULL, + NC_("dialogs-action", "Manage Extensions: search, install, uninstall, update."), + "gimp-extensions-dialog", + GIMP_HELP_EXTENSIONS_DIALOG } }; diff --git a/app/dialogs/Makefile.am b/app/dialogs/Makefile.am index e2b399a9f9..7001fa57e9 100644 --- a/app/dialogs/Makefile.am +++ b/app/dialogs/Makefile.am @@ -35,6 +35,8 @@ libappdialogs_a_sources = \ convert-precision-dialog.h \ data-delete-dialog.c \ data-delete-dialog.h \ + extensions-dialog.c \ + extensions-dialog.h \ fade-dialog.c \ fade-dialog.h \ file-open-dialog.c \ diff --git a/app/dialogs/dialogs-constructors.c b/app/dialogs/dialogs-constructors.c index 1f0a7ab0be..de631fdd91 100644 --- a/app/dialogs/dialogs-constructors.c +++ b/app/dialogs/dialogs-constructors.c @@ -144,6 +144,15 @@ dialogs_preferences_get (GimpDialogFactory *factory, return preferences_dialog_create (context->gimp); } +GtkWidget * +dialogs_extensions_get (GimpDialogFactory *factory, + GimpContext *context, + GimpUIManager *ui_manager, + gint view_size) +{ + return extensions_dialog_new (context->gimp); +} + GtkWidget * dialogs_keyboard_shortcuts_get (GimpDialogFactory *factory, GimpContext *context, diff --git a/app/dialogs/dialogs-constructors.h b/app/dialogs/dialogs-constructors.h index 6c86557bd9..021c80bbad 100644 --- a/app/dialogs/dialogs-constructors.h +++ b/app/dialogs/dialogs-constructors.h @@ -45,6 +45,10 @@ GtkWidget * dialogs_preferences_get (GimpDialogFactory *factory, GimpContext *context, GimpUIManager *ui_manager, gint view_size); +GtkWidget * dialogs_extensions_get (GimpDialogFactory *factory, + GimpContext *context, + GimpUIManager *ui_manager, + gint view_size); GtkWidget * dialogs_input_devices_get (GimpDialogFactory *factory, GimpContext *context, GimpUIManager *ui_manager, diff --git a/app/dialogs/dialogs.c b/app/dialogs/dialogs.c index c3c2707def..a40317761e 100644 --- a/app/dialogs/dialogs.c +++ b/app/dialogs/dialogs.c @@ -290,6 +290,8 @@ static const GimpDialogFactoryEntry entries[] = dialogs_close_all_get, TRUE, FALSE, FALSE), TOPLEVEL ("gimp-quit-dialog", dialogs_quit_get, TRUE, FALSE, FALSE), + TOPLEVEL ("gimp-extensions-dialog", + dialogs_extensions_get, TRUE, TRUE, TRUE), /* docks */ DOCK ("gimp-dock", diff --git a/app/dialogs/extensions-dialog.c b/app/dialogs/extensions-dialog.c new file mode 100644 index 0000000000..7eb5f3e1dc --- /dev/null +++ b/app/dialogs/extensions-dialog.c @@ -0,0 +1,164 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis + * + * extension-dialog.c + * Copyright (C) 2018 Jehan + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * 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, see . + */ + +#include "config.h" + +#include +#include +#include + +#include "libgimpwidgets/gimpwidgets.h" + +#include "dialogs-types.h" + +#include "core/gimp.h" +#include "core/gimpextensionmanager.h" +#include "core/gimpextension.h" + +#include "widgets/gimphelp-ids.h" +#include "widgets/gimpprefsbox.h" + +#include "extensions-dialog.h" + +#include "gimp-intl.h" + +static void extensions_dialog_response (GtkWidget *widget, + gint response_id, + GtkWidget *dialog); + +/* public function */ + +GtkWidget * +extensions_dialog_new (Gimp *gimp) +{ + GtkWidget *dialog; + GtkWidget *prefs_box; + GtkWidget *vbox; + GtkWidget *widget; + const GList *extensions; + GList *iter; + GtkTreeIter top_iter; + + dialog = gimp_dialog_new (_("Extensions"), "gimp-extensions", + NULL, 0, NULL, + GIMP_HELP_EXTENSIONS_DIALOG, + _("_OK"), GTK_RESPONSE_OK, + NULL); + + g_signal_connect (dialog, "response", + G_CALLBACK (extensions_dialog_response), + dialog); + + prefs_box = gimp_prefs_box_new (); + gtk_container_set_border_width (GTK_CONTAINER (prefs_box), 12); + gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), + prefs_box, TRUE, TRUE, 0); + gtk_widget_show (prefs_box); + + vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box), + "system-software-install", + /*"gimp-extensions-installed",*/ + _("Installed Extensions"), + _("Installed Extensions"), + GIMP_HELP_EXTENSIONS_INSTALLED, + NULL, + &top_iter); + + widget = gtk_list_box_new (); + gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 1); + gtk_widget_show (widget); + + extensions = gimp_extension_manager_get_user_extensions (gimp->extension_manager); + iter = (GList *) extensions; + + for (; iter; iter = iter->next) + { + GimpExtension *extension = iter->data; + GtkWidget *frame; + GtkWidget *hbox; + GtkWidget *onoff; + + frame = gtk_frame_new (gimp_extension_get_name (extension)); + gtk_container_add (GTK_CONTAINER (widget), frame); + gtk_widget_show (frame); + + hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 1); + gtk_container_add (GTK_CONTAINER (frame), hbox); + gtk_widget_show (hbox); + + if (gimp_extension_get_comment (extension)) + { + GtkWidget *desc = gtk_text_view_new (); + GtkTextBuffer *buffer; + + buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (desc)); + gtk_text_buffer_set_text (buffer, + gimp_extension_get_comment (extension), + -1); + gtk_text_view_set_editable (GTK_TEXT_VIEW (desc), FALSE); + gtk_box_pack_start (GTK_BOX (hbox), desc, TRUE, TRUE, 1); + gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (desc), + GTK_WRAP_WORD_CHAR); + gtk_widget_show (desc); + } + + onoff = gtk_switch_new (); + gtk_switch_set_active (GTK_SWITCH (onoff), + gimp_extension_manager_is_active (gimp->extension_manager, + gimp_object_get_name (extension))); + gtk_box_pack_end (GTK_BOX (hbox), onoff, FALSE, FALSE, 1); + gtk_widget_show (onoff); + } + + /* TODO: system extensions show in a similar list except that they + * cannot be uninstalled, yet they can be deactivated as well. + * Also you can override a system extension by installing another + * version (same id, same extension). + */ + vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box), + "system-software-install", + _("System Extensions"), + _("System Extensions"), + GIMP_HELP_EXTENSIONS_SYSTEM, + NULL, + &top_iter); + + + /* TODO: provide a search box and a list of uninstalled extension from + * a remote repository list. + */ + vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box), + "system-software-install", + _("Search Extensions"), + _("Search Extensions"), + GIMP_HELP_EXTENSIONS_INSTALL, + NULL, + &top_iter); + return dialog; +} + + +static void +extensions_dialog_response (GtkWidget *widget, + gint response_id, + GtkWidget *dialog) +{ + gtk_widget_destroy (dialog); +} diff --git a/app/dialogs/extensions-dialog.h b/app/dialogs/extensions-dialog.h new file mode 100644 index 0000000000..8eb668e8ad --- /dev/null +++ b/app/dialogs/extensions-dialog.h @@ -0,0 +1,28 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * extension-dialog.h + * Copyright (C) 2018 Jehan + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * 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, see . + */ + +#ifndef __EXTENSIONS_DIALOG_H__ +#define __EXTENSIONS_DIALOG_H__ + + +GtkWidget * extensions_dialog_new (Gimp *gimp); + + +#endif /* __EXTENSIONS_DIALOG_H__ */ diff --git a/app/widgets/gimphelp-ids.h b/app/widgets/gimphelp-ids.h index 837a9ed0e1..30de3a51f0 100644 --- a/app/widgets/gimphelp-ids.h +++ b/app/widgets/gimphelp-ids.h @@ -737,4 +737,9 @@ #define GIMP_HELP_CONTROLLER_MOUSE "gimp-controller-mouse" #define GIMP_HELP_CONTROLLER_WHEEL "gimp-controller-wheel" +#define GIMP_HELP_EXTENSIONS_DIALOG "gimp-extensions-dialog" +#define GIMP_HELP_EXTENSIONS_INSTALLED "gimp-extensions-installed" +#define GIMP_HELP_EXTENSIONS_SYSTEM "gimp-extensions-system" +#define GIMP_HELP_EXTENSIONS_INSTALL "gimp-extensions-install" + #endif /* __GIMP_HELP_IDS_H__ */ diff --git a/menus/image-menu.xml.in b/menus/image-menu.xml.in index 75bc1886fa..33c8270805 100644 --- a/menus/image-menu.xml.in +++ b/menus/image-menu.xml.in @@ -228,6 +228,7 @@ +