Commit 99746e1d authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

app/widgets/Makefile.am app/widgets/widgets-types.h new files implementing

2003-10-10  Michael Natterer  <mitch@gimp.org>

	* app/widgets/Makefile.am
	* app/widgets/widgets-types.h
	* app/widgets/gimpdocked.[ch]: new files implementing
	GimpDockedInterface, a GTypeInterface which must be implemented by
	all widgets which want to be packed into a GimpDockable. Has
	virtual functions similar to the ones GimpDockable had.

	* app/widgets/gimpdockable.[ch]: removed all virtual functions and
	all function pointers from the instance struct (also the ones just
	added in the commit below). Make sure only widgets implementing
	the GimpDockedIface are added and simply call the child's
	GimpDocked functions where we used to call our own virtual
	functions and function pointers.

	* app/widgets/gimpcoloreditor.c
	* app/widgets/gimpcontainereditor.c
	* app/widgets/gimpcontainergridview.c
	* app/widgets/gimpcontainerview.c
	* app/widgets/gimpeditor.c
	* app/widgets/gimpimageeditor.c
	* app/widgets/gimpitemtreeview.c
	* app/widgets/gimpsessioninfo.c
	* app/widgets/gimptooloptionseditor.c
	* app/display/gimpnavigationview.c: implement GimpDockedIface.

	* app/gui/dialogs-constructors.c: removed all that get_preview_func(),
	set_context_func() etc. cruft since that's done by GimpDockedIface.
	It's really a file of constructors now.

	* app/gui/dialogs-menu.c: changed accordingly.

	* app/widgets/gimpimagedock.c: forgotten in the commit below.
parent 0ca8e5ef
2003-10-10 Michael Natterer <mitch@gimp.org>
* app/widgets/Makefile.am
* app/widgets/widgets-types.h
* app/widgets/gimpdocked.[ch]: new files implementing
GimpDockedInterface, a GTypeInterface which must be implemented by
all widgets which want to be packed into a GimpDockable. Has
virtual functions similar to the ones GimpDockable had.
* app/widgets/gimpdockable.[ch]: removed all virtual functions and
all function pointers from the instance struct (also the ones just
added in the commit below). Make sure only widgets implementing
the GimpDockedIface are added and simply call the child's
GimpDocked functions where we used to call our own virtual
functions and function pointers.
* app/widgets/gimpcoloreditor.c
* app/widgets/gimpcontainereditor.c
* app/widgets/gimpcontainergridview.c
* app/widgets/gimpcontainerview.c
* app/widgets/gimpeditor.c
* app/widgets/gimpimageeditor.c
* app/widgets/gimpitemtreeview.c
* app/widgets/gimpsessioninfo.c
* app/widgets/gimptooloptionseditor.c
* app/display/gimpnavigationview.c: implement GimpDockedIface.
* app/gui/dialogs-constructors.c: removed all that get_preview_func(),
set_context_func() etc. cruft since that's done by GimpDockedIface.
It's really a file of constructors now.
* app/gui/dialogs-menu.c: changed accordingly.
* app/widgets/gimpimagedock.c: forgotten in the commit below.
2003-10-10 Michael Natterer <mitch@gimp.org>
 
