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).
This commit is contained in:
Jehan 2018-07-03 18:31:43 +02:00
parent 20b399e9bf
commit ff12c2d903
9 changed files with 222 additions and 1 deletions

View File

@ -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 }
};

View File

@ -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 \

View File

@ -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,

View File

@ -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,

View File

@ -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",

View File

@ -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 <jehan@gimp.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <cairo-gobject.h>
#include <gegl.h>
#include <gtk/gtk.h>
#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);
}

View File

@ -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 <jehan@gimp.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef __EXTENSIONS_DIALOG_H__
#define __EXTENSIONS_DIALOG_H__
GtkWidget * extensions_dialog_new (Gimp *gimp);
#endif /* __EXTENSIONS_DIALOG_H__ */

View File

@ -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__ */

View File

@ -228,6 +228,7 @@
<separator />
<placeholder name="Preferences">
<menuitem action="dialogs-preferences" />
<menuitem action="dialogs-extensions" />
<menuitem action="dialogs-input-devices" />
<menuitem action="dialogs-keyboard-shortcuts" />
<menuitem action="dialogs-module-dialog"/>