Cleaned up session management and changed the format of sessionrc
This diff is collapsed.
......@@ -33,8 +33,10 @@
#include "config/gimpdisplayconfig.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "widgets/gimpdocked.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpnavigationpreview.h"
#include "widgets/gimppreviewrenderer.h"
......@@ -54,6 +56,11 @@
static void gimp_navigation_view_class_init (GimpNavigationViewClass *klass);
static void gimp_navigation_view_init (GimpNavigationView *view);
static void gimp_navigation_view_docked_iface_init (GimpDockedIface *docked_iface);
static void gimp_navigation_view_set_docked_context (GimpDocked *docked,
GimpContext *context,
GimpContext *prev_context);
static void gimp_navigation_view_destroy (GtkObject *object);
static GtkWidget * gimp_navigation_view_new_private (GimpDisplayShell *shell,
......@@ -103,9 +110,9 @@ static GimpEditorClass *parent_class = NULL;
GType
gimp_navigation_view_get_type (void)
{
static GType view_type = 0;
static GType type = 0;
if (! view_type)
if (! type)
{
static const GTypeInfo view_info =
{
......@@ -119,13 +126,22 @@ gimp_navigation_view_get_type (void)
0, /* n_preallocs */
(GInstanceInitFunc) gimp_navigation_view_init,
};
static const GInterfaceInfo docked_iface_info =
{
(GInterfaceInitFunc) gimp_navigation_view_docked_iface_init,
NULL, /* iface_finalize */
NULL /* iface_data */
};
type = g_type_register_static (GIMP_TYPE_EDITOR,
"GimpNavigationView",
&view_info, 0);
view_type = g_type_register_static (GIMP_TYPE_EDITOR,
"GimpNavigationView",
&view_info, 0);
g_type_add_interface_static (type, GIMP_TYPE_DOCKED,
&docked_iface_info);
}
return view_type;
return type;
}
static void
......@@ -173,6 +189,54 @@ gimp_navigation_view_init (GimpNavigationView *view)
gtk_widget_set_sensitive (GTK_WIDGET (view), FALSE);
}
static void
gimp_navigation_view_docked_iface_init (GimpDockedIface *docked_iface)
{
docked_iface->set_context = gimp_navigation_view_set_docked_context;
}
static void
gimp_navigation_view_docked_context_changed (GimpContext *context,
GimpDisplay *gdisp,
GimpNavigationView *view)
{
GimpDisplayShell *shell = NULL;
if (gdisp)
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
gimp_navigation_view_set_shell (view, shell);
}
static void
gimp_navigation_view_set_docked_context (GimpDocked *docked,
GimpContext *context,
GimpContext *prev_context)
{
GimpNavigationView *view = GIMP_NAVIGATION_VIEW (docked);
GimpDisplay *gdisp = NULL;
GimpDisplayShell *shell = NULL;
if (prev_context)
g_signal_handlers_disconnect_by_func (prev_context,
gimp_navigation_view_docked_context_changed,
view);
if (context)
{
g_signal_connect (context, "display_changed",
G_CALLBACK (gimp_navigation_view_docked_context_changed),
view);
gdisp = gimp_context_get_display (context);
}
if (gdisp)
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
gimp_navigation_view_set_shell (view, shell);
}
static void
gimp_navigation_view_destroy (GtkObject *object)
{
......
......@@ -33,8 +33,10 @@
#include "config/gimpdisplayconfig.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "widgets/gimpdocked.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpnavigationpreview.h"
#include "widgets/gimppreviewrenderer.h"
......@@ -54,6 +56,11 @@
static void gimp_navigation_view_class_init (GimpNavigationViewClass *klass);
static void gimp_navigation_view_init (GimpNavigationView *view);
static void gimp_navigation_view_docked_iface_init (GimpDockedIface *docked_iface);
static void gimp_navigation_view_set_docked_context (GimpDocked *docked,
GimpContext *context,
GimpContext *prev_context);
static void gimp_navigation_view_destroy (GtkObject *object);
static GtkWidget * gimp_navigation_view_new_private (GimpDisplayShell *shell,
......@@ -103,9 +110,9 @@ static GimpEditorClass *parent_class = NULL;
GType
gimp_navigation_view_get_type (void)
{
static GType view_type = 0;
static GType type = 0;
if (! view_type)
if (! type)
{
static const GTypeInfo view_info =
{
......@@ -119,13 +126,22 @@ gimp_navigation_view_get_type (void)
0, /* n_preallocs */
(GInstanceInitFunc) gimp_navigation_view_init,
};
static const GInterfaceInfo docked_iface_info =
{
(GInterfaceInitFunc) gimp_navigation_view_docked_iface_init,
NULL, /* iface_finalize */
NULL /* iface_data */
};
type = g_type_register_static (GIMP_TYPE_EDITOR,
"GimpNavigationView",
&view_info, 0);
view_type = g_type_register_static (GIMP_TYPE_EDITOR,
"GimpNavigationView",
&view_info, 0);
g_type_add_interface_static (type, GIMP_TYPE_DOCKED,
&docked_iface_info);
}
return view_type;
return type;
}
static void
......@@ -173,6 +189,54 @@ gimp_navigation_view_init (GimpNavigationView *view)
gtk_widget_set_sensitive (GTK_WIDGET (view), FALSE);
}
static void
gimp_navigation_view_docked_iface_init (GimpDockedIface *docked_iface)
{
docked_iface->set_context = gimp_navigation_view_set_docked_context;
}
static void
gimp_navigation_view_docked_context_changed (GimpContext *context,
GimpDisplay *gdisp,
GimpNavigationView *view)
{
GimpDisplayShell *shell = NULL;
if (gdisp)
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
gimp_navigation_view_set_shell (view, shell);
}
static void
gimp_navigation_view_set_docked_context (GimpDocked *docked,
GimpContext *context,
GimpContext *prev_context)
{
GimpNavigationView *view = GIMP_NAVIGATION_VIEW (docked);
GimpDisplay *gdisp = NULL;
GimpDisplayShell *shell = NULL;
if (prev_context)
g_signal_handlers_disconnect_by_func (prev_context,
gimp_navigation_view_docked_context_changed,
view);
if (context)
{
g_signal_connect (context, "display_changed",
G_CALLBACK (gimp_navigation_view_docked_context_changed),
view);
gdisp = gimp_context_get_display (context);
}
if (gdisp)
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
gimp_navigation_view_set_shell (view, shell);
}
static void
gimp_navigation_view_destroy (GtkObject *object)
{
......
This diff is collapsed.
......@@ -31,6 +31,7 @@
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpdockable.h"
#include "widgets/gimpdockbook.h"
#include "widgets/gimpdocked.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpimagedock.h"
#include "widgets/gimpitemfactory.h"
......@@ -325,8 +326,10 @@ dialogs_menu_update (GtkItemFactory *factory,
else if (tab_style == GIMP_TAB_STYLE_PREVIEW_NAME)
SET_ACTIVE ("/Tab Style/Status & Text", TRUE);
SET_SENSITIVE ("/Tab Style/Current Status", dockable->get_preview_func);
SET_SENSITIVE ("/Tab Style/Status & Text", dockable->get_preview_func);
SET_SENSITIVE ("/Tab Style/Current Status",
GIMP_DOCKED_GET_INTERFACE (GTK_BIN (dockable)->child)->get_preview);
SET_SENSITIVE ("/Tab Style/Status & Text",
GIMP_DOCKED_GET_INTERFACE (GTK_BIN (dockable)->child)->get_preview);
SET_VISIBLE ("/View as Grid", view_type != -1);
SET_VISIBLE ("/View as List", view_type != -1);
......
......@@ -79,6 +79,8 @@ libappwidgets_a_sources = \
gimpdockable.h \
gimpdockbook.c \
gimpdockbook.h \
gimpdocked.c \
gimpdocked.h \
gimpdocumentview.c \
gimpdocumentview.h \
gimpdrawabletreeview.c \
......
......@@ -32,15 +32,21 @@
#include "core/gimpcontext.h"
#include "gimpcoloreditor.h"
#include "gimpdocked.h"
#include "gimp-intl.h"
static void gimp_color_editor_class_init (GimpColorEditorClass *klass);
static void gimp_color_editor_init (GimpColorEditor *editor);
static void gimp_color_editor_class_init (GimpColorEditorClass *klass);
static void gimp_color_editor_init (GimpColorEditor *editor);
static void gimp_color_editor_docked_iface_init (GimpDockedIface *docked_iface);
static void gimp_color_editor_destroy (GtkObject *object);
static void gimp_color_editor_set_docked_context (GimpDocked *docked,
GimpContext *context,
GimpContext *prev_context);
static void gimp_color_editor_fg_changed (GimpContext *context,
const GimpRGB *rgb,
GimpColorEditor *editor);
......@@ -68,9 +74,9 @@ static GimpEditorClass *parent_class = NULL;
GType
gimp_color_editor_get_type (void)
{
static GType editor_type = 0;
static GType type = 0;
if (! editor_type)
if (! type)
{
static const GTypeInfo editor_info =
{
......@@ -84,13 +90,22 @@ gimp_color_editor_get_type (void)
0, /* n_preallocs */
(GInstanceInitFunc) gimp_color_editor_init,
};
static const GInterfaceInfo docked_iface_info =
{
(GInterfaceInitFunc) gimp_color_editor_docked_iface_init,
NULL, /* iface_finalize */
NULL /* iface_data */
};
editor_type = g_type_register_static (GIMP_TYPE_EDITOR,
"GimpColorEditor",
&editor_info, 0);
type = g_type_register_static (GIMP_TYPE_EDITOR,
"GimpColorEditor",
&editor_info, 0);
g_type_add_interface_static (type, GIMP_TYPE_DOCKED,
&docked_iface_info);
}
return editor_type;
return type;
}
static void
......@@ -270,6 +285,12 @@ gimp_color_editor_init (GimpColorEditor *editor)
}
}
static void
gimp_color_editor_docked_iface_init (GimpDockedIface *docked_iface)
{
docked_iface->set_context = gimp_color_editor_set_docked_context;
}
static void
gimp_color_editor_destroy (GtkObject *object)
{
......@@ -283,6 +304,14 @@ gimp_color_editor_destroy (GtkObject *object)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
static void
gimp_color_editor_set_docked_context (GimpDocked *docked,
GimpContext *context,
GimpContext *prev_context)
{
gimp_color_editor_set_context (GIMP_COLOR_EDITOR (docked), context);
}
/* public functions */
......
......@@ -34,13 +34,15 @@
#include "gimpcontainereditor.h"
#include "gimpcontainergridview.h"
#include "gimpcontainertreeview.h"
#include "gimpdocked.h"
#include "gimpitemfactory.h"
#include "gimpmenufactory.h"
#include "gimppreviewrenderer.h"
static void gimp_container_editor_class_init (GimpContainerEditorClass *klass);
static void gimp_container_editor_init (GimpContainerEditor *view);
static void gimp_container_editor_class_init (GimpContainerEditorClass *klass);
static void gimp_container_editor_init (GimpContainerEditor *view);
static void gimp_container_editor_docked_iface_init (GimpDockedIface *docked_iface);
static gboolean gimp_container_editor_select_item (GtkWidget *widget,
GimpViewable *viewable,
......@@ -57,6 +59,15 @@ static void gimp_container_editor_context_item (GtkWidget *widge
static void gimp_container_editor_real_context_item(GimpContainerEditor *editor,
GimpViewable *viewable);
static GtkWidget * gimp_container_editor_get_preview (GimpDocked *docked,
GimpContext *context,
GtkIconSize size);
static void gimp_container_editor_set_context (GimpDocked *docked,
GimpContext *context,
GimpContext *prev_context);
static GimpItemFactory * gimp_container_editor_get_menu (GimpDocked *docked,
gpointer *item_factory_data);
static GtkVBoxClass *parent_class = NULL;
......@@ -64,9 +75,9 @@ static GtkVBoxClass *parent_class = NULL;
GType
gimp_container_editor_get_type (void)
{
static GType view_type = 0;
static GType type = 0;
if (! view_type)
if (! type)
{
static const GTypeInfo view_info =
{
......@@ -80,13 +91,22 @@ gimp_container_editor_get_type (void)
0, /* n_preallocs */
(GInstanceInitFunc) gimp_container_editor_init,
};
static const GInterfaceInfo docked_iface_info =
{
(GInterfaceInitFunc) gimp_container_editor_docked_iface_init,
NULL, /* iface_finalize */
NULL /* iface_data */
};
view_type = g_type_register_static (GTK_TYPE_VBOX,
"GimpContainerEditor",
&view_info, 0);
type = g_type_register_static (GTK_TYPE_VBOX,
"GimpContainerEditor",
&view_info, 0);
g_type_add_interface_static (type, GIMP_TYPE_DOCKED,
&docked_iface_info);
}
return view_type;
return type;
}
static void
......@@ -105,6 +125,14 @@ gimp_container_editor_init (GimpContainerEditor *view)
view->view = NULL;
}
static void
gimp_container_editor_docked_iface_init (GimpDockedIface *docked_iface)
{
docked_iface->get_preview = gimp_container_editor_get_preview;
docked_iface->set_context = gimp_container_editor_set_context;
docked_iface->get_menu = gimp_container_editor_get_menu;
}
gboolean
gimp_container_editor_construct (GimpContainerEditor *editor,
GimpViewType view_type,
......@@ -239,3 +267,35 @@ gimp_container_editor_real_context_item (GimpContainerEditor *editor,
NULL, NULL, NULL);
}
}
static GtkWidget *
gimp_container_editor_get_preview (GimpDocked *docked,
GimpContext *context,
GtkIconSize size)
{
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (docked);
return gimp_docked_get_preview (GIMP_DOCKED (editor->view),
context, size);
}
static void
gimp_container_editor_set_context (GimpDocked *docked,
GimpContext *context,
GimpContext *prev_context)
{
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (docked);
gimp_docked_set_context (GIMP_DOCKED (editor->view),
context, prev_context);
}
static GimpItemFactory *
gimp_container_editor_get_menu (GimpDocked *docked,
gpointer *item_factory_data)
{
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (docked);
return gimp_docked_get_menu (GIMP_DOCKED (editor->view),
item_factory_data);
}
......@@ -21,6 +21,8 @@
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
......@@ -34,7 +36,10 @@
#include "gimpcontainerview.h"
#include "gimpdnd.h"
#include "gimpdocked.h"
#include "gimppreview.h"
#include "gimppreviewrenderer.h"
#include "gimppropwidgets.h"
enum
......@@ -46,9 +51,10 @@ enum
};
static void gimp_container_view_class_init (GimpContainerViewClass *klass);
static void gimp_container_view_init (GimpContainerView *view,
GimpContainerViewClass *klass);
static void gimp_container_view_class_init (GimpContainerViewClass *klass);
static void gimp_container_view_init (GimpContainerView *view,
GimpContainerViewClass *klass);
static void gimp_container_view_docked_iface_init (GimpDockedIface *docked_iface);
static void gimp_container_view_destroy (GtkObject *object);
......@@ -71,6 +77,13 @@ static void gimp_container_view_reorder (GimpContainerView *view,
gint new_index,
GimpContainer *container);
static GtkWidget * gimp_container_view_get_preview (GimpDocked *docked,
GimpContext *context,
GtkIconSize size);
static void gimp_container_view_set_docked_context (GimpDocked *docked,
GimpContext *context,
GimpContext *prev_context);
static void gimp_container_view_context_changed (GimpContext *context,
GimpViewable *viewable,
GimpContainerView *view);
......@@ -90,9 +103,9 @@ static GimpEditorClass *parent_class = NULL;
GType
gimp_container_view_get_type (void)
{
static GType view_type = 0;
static GType type = 0;
if (! view_type)
if (! type)
{
static const GTypeInfo view_info =
{
......@@ -106,13 +119,22 @@ gimp_container_view_get_type (void)
0, /* n_preallocs */
(GInstanceInitFunc) gimp_container_view_init,
};
static const GInterfaceInfo docked_iface_info =
{
(GInterfaceInitFunc) gimp_container_view_docked_iface_init,
NULL, /* iface_finalize */
NULL /* iface_data */
};
type = g_type_register_static (GIMP_TYPE_EDITOR,
"GimpContainerView",
&view_info, 0);
view_type = g_type_register_static (GIMP_TYPE_EDITOR,
"GimpContainerView",
&view_info, 0);
g_type_add_interface_static (type, GIMP_TYPE_DOCKED,
&docked_iface_info);
}
return view_type;
return type;
}
static void
......@@ -219,6 +241,13 @@ gimp_container_view_destroy (GtkObject *object)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
static void
gimp_container_view_docked_iface_init (GimpDockedIface *docked_iface)
{
docked_iface->get_preview = gimp_container_view_get_preview;
docked_iface->set_context = gimp_container_view_set_docked_context;
}
void
gimp_container_view_set_container (GimpContainerView *view,
GimpContainer *container)
......@@ -688,6 +717,41 @@ gimp_container_view_reorder (GimpContainerView *view,
}
}
static void
gimp_container_view_set_docked_context (GimpDocked *docked,
GimpContext *context,
GimpContext *prev_context)
{
gimp_container_view_set_context (GIMP_CONTAINER_VIEW (docked), context);
}
static GtkWidget *
gimp_container_view_get_preview (GimpDocked *docked,
GimpContext *context,
GtkIconSize size)