added a "menu_title" which is registered with each menu.

2003-09-23  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimpmenufactory.[ch]: added a "menu_title" which is
	registered with each menu.

	* app/widgets/gimpitemfactory.[ch]: added the title to the
	constructor and to the GimpItemFactory struct.

	* app/gui/menus.c: register titles with all menus.

	* app/widgets/gimpdockable.[ch]: show the tab menu, not the
	contained dialog's menu when clicking on the menu button.
	Embed the dialog's menu as submenu. Use the item_factory's
	title and the dockable's stock_id for the submenu entry.

	* app/widgets/gimpeditor.c: removed GtkWidget:popup_menu()
	implementation since that's done by GimpDockable now.

	* app/widgets/gimpdockbook.c: set the new menu item invisible
	when showing the menu as tab menu.

	* app/widgets/gimphelp-ids.h: added GIMP_HELP_DOCK_TAB_DETACH
	and renamed _TAB_REMOVE to _TAB_CLOSE.

	* app/gui/dialogs-menu.c: added the new menu entry for showing the
	dialog's sub-menu. Added a "Detach" menu item, renamed "Remove" to
	"Close". Accept both a GimpDockbook and a GimpDockable pointer as
	"data" in dialogs_menu_update().

	* app/gui/dialogs-commands.[ch]: changed accordingly. Never use
	gtk_item_factory_popup_data_from_widget() but always the "data"
	passed to the callbacks. Take care to not set the already active
	preview_size, tab_style and list/grid type in the resp. callbacks
	to avoid being called from dialogs_menu_update().

	* app/gui/dialogs-constructors.c: removed separate
	set_context_funcs and get_menu_funcs for GimpContainerView and
	GimpContainerEditor widgets and simply use
	gimp_container_view_get_by_dockable() to find the right widget.
This commit is contained in:
Michael Natterer 2003-09-23 16:17:25 +00:00 committed by Michael Natterer
parent a8ed5f6bf5
commit c5fd48f2fb
18 changed files with 703 additions and 610 deletions

View File

@ -1,3 +1,43 @@
2003-09-23 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpmenufactory.[ch]: added a "menu_title" which is
registered with each menu.
* app/widgets/gimpitemfactory.[ch]: added the title to the
constructor and to the GimpItemFactory struct.
* app/gui/menus.c: register titles with all menus.
* app/widgets/gimpdockable.[ch]: show the tab menu, not the
contained dialog's menu when clicking on the menu button.
Embed the dialog's menu as submenu. Use the item_factory's
title and the dockable's stock_id for the submenu entry.
* app/widgets/gimpeditor.c: removed GtkWidget:popup_menu()
implementation since that's done by GimpDockable now.
* app/widgets/gimpdockbook.c: set the new menu item invisible
when showing the menu as tab menu.
* app/widgets/gimphelp-ids.h: added GIMP_HELP_DOCK_TAB_DETACH
and renamed _TAB_REMOVE to _TAB_CLOSE.
* app/gui/dialogs-menu.c: added the new menu entry for showing the
dialog's sub-menu. Added a "Detach" menu item, renamed "Remove" to
"Close". Accept both a GimpDockbook and a GimpDockable pointer as
"data" in dialogs_menu_update().
* app/gui/dialogs-commands.[ch]: changed accordingly. Never use
gtk_item_factory_popup_data_from_widget() but always the "data"
passed to the callbacks. Take care to not set the already active
preview_size, tab_style and list/grid type in the resp. callbacks
to avoid being called from dialogs_menu_update().
* app/gui/dialogs-constructors.c: removed separate
set_context_funcs and get_menu_funcs for GimpContainerView and
GimpContainerEditor widgets and simply use
gimp_container_view_get_by_dockable() to find the right widget.
2003-09-23 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpdialogfactory.c

View File

@ -88,11 +88,9 @@ dialogs_add_tab_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpDockbook *dockbook;
GimpDockbook *dockbook = GIMP_DOCKBOOK (data);
dockbook = (GimpDockbook *) gtk_item_factory_popup_data_from_widget (widget);
if (dockbook && action)
if (action)
{
GtkWidget *dockable;
const gchar *identifier;
@ -118,26 +116,40 @@ dialogs_add_tab_cmd_callback (GtkWidget *widget,
}
void
dialogs_remove_tab_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
dialogs_close_tab_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpDockbook *dockbook;
GimpDockbook *dockbook = GIMP_DOCKBOOK (data);
GimpDockable *dockable;
gint page_num;
dockbook = (GimpDockbook *) gtk_item_factory_popup_data_from_widget (widget);
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
if (dockbook)
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
if (dockable)
gimp_dockbook_remove (dockbook, dockable);
}
void
dialogs_detach_tab_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpDockbook *dockbook = GIMP_DOCKBOOK (data);
GimpDockable *dockable;
gint page_num;
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
if (dockable)
{
GimpDockable *dockable;
gint page_num;
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
if (dockable)
gimp_dockbook_remove (dockbook, dockable);
/* TODO */
}
}
@ -146,85 +158,87 @@ dialogs_toggle_view_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpDockbook *dockbook;
GimpDockbook *dockbook = GIMP_DOCKBOOK (data);
GimpDockable *dockable;
GimpViewType view_type;
gint page_num;
if (! GTK_CHECK_MENU_ITEM (widget)->active)
return;
dockbook = (GimpDockbook *) gtk_item_factory_popup_data_from_widget (widget);
view_type = (GimpViewType) action;
if (dockbook)
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
if (dockable)
{
GimpDockable *dockable;
gint page_num;
GimpDialogFactoryEntry *entry;
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
entry = g_object_get_data (G_OBJECT (dockable),
"gimp-dialog-factory-entry");
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
if (dockable)
if (entry)
{
GimpDialogFactoryEntry *entry;
gchar *identifier;
gchar *substring = NULL;
entry = g_object_get_data (G_OBJECT (dockable),
"gimp-dialog-factory-entry");
identifier = g_strdup (entry->identifier);
if (entry)
substring = strstr (identifier, "grid");
if (substring && view_type == GIMP_VIEW_TYPE_GRID)
return;
if (! substring)
{
gchar *identifier;
gchar *substring = NULL;
substring = strstr (identifier, "list");
identifier = g_strdup (entry->identifier);
substring = strstr (identifier, "grid");
if (! substring)
substring = strstr (identifier, "list");
if (substring)
{
GimpContainerView *old_view;
GtkWidget *new_dockable;
gint preview_size = -1;
if (view_type == GIMP_VIEW_TYPE_LIST)
memcpy (substring, "list", 4);
else if (view_type == GIMP_VIEW_TYPE_GRID)
memcpy (substring, "grid", 4);
old_view = gimp_container_view_get_by_dockable (dockable);
if (old_view)
preview_size = old_view->preview_size;
new_dockable =
gimp_dialog_factory_dockable_new (dockbook->dock->dialog_factory,
dockbook->dock,
identifier,
preview_size);
/* Maybe gimp_dialog_factory_dockable_new() returned
* an already existing singleton dockable, so check
* if it already is attached to a dockbook.
*/
if (new_dockable && ! GIMP_DOCKABLE (new_dockable)->dockbook)
{
gimp_dockbook_add (dockbook, GIMP_DOCKABLE (new_dockable),
page_num);
gimp_dockbook_remove (dockbook, dockable);
gtk_notebook_set_current_page (GTK_NOTEBOOK (dockbook),
page_num);
}
}
g_free (identifier);
if (substring && view_type == GIMP_VIEW_TYPE_LIST)
return;
}
if (substring)
{
GimpContainerView *old_view;
GtkWidget *new_dockable;
gint preview_size = -1;
if (view_type == GIMP_VIEW_TYPE_LIST)
memcpy (substring, "list", 4);
else if (view_type == GIMP_VIEW_TYPE_GRID)
memcpy (substring, "grid", 4);
old_view = gimp_container_view_get_by_dockable (dockable);
if (old_view)
preview_size = old_view->preview_size;
new_dockable =
gimp_dialog_factory_dockable_new (dockbook->dock->dialog_factory,
dockbook->dock,
identifier,
preview_size);
/* Maybe gimp_dialog_factory_dockable_new() returned
* an already existing singleton dockable, so check
* if it already is attached to a dockbook.
*/
if (new_dockable && ! GIMP_DOCKABLE (new_dockable)->dockbook)
{
gimp_dockbook_add (dockbook, GIMP_DOCKABLE (new_dockable),
page_num);
gimp_dockbook_remove (dockbook, dockable);
gtk_notebook_set_current_page (GTK_NOTEBOOK (dockbook),
page_num);
}
}
g_free (identifier);
}
}
}
@ -234,33 +248,30 @@ dialogs_preview_size_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpDockbook *dockbook;
GimpDockbook *dockbook = GIMP_DOCKBOOK (data);
GimpDockable *dockable;
gint preview_size;
gint page_num;
if (! GTK_CHECK_MENU_ITEM (widget)->active)
return;
dockbook = (GimpDockbook *) gtk_item_factory_popup_data_from_widget (widget);
preview_size = (gint) action;
if (dockbook)
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
if (dockable)
{
GimpDockable *dockable;
gint page_num;
GimpContainerView *view;
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
view = gimp_container_view_get_by_dockable (dockable);
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
if (dockable)
if (view)
{
GimpContainerView *view;
view = gimp_container_view_get_by_dockable (dockable);
if (view)
if (view->preview_size != preview_size)
gimp_container_view_set_preview_size (view, preview_size,
view->preview_border_width);
}
@ -272,27 +283,24 @@ dialogs_tab_style_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpDockbook *dockbook;
GimpDockbook *dockbook = GIMP_DOCKBOOK (data);
GimpDockable *dockable;
GimpTabStyle tab_style;
gint page_num;
if (! GTK_CHECK_MENU_ITEM (widget)->active)
return;
dockbook = (GimpDockbook *) gtk_item_factory_popup_data_from_widget (widget);
tab_style = (gint) action;
if (dockbook)
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
if (dockable)
{
GimpDockable *dockable;
gint page_num;
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
if (dockable)
if (dockable->tab_style != tab_style)
{
GtkWidget *tab_widget;
@ -312,11 +320,9 @@ dialogs_toggle_image_menu_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpDockbook *dockbook;
GimpDockbook *dockbook = GIMP_DOCKBOOK (data);
dockbook = (GimpDockbook *) gtk_item_factory_popup_data_from_widget (widget);
if (dockbook && GIMP_IS_IMAGE_DOCK (dockbook->dock))
if (GIMP_IS_IMAGE_DOCK (dockbook->dock))
{
gimp_image_dock_set_show_image_menu (GIMP_IMAGE_DOCK (dockbook->dock),
GTK_CHECK_MENU_ITEM (widget)->active);
@ -328,11 +334,9 @@ dialogs_toggle_auto_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpDockbook *dockbook;
GimpDockbook *dockbook = GIMP_DOCKBOOK (data);
dockbook = (GimpDockbook *) gtk_item_factory_popup_data_from_widget (widget);
if (dockbook && GIMP_IS_IMAGE_DOCK (dockbook->dock))
if (GIMP_IS_IMAGE_DOCK (dockbook->dock))
{
gimp_image_dock_set_auto_follow_active (GIMP_IMAGE_DOCK (dockbook->dock),
GTK_CHECK_MENU_ITEM (widget)->active);

View File

@ -33,7 +33,10 @@ void dialogs_create_dockable_cmd_callback (GtkWidget *widget,
void dialogs_add_tab_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void dialogs_remove_tab_cmd_callback (GtkWidget *widget,
void dialogs_close_tab_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void dialogs_detach_tab_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);

View File

@ -45,6 +45,7 @@
#include "widgets/gimpcolormapeditor.h"
#include "widgets/gimpcontainergridview.h"
#include "widgets/gimpcontainertreeview.h"
#include "widgets/gimpcontainerview-utils.h"
#include "widgets/gimpdataeditor.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimperrorconsole.h"
@ -106,8 +107,6 @@ static GtkWidget * dialogs_tool_options_preview_func (GimpDockable *dockable,
static void dialogs_set_view_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_editor_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_color_editor_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_image_item_context_func (GimpDockable *dockable,
@ -119,8 +118,6 @@ static void dialogs_set_navigation_context_func (GimpDockable *dockable,
static GimpItemFactory * dialogs_get_view_menu_func (GimpDockable *dockable,
gpointer *item_factory_data);
static GimpItemFactory * dialogs_get_editor_menu_func (GimpDockable *dockable,
gpointer *item_factory_data);
static GtkWidget * dialogs_dockable_new (GtkWidget *widget,
const gchar *name,
@ -307,7 +304,7 @@ dialogs_error_console_get (GimpDialogFactory *factory,
GIMP_HELP_ERRORS_DIALOG,
NULL, NULL,
NULL,
dialogs_get_editor_menu_func);
dialogs_get_view_menu_func);
}
@ -331,8 +328,8 @@ dialogs_image_list_view_new (GimpDialogFactory *factory,
GIMP_STOCK_IMAGES,
GIMP_HELP_IMAGE_DIALOG,
NULL, NULL,
dialogs_set_editor_context_func,
dialogs_get_editor_menu_func);
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
}
GtkWidget *
@ -355,8 +352,8 @@ dialogs_brush_list_view_new (GimpDialogFactory *factory,
GIMP_STOCK_TOOL_PAINTBRUSH,
GIMP_HELP_BRUSH_DIALOG,
dialogs_viewable_preview_func, "brush",
dialogs_set_editor_context_func,
dialogs_get_editor_menu_func);
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
}
GtkWidget *
@ -378,8 +375,8 @@ dialogs_pattern_list_view_new (GimpDialogFactory *factory,
GIMP_STOCK_TOOL_BUCKET_FILL,
GIMP_HELP_PATTERN_DIALOG,
dialogs_viewable_preview_func, "pattern",
dialogs_set_editor_context_func,
dialogs_get_editor_menu_func);
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
}
GtkWidget *
@ -401,8 +398,8 @@ dialogs_gradient_list_view_new (GimpDialogFactory *factory,
GIMP_STOCK_TOOL_BLEND,
GIMP_HELP_GRADIENT_DIALOG,
dialogs_viewable_preview_func, "gradient",
dialogs_set_editor_context_func,
dialogs_get_editor_menu_func);
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
}
GtkWidget *
@ -424,8 +421,8 @@ dialogs_palette_list_view_new (GimpDialogFactory *factory,
GTK_STOCK_SELECT_COLOR,
GIMP_HELP_PALETTE_DIALOG,
dialogs_viewable_preview_func, "palette",
dialogs_set_editor_context_func,
dialogs_get_editor_menu_func);
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
}
GtkWidget *
@ -488,8 +485,8 @@ dialogs_buffer_list_view_new (GimpDialogFactory *factory,
GTK_STOCK_PASTE,
GIMP_HELP_BUFFER_DIALOG,
NULL, NULL,
dialogs_set_editor_context_func,
dialogs_get_editor_menu_func);
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
}
GtkWidget *
@ -511,8 +508,8 @@ dialogs_document_list_new (GimpDialogFactory *factory,
GTK_STOCK_OPEN,
GIMP_HELP_DOCUMENT_DIALOG,
NULL, NULL,
dialogs_set_editor_context_func,
dialogs_get_editor_menu_func);
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
}
GtkWidget *
@ -540,8 +537,8 @@ dialogs_template_list_new (GimpDialogFactory *factory,
GIMP_STOCK_TEMPLATE,
GIMP_HELP_TEMPLATE_DIALOG,
NULL, NULL,
dialogs_set_editor_context_func,
dialogs_get_editor_menu_func);
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
}
@ -565,8 +562,8 @@ dialogs_image_grid_view_new (GimpDialogFactory *factory,
GIMP_STOCK_IMAGES,
GIMP_HELP_IMAGE_DIALOG,
NULL, NULL,
dialogs_set_editor_context_func,
dialogs_get_editor_menu_func);
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
}
GtkWidget *
@ -589,8 +586,8 @@ dialogs_brush_grid_view_new (GimpDialogFactory *factory,
GIMP_STOCK_TOOL_PAINTBRUSH,
GIMP_HELP_BRUSH_DIALOG,
dialogs_viewable_preview_func, "brush",
dialogs_set_editor_context_func,
dialogs_get_editor_menu_func);
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
}
GtkWidget *
@ -612,8 +609,8 @@ dialogs_pattern_grid_view_new (GimpDialogFactory *factory,
GIMP_STOCK_TOOL_BUCKET_FILL,
GIMP_HELP_PATTERN_DIALOG,
dialogs_viewable_preview_func, "pattern",
dialogs_set_editor_context_func,
dialogs_get_editor_menu_func);
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
}
GtkWidget *
@ -635,8 +632,8 @@ dialogs_gradient_grid_view_new (GimpDialogFactory *factory,
GIMP_STOCK_TOOL_BLEND,
GIMP_HELP_GRADIENT_DIALOG,
dialogs_viewable_preview_func, "gradient",
dialogs_set_editor_context_func,
dialogs_get_editor_menu_func);
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
}
GtkWidget *
@ -658,8 +655,8 @@ dialogs_palette_grid_view_new (GimpDialogFactory *factory,
GTK_STOCK_SELECT_COLOR,
GIMP_HELP_PALETTE_DIALOG,
dialogs_viewable_preview_func, "palette",
dialogs_set_editor_context_func,
dialogs_get_editor_menu_func);
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
}
GtkWidget *
@ -722,8 +719,8 @@ dialogs_buffer_grid_view_new (GimpDialogFactory *factory,
GTK_STOCK_PASTE,
GIMP_HELP_BUFFER_DIALOG,
NULL, NULL,
dialogs_set_editor_context_func,
dialogs_get_editor_menu_func);
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
}
GtkWidget *
@ -745,8 +742,8 @@ dialogs_document_grid_new (GimpDialogFactory *factory,
GTK_STOCK_OPEN,
GIMP_HELP_DOCUMENT_DIALOG,
NULL, NULL,
dialogs_set_editor_context_func,
dialogs_get_editor_menu_func);
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
}
@ -948,7 +945,7 @@ dialogs_undo_history_new (GimpDialogFactory *factory,
GIMP_HELP_UNDO_DIALOG,
NULL, NULL,
dialogs_set_image_editor_context_func,
dialogs_get_view_menu_func);
NULL);
gimp_dockable_set_context (GIMP_DOCKABLE (dockable), context);
@ -1227,21 +1224,10 @@ static void
dialogs_set_view_context_func (GimpDockable *dockable,
GimpContext *context)
{
GtkWidget *widget = GTK_BIN (dockable)->child;
GimpContainerView *view = gimp_container_view_get_by_dockable (dockable);
if (GIMP_IS_CONTAINER_VIEW (widget))
gimp_container_view_set_context (GIMP_CONTAINER_VIEW (widget), context);
}
static void
dialogs_set_editor_context_func (GimpDockable *dockable,
GimpContext *context)
{
GtkWidget *widget = GTK_BIN (dockable)->child;
if (GIMP_IS_CONTAINER_EDITOR (widget))
gimp_container_view_set_context (GIMP_CONTAINER_EDITOR (widget)->view,
context);
if (view)
gimp_container_view_set_context (view, context);
}
static void
@ -1342,30 +1328,11 @@ static GimpItemFactory *
dialogs_get_view_menu_func (GimpDockable *dockable,
gpointer *item_factory_data)
{
GtkWidget *widget = GTK_BIN (dockable)->child;
GimpContainerView *view = gimp_container_view_get_by_dockable (dockable);
if (GIMP_IS_EDITOR (widget))
if (view)
{
GimpEditor *editor = GIMP_EDITOR (widget);
if (item_factory_data)
*item_factory_data = editor->item_factory_data;
return editor->item_factory;
}
return NULL;
}
static GimpItemFactory *
dialogs_get_editor_menu_func (GimpDockable *dockable,
gpointer *item_factory_data)
{
GtkWidget *widget = GTK_BIN (dockable)->child;
if (GIMP_IS_CONTAINER_EDITOR (widget))
{
GimpEditor *editor = GIMP_EDITOR (GIMP_CONTAINER_EDITOR (widget)->view);
GimpEditor *editor = GIMP_EDITOR (view);
if (item_factory_data)
*item_factory_data = editor->item_factory_data;

View File

@ -88,11 +88,9 @@ dialogs_add_tab_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpDockbook *dockbook;
GimpDockbook *dockbook = GIMP_DOCKBOOK (data);
dockbook = (GimpDockbook *) gtk_item_factory_popup_data_from_widget (widget);
if (dockbook && action)
if (action)
{
GtkWidget *dockable;
const gchar *identifier;
@ -118,26 +116,40 @@ dialogs_add_tab_cmd_callback (GtkWidget *widget,
}
void
dialogs_remove_tab_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
dialogs_close_tab_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpDockbook *dockbook;
GimpDockbook *dockbook = GIMP_DOCKBOOK (data);
GimpDockable *dockable;
gint page_num;
dockbook = (GimpDockbook *) gtk_item_factory_popup_data_from_widget (widget);
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
if (dockbook)
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
if (dockable)
gimp_dockbook_remove (dockbook, dockable);
}
void
dialogs_detach_tab_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpDockbook *dockbook = GIMP_DOCKBOOK (data);
GimpDockable *dockable;
gint page_num;
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
if (dockable)
{
GimpDockable *dockable;
gint page_num;
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
if (dockable)
gimp_dockbook_remove (dockbook, dockable);
/* TODO */
}
}
@ -146,85 +158,87 @@ dialogs_toggle_view_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpDockbook *dockbook;
GimpDockbook *dockbook = GIMP_DOCKBOOK (data);
GimpDockable *dockable;
GimpViewType view_type;
gint page_num;
if (! GTK_CHECK_MENU_ITEM (widget)->active)
return;
dockbook = (GimpDockbook *) gtk_item_factory_popup_data_from_widget (widget);
view_type = (GimpViewType) action;
if (dockbook)
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
if (dockable)
{
GimpDockable *dockable;
gint page_num;
GimpDialogFactoryEntry *entry;
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
entry = g_object_get_data (G_OBJECT (dockable),
"gimp-dialog-factory-entry");
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
if (dockable)
if (entry)
{
GimpDialogFactoryEntry *entry;
gchar *identifier;
gchar *substring = NULL;
entry = g_object_get_data (G_OBJECT (dockable),
"gimp-dialog-factory-entry");
identifier = g_strdup (entry->identifier);
if (entry)
substring = strstr (identifier, "grid");
if (substring && view_type == GIMP_VIEW_TYPE_GRID)
return;
if (! substring)
{
gchar *identifier;
gchar *substring = NULL;
substring = strstr (identifier, "list");
identifier = g_strdup (entry->identifier);
substring = strstr (identifier, "grid");
if (! substring)
substring = strstr (identifier, "list");
if (substring)
{
GimpContainerView *old_view;
GtkWidget *new_dockable;
gint preview_size = -1;
if (view_type == GIMP_VIEW_TYPE_LIST)
memcpy (substring, "list", 4);
else if (view_type == GIMP_VIEW_TYPE_GRID)
memcpy (substring, "grid", 4);
old_view = gimp_container_view_get_by_dockable (dockable);
if (old_view)
preview_size = old_view->preview_size;
new_dockable =
gimp_dialog_factory_dockable_new (dockbook->dock->dialog_factory,
dockbook->dock,
identifier,
preview_size);
/* Maybe gimp_dialog_factory_dockable_new() returned
* an already existing singleton dockable, so check
* if it already is attached to a dockbook.
*/
if (new_dockable && ! GIMP_DOCKABLE (new_dockable)->dockbook)
{
gimp_dockbook_add (dockbook, GIMP_DOCKABLE (new_dockable),
page_num);
gimp_dockbook_remove (dockbook, dockable);
gtk_notebook_set_current_page (GTK_NOTEBOOK (dockbook),
page_num);
}
}
g_free (identifier);
if (substring && view_type == GIMP_VIEW_TYPE_LIST)
return;
}
if (substring)
{
GimpContainerView *old_view;
GtkWidget *new_dockable;
gint preview_size = -1;
if (view_type == GIMP_VIEW_TYPE_LIST)
memcpy (substring, "list", 4);
else if (view_type == GIMP_VIEW_TYPE_GRID)
memcpy (substring, "grid", 4);
old_view = gimp_container_view_get_by_dockable (dockable);
if (old_view)
preview_size = old_view->preview_size;
new_dockable =
gimp_dialog_factory_dockable_new (dockbook->dock->dialog_factory,
dockbook->dock,
identifier,
preview_size);
/* Maybe gimp_dialog_factory_dockable_new() returned
* an already existing singleton dockable, so check
* if it already is attached to a dockbook.
*/
if (new_dockable && ! GIMP_DOCKABLE (new_dockable)->dockbook)
{
gimp_dockbook_add (dockbook, GIMP_DOCKABLE (new_dockable),
page_num);
gimp_dockbook_remove (dockbook, dockable);
gtk_notebook_set_current_page (GTK_NOTEBOOK (dockbook),
page_num);
}
}
g_free (identifier);
}
}
}
@ -234,33 +248,30 @@ dialogs_preview_size_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpDockbook *dockbook;
GimpDockbook *dockbook = GIMP_DOCKBOOK (data);
GimpDockable *dockable;
gint preview_size;
gint page_num;
if (! GTK_CHECK_MENU_ITEM (widget)->active)
return;
dockbook = (GimpDockbook *) gtk_item_factory_popup_data_from_widget (widget);
preview_size = (gint) action;
if (dockbook)
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
if (dockable)
{
GimpDockable *dockable;
gint page_num;
GimpContainerView *view;
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
view = gimp_container_view_get_by_dockable (dockable);
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
if (dockable)
if (view)
{
GimpContainerView *view;
view = gimp_container_view_get_by_dockable (dockable);
if (view)
if (view->preview_size != preview_size)
gimp_container_view_set_preview_size (view, preview_size,
view->preview_border_width);
}
@ -272,27 +283,24 @@ dialogs_tab_style_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpDockbook *dockbook;
GimpDockbook *dockbook = GIMP_DOCKBOOK (data);
GimpDockable *dockable;
GimpTabStyle tab_style;
gint page_num;
if (! GTK_CHECK_MENU_ITEM (widget)->active)
return;
dockbook = (GimpDockbook *) gtk_item_factory_popup_data_from_widget (widget);
tab_style = (gint) action;
if (dockbook)
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
if (dockable)
{
GimpDockable *dockable;
gint page_num;
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
if (dockable)
if (dockable->tab_style != tab_style)
{
GtkWidget *tab_widget;
@ -312,11 +320,9 @@ dialogs_toggle_image_menu_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpDockbook *dockbook;
GimpDockbook *dockbook = GIMP_DOCKBOOK (data);
dockbook = (GimpDockbook *) gtk_item_factory_popup_data_from_widget (widget);
if (dockbook && GIMP_IS_IMAGE_DOCK (dockbook->dock))
if (GIMP_IS_IMAGE_DOCK (dockbook->dock))
{
gimp_image_dock_set_show_image_menu (GIMP_IMAGE_DOCK (dockbook->dock),
GTK_CHECK_MENU_ITEM (widget)->active);
@ -328,11 +334,9 @@ dialogs_toggle_auto_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpDockbook *dockbook;
GimpDockbook *dockbook = GIMP_DOCKBOOK (data);
dockbook = (GimpDockbook *) gtk_item_factory_popup_data_from_widget (widget);
if (dockbook && GIMP_IS_IMAGE_DOCK (dockbook->dock))
if (GIMP_IS_IMAGE_DOCK (dockbook->dock))
{
gimp_image_dock_set_auto_follow_active (GIMP_IMAGE_DOCK (dockbook->dock),
GTK_CHECK_MENU_ITEM (widget)->active);

View File

@ -33,7 +33,10 @@ void dialogs_create_dockable_cmd_callback (GtkWidget *widget,
void dialogs_add_tab_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void dialogs_remove_tab_cmd_callback (GtkWidget *widget,
void dialogs_close_tab_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void dialogs_detach_tab_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);

View File

@ -45,6 +45,7 @@
#include "widgets/gimpcolormapeditor.h"
#include "widgets/gimpcontainergridview.h"
#include "widgets/gimpcontainertreeview.h"
#include "widgets/gimpcontainerview-utils.h"
#include "widgets/gimpdataeditor.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimperrorconsole.h"
@ -106,8 +107,6 @@ static GtkWidget * dialogs_tool_options_preview_func (GimpDockable *dockable,
static void dialogs_set_view_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_editor_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_color_editor_context_func (GimpDockable *dockable,
GimpContext *context);
static void dialogs_set_image_item_context_func (GimpDockable *dockable,
@ -119,8 +118,6 @@ static void dialogs_set_navigation_context_func (GimpDockable *dockable,
static GimpItemFactory * dialogs_get_view_menu_func (GimpDockable *dockable,
gpointer *item_factory_data);
static GimpItemFactory * dialogs_get_editor_menu_func (GimpDockable *dockable,
gpointer *item_factory_data);
static GtkWidget * dialogs_dockable_new (GtkWidget *widget,
const gchar *name,
@ -307,7 +304,7 @@ dialogs_error_console_get (GimpDialogFactory *factory,
GIMP_HELP_ERRORS_DIALOG,
NULL, NULL,
NULL,
dialogs_get_editor_menu_func);
dialogs_get_view_menu_func);
}
@ -331,8 +328,8 @@ dialogs_image_list_view_new (GimpDialogFactory *factory,
GIMP_STOCK_IMAGES,
GIMP_HELP_IMAGE_DIALOG,
NULL, NULL,
dialogs_set_editor_context_func,
dialogs_get_editor_menu_func);
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
}
GtkWidget *
@ -355,8 +352,8 @@ dialogs_brush_list_view_new (GimpDialogFactory *factory,
GIMP_STOCK_TOOL_PAINTBRUSH,
GIMP_HELP_BRUSH_DIALOG,
dialogs_viewable_preview_func, "brush",
dialogs_set_editor_context_func,
dialogs_get_editor_menu_func);
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
}
GtkWidget *
@ -378,8 +375,8 @@ dialogs_pattern_list_view_new (GimpDialogFactory *factory,
GIMP_STOCK_TOOL_BUCKET_FILL,
GIMP_HELP_PATTERN_DIALOG,
dialogs_viewable_preview_func, "pattern",
dialogs_set_editor_context_func,
dialogs_get_editor_menu_func);
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
}
GtkWidget *
@ -401,8 +398,8 @@ dialogs_gradient_list_view_new (GimpDialogFactory *factory,
GIMP_STOCK_TOOL_BLEND,
GIMP_HELP_GRADIENT_DIALOG,
dialogs_viewable_preview_func, "gradient",
dialogs_set_editor_context_func,
dialogs_get_editor_menu_func);
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
}
GtkWidget *
@ -424,8 +421,8 @@ dialogs_palette_list_view_new (GimpDialogFactory *factory,
GTK_STOCK_SELECT_COLOR,
GIMP_HELP_PALETTE_DIALOG,
dialogs_viewable_preview_func, "palette",
dialogs_set_editor_context_func,
dialogs_get_editor_menu_func);
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
}
GtkWidget *
@ -488,8 +485,8 @@ dialogs_buffer_list_view_new (GimpDialogFactory *factory,
GTK_STOCK_PASTE,
GIMP_HELP_BUFFER_DIALOG,
NULL, NULL,
dialogs_set_editor_context_func,
dialogs_get_editor_menu_func);
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
}
GtkWidget *
@ -511,8 +508,8 @@ dialogs_document_list_new (GimpDialogFactory *factory,
GTK_STOCK_OPEN,
GIMP_HELP_DOCUMENT_DIALOG,
NULL, NULL,
dialogs_set_editor_context_func,
dialogs_get_editor_menu_func);
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
}
GtkWidget *
@ -540,8 +537,8 @@ dialogs_template_list_new (GimpDialogFactory *factory,
GIMP_STOCK_TEMPLATE,
GIMP_HELP_TEMPLATE_DIALOG,
NULL, NULL,
dialogs_set_editor_context_func,
dialogs_get_editor_menu_func);
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
}
@ -565,8 +562,8 @@ dialogs_image_grid_view_new (GimpDialogFactory *factory,
GIMP_STOCK_IMAGES,
GIMP_HELP_IMAGE_DIALOG,
NULL, NULL,
dialogs_set_editor_context_func,
dialogs_get_editor_menu_func);
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
}
GtkWidget *
@ -589,8 +586,8 @@ dialogs_brush_grid_view_new (GimpDialogFactory *factory,
GIMP_STOCK_TOOL_PAINTBRUSH,
GIMP_HELP_BRUSH_DIALOG,
dialogs_viewable_preview_func, "brush",
dialogs_set_editor_context_func,
dialogs_get_editor_menu_func);
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
}
GtkWidget *
@ -612,8 +609,8 @@ dialogs_pattern_grid_view_new (GimpDialogFactory *factory,
GIMP_STOCK_TOOL_BUCKET_FILL,
GIMP_HELP_PATTERN_DIALOG,
dialogs_viewable_preview_func, "pattern",
dialogs_set_editor_context_func,
dialogs_get_editor_menu_func);
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
}
GtkWidget *
@ -635,8 +632,8 @@ dialogs_gradient_grid_view_new (GimpDialogFactory *factory,
GIMP_STOCK_TOOL_BLEND,
GIMP_HELP_GRADIENT_DIALOG,
dialogs_viewable_preview_func, "gradient",
dialogs_set_editor_context_func,
dialogs_get_editor_menu_func);
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
}
GtkWidget *
@ -658,8 +655,8 @@ dialogs_palette_grid_view_new (GimpDialogFactory *factory,
GTK_STOCK_SELECT_COLOR,
GIMP_HELP_PALETTE_DIALOG,
dialogs_viewable_preview_func, "palette",
dialogs_set_editor_context_func,
dialogs_get_editor_menu_func);
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
}
GtkWidget *
@ -722,8 +719,8 @@ dialogs_buffer_grid_view_new (GimpDialogFactory *factory,
GTK_STOCK_PASTE,
GIMP_HELP_BUFFER_DIALOG,
NULL, NULL,
dialogs_set_editor_context_func,
dialogs_get_editor_menu_func);
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
}
GtkWidget *
@ -745,8 +742,8 @@ dialogs_document_grid_new (GimpDialogFactory *factory,
GTK_STOCK_OPEN,
GIMP_HELP_DOCUMENT_DIALOG,
NULL, NULL,
dialogs_set_editor_context_func,
dialogs_get_editor_menu_func);
dialogs_set_view_context_func,
dialogs_get_view_menu_func);
}
@ -948,7 +945,7 @@ dialogs_undo_history_new (GimpDialogFactory *factory,
GIMP_HELP_UNDO_DIALOG,
NULL, NULL,
dialogs_set_image_editor_context_func,
dialogs_get_view_menu_func);
NULL);
gimp_dockable_set_context (GIMP_DOCKABLE (dockable), context);
@ -1227,21 +1224,10 @@ static void
dialogs_set_view_context_func (GimpDockable *dockable,
GimpContext *context)
{
GtkWidget *widget = GTK_BIN (dockable)->child;
GimpContainerView *view = gimp_container_view_get_by_dockable (dockable);
if (GIMP_IS_CONTAINER_VIEW (widget))
gimp_container_view_set_context (GIMP_CONTAINER_VIEW (widget), context);
}
static void
dialogs_set_editor_context_func (GimpDockable *dockable,
GimpContext *context)
{
GtkWidget *widget = GTK_BIN (dockable)->child;
if (GIMP_IS_CONTAINER_EDITOR (widget))
gimp_container_view_set_context (GIMP_CONTAINER_EDITOR (widget)->view,
context);
if (view)
gimp_container_view_set_context (view, context);
}
static void
@ -1342,30 +1328,11 @@ static GimpItemFactory *
dialogs_get_view_menu_func (GimpDockable *dockable,
gpointer *item_factory_data)
{
GtkWidget *widget = GTK_BIN (dockable)->child;
GimpContainerView *view = gimp_container_view_get_by_dockable (dockable);
if (GIMP_IS_EDITOR (widget))
if (view)
{
GimpEditor *editor = GIMP_EDITOR (widget);
if (item_factory_data)
*item_factory_data = editor->item_factory_data;
return editor->item_factory;
}
return NULL;
}
static GimpItemFactory *
dialogs_get_editor_menu_func (GimpDockable *dockable,
gpointer *item_factory_data)
{
GtkWidget *widget = GTK_BIN (dockable)->child;
if (GIMP_IS_CONTAINER_EDITOR (widget))
{
GimpEditor *editor = GIMP_EDITOR (GIMP_CONTAINER_EDITOR (widget)->view);
GimpEditor *editor = GIMP_EDITOR (view);
if (item_factory_data)
*item_factory_data = editor->item_factory_data;

View File

@ -58,6 +58,10 @@
GimpItemFactoryEntry dialogs_menu_entries[] =
{
{ { "/dialog-menu", NULL, NULL, 0,
"<StockItem>", GTK_STOCK_MISSING_IMAGE },
NULL, NULL, NULL },
{ { N_("/_Select Tab"), NULL, NULL, 0 },
NULL, NULL, NULL },
@ -118,11 +122,16 @@ GimpItemFactoryEntry dialogs_menu_entries[] =
ADD_TAB (N_("/Add Tab/Tools..."), "gimp-tool-list",
GTK_STOCK_MISSING_IMAGE, GIMP_HELP_TOOL_DIALOG),
{ { N_("/_Remove Tab"), "",
dialogs_remove_tab_cmd_callback, 0,
"<StockItem>", GTK_STOCK_REMOVE },
{ { N_("/_Close Tab"), "",
dialogs_close_tab_cmd_callback, 0,
"<StockItem>", GTK_STOCK_CLOSE },
NULL,
GIMP_HELP_DOCK_TAB_REMOVE, NULL },
GIMP_HELP_DOCK_TAB_CLOSE, NULL },
{ { N_("/_Detach Tab"), "",
dialogs_detach_tab_cmd_callback, 0,
"<StockItem>", GTK_STOCK_CONVERT },
NULL,
GIMP_HELP_DOCK_TAB_DETACH, NULL },
MENU_SEPARATOR ("/---"),
@ -188,64 +197,73 @@ void
dialogs_menu_update (GtkItemFactory *factory,
gpointer data)
{
GimpDockbook *dockbook;
GimpDockable *dockable;
GimpDockbook *dockbook;
GimpDialogFactoryEntry *entry;
GimpContainerView *view;
GimpViewType view_type = -1;
gboolean list_view_available = FALSE;
gboolean grid_view_available = FALSE;
GimpPreviewSize preview_size = -1;
GimpTabStyle tab_style;
dockbook = GIMP_DOCKBOOK (data);
if (dockbook)
if (GIMP_IS_DOCKBOOK (data))
{
GimpDockable *dockable;
gint page_num;
GimpDialogFactoryEntry *entry;
GimpContainerView *view;
GimpViewType view_type = -1;
gboolean list_view_available = FALSE;
gboolean grid_view_available = FALSE;
GimpPreviewSize preview_size = -1;
GimpTabStyle tab_style;
gint page_num;
dockbook = GIMP_DOCKBOOK (data);
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
}
else if (GIMP_IS_DOCKABLE (data))
{
dockable = GIMP_DOCKABLE (data);
dockbook = dockable->dockbook;
}
else
{
return;
}
entry = g_object_get_data (G_OBJECT (dockable),
"gimp-dialog-factory-entry");
entry = g_object_get_data (G_OBJECT (dockable), "gimp-dialog-factory-entry");
if (entry)
if (entry)
{
gchar *identifier;
gchar *substring = NULL;
identifier = g_strdup (entry->identifier);
if ((substring = strstr (identifier, "grid")))
view_type = GIMP_VIEW_TYPE_GRID;
else if ((substring = strstr (identifier, "list")))
view_type = GIMP_VIEW_TYPE_LIST;
if (substring)
{
gchar *identifier;
gchar *substring = NULL;
memcpy (substring, "list", 4);
if (gimp_dialog_factory_find_entry (dockbook->dock->dialog_factory,
identifier))
list_view_available = TRUE;
identifier = g_strdup (entry->identifier);
if ((substring = strstr (identifier, "grid")))
view_type = GIMP_VIEW_TYPE_GRID;
else if ((substring = strstr (identifier, "list")))
view_type = GIMP_VIEW_TYPE_LIST;
if (substring)
{
memcpy (substring, "list", 4);
if (gimp_dialog_factory_find_entry (dockbook->dock->dialog_factory,
identifier))
list_view_available = TRUE;
memcpy (substring, "grid", 4);
if (gimp_dialog_factory_find_entry (dockbook->dock->dialog_factory,
identifier))
grid_view_available = TRUE;
}
g_free (identifier);
memcpy (substring, "grid", 4);
if (gimp_dialog_factory_find_entry (dockbook->dock->dialog_factory,
identifier))
grid_view_available = TRUE;
}
view = gimp_container_view_get_by_dockable (dockable);
g_free (identifier);
}
if (view)
preview_size = view->preview_size;
view = gimp_container_view_get_by_dockable (dockable);
tab_style = dockable->tab_style;
if (view)
preview_size = view->preview_size;
tab_style = dockable->tab_style;
#define SET_ACTIVE(path,active) \
gimp_item_factory_set_active (factory, (path), (active) != 0)
@ -254,96 +272,95 @@ dialogs_menu_update (GtkItemFactory *factory,
#define SET_SENSITIVE(path,sensitive) \
gimp_item_factory_set_sensitive (factory, (path), (sensitive) != 0)
SET_VISIBLE ("/Preview Size", preview_size != -1);
SET_VISIBLE ("/Preview Size", preview_size != -1);
if (preview_size != -1)
if (preview_size != -1)
{
if (preview_size >= GIMP_PREVIEW_SIZE_GIGANTIC)
{
if (preview_size >= GIMP_PREVIEW_SIZE_GIGANTIC)
{
SET_ACTIVE ("/Preview Size/Gigantic", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_ENORMOUS)
{
SET_ACTIVE ("/Preview Size/Enormous", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_HUGE)
{
SET_ACTIVE ("/Preview Size/Huge", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_EXTRA_LARGE)
{
SET_ACTIVE ("/Preview Size/Extra Large", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_LARGE)
{
SET_ACTIVE ("/Preview Size/Large", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_MEDIUM)
{
SET_ACTIVE ("/Preview Size/Medium", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_SMALL)
{
SET_ACTIVE ("/Preview Size/Small", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_EXTRA_SMALL)
{
SET_ACTIVE ("/Preview Size/Extra Small", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_TINY)
{
SET_ACTIVE ("/Preview Size/Tiny", TRUE);
}
SET_ACTIVE ("/Preview Size/Gigantic", TRUE);
}
if (tab_style == GIMP_TAB_STYLE_ICON)
SET_ACTIVE ("/Tab Style/Icon", TRUE);
else if (tab_style == GIMP_TAB_STYLE_PREVIEW)
SET_ACTIVE ("/Tab Style/Current Status", TRUE);
else if (tab_style == GIMP_TAB_STYLE_NAME)
SET_ACTIVE ("/Tab Style/Text", TRUE);
else if (tab_style == GIMP_TAB_STYLE_ICON_NAME)
SET_ACTIVE ("/Tab Style/Icon & Text", TRUE);
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_VISIBLE ("/View as Grid", view_type != -1);
SET_VISIBLE ("/View as List", view_type != -1);
if (view_type != -1)
else if (preview_size >= GIMP_PREVIEW_SIZE_ENORMOUS)
{
if (view_type == GIMP_VIEW_TYPE_LIST)
SET_ACTIVE ("/View as List", TRUE);
else
SET_ACTIVE ("/View as Grid", TRUE);
SET_SENSITIVE ("/View as Grid", grid_view_available);
SET_SENSITIVE ("/View as List", list_view_available);
SET_ACTIVE ("/Preview Size/Enormous", TRUE);
}
if (GIMP_IS_IMAGE_DOCK (dockbook->dock))
else if (preview_size >= GIMP_PREVIEW_SIZE_HUGE)
{
SET_VISIBLE ("/image-menu-separator", TRUE);
SET_VISIBLE ("/Show Image Menu", TRUE);
SET_VISIBLE ("/Auto Follow Active Image", TRUE);
SET_ACTIVE ("/Show Image Menu",
GIMP_IMAGE_DOCK (dockbook->dock)->show_image_menu);
SET_ACTIVE ("/Auto Follow Active Image",
GIMP_IMAGE_DOCK (dockbook->dock)->auto_follow_active);
SET_ACTIVE ("/Preview Size/Huge", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_EXTRA_LARGE)
{
SET_ACTIVE ("/Preview Size/Extra Large", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_LARGE)
{
SET_ACTIVE ("/Preview Size/Large", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_MEDIUM)
{
SET_ACTIVE ("/Preview Size/Medium", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_SMALL)
{
SET_ACTIVE ("/Preview Size/Small", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_EXTRA_SMALL)
{
SET_ACTIVE ("/Preview Size/Extra Small", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_TINY)
{
SET_ACTIVE ("/Preview Size/Tiny", TRUE);
}
}
if (tab_style == GIMP_TAB_STYLE_ICON)
SET_ACTIVE ("/Tab Style/Icon", TRUE);
else if (tab_style == GIMP_TAB_STYLE_PREVIEW)
SET_ACTIVE ("/Tab Style/Current Status", TRUE);
else if (tab_style == GIMP_TAB_STYLE_NAME)
SET_ACTIVE ("/Tab Style/Text", TRUE);
else if (tab_style == GIMP_TAB_STYLE_ICON_NAME)
SET_ACTIVE ("/Tab Style/Icon & Text", TRUE);
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_VISIBLE ("/View as Grid", view_type != -1);
SET_VISIBLE ("/View as List", view_type != -1);
if (view_type != -1)
{
if (view_type == GIMP_VIEW_TYPE_LIST)
SET_ACTIVE ("/View as List", TRUE);
else
{
SET_VISIBLE ("/image-menu-separator", FALSE);
SET_VISIBLE ("/Show Image Menu", FALSE);
SET_VISIBLE ("/Auto Follow Active Image", FALSE);
}
SET_ACTIVE ("/View as Grid", TRUE);
SET_SENSITIVE ("/View as Grid", grid_view_available);
SET_SENSITIVE ("/View as List", list_view_available);
}
if (GIMP_IS_IMAGE_DOCK (dockbook->dock))
{
SET_VISIBLE ("/image-menu-separator", TRUE);
SET_VISIBLE ("/Show Image Menu", TRUE);
SET_VISIBLE ("/Auto Follow Active Image", TRUE);
SET_ACTIVE ("/Show Image Menu",
GIMP_IMAGE_DOCK (dockbook->dock)->show_image_menu);
SET_ACTIVE ("/Auto Follow Active Image",
GIMP_IMAGE_DOCK (dockbook->dock)->auto_follow_active);
}
else
{
SET_VISIBLE ("/image-menu-separator", FALSE);
SET_VISIBLE ("/Show Image Menu", FALSE);
SET_VISIBLE ("/Auto Follow Active Image", FALSE);
}
#undef SET_ACTIVE
#undef SET_VISIBLE
#undef SET_SENSITIVE
}
}

View File

@ -108,24 +108,28 @@ menus_init (Gimp *gimp)
global_menu_factory = gimp_menu_factory_new (gimp);
gimp_menu_factory_menu_register (global_menu_factory, "<Toolbox>",
_("Toolbox Menu"),
GIMP_HELP_TOOLBOX,
toolbox_menu_setup, NULL, FALSE,
n_toolbox_menu_entries,
toolbox_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<Image>",
_("Image Menu"),
GIMP_HELP_IMAGE_WINDOW,
image_menu_setup, image_menu_update, FALSE,
n_image_menu_entries,
image_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<Load>",
_("Open Menu"),
GIMP_HELP_FILE_OPEN,
file_open_menu_setup, NULL, FALSE,
n_file_open_menu_entries,
file_open_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<Save>",
_("Save Menu"),
GIMP_HELP_FILE_SAVE,
file_save_menu_setup,
file_save_menu_update, FALSE,
@ -133,102 +137,119 @@ menus_init (Gimp *gimp)
file_save_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<Layers>",
_("Layers Menu"),
GIMP_HELP_LAYER_DIALOG,
NULL, layers_menu_update, TRUE,
n_layers_menu_entries,
layers_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<Channels>",
_("Channels Menu"),
GIMP_HELP_CHANNEL_DIALOG,
NULL, channels_menu_update, TRUE,
n_channels_menu_entries,
channels_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<Vectors>",
_("Paths Menu"),
GIMP_HELP_PATH_DIALOG,
NULL, vectors_menu_update, TRUE,
n_vectors_menu_entries,
vectors_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<Dialogs>",
_("Dialogs Menu"),
GIMP_HELP_DOCK,
NULL, dialogs_menu_update, TRUE,
n_dialogs_menu_entries,
dialogs_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<Brushes>",
_("Brushes Menu"),
GIMP_HELP_BRUSH_DIALOG,
NULL, brushes_menu_update, TRUE,
n_brushes_menu_entries,
brushes_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<Patterns>",
_("Patterns Menu"),
GIMP_HELP_PATTERN_DIALOG,
NULL, patterns_menu_update, TRUE,
n_patterns_menu_entries,
patterns_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<Gradients>",
_("Gradients Menu"),
GIMP_HELP_GRADIENT_DIALOG,
NULL, gradients_menu_update, TRUE,
n_gradients_menu_entries,
gradients_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<Palettes>",
_("Palettes Menu"),
GIMP_HELP_PALETTE_DIALOG,
NULL, palettes_menu_update, TRUE,
n_palettes_menu_entries,
palettes_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<Buffers>",
_("Buffers Menu"),
GIMP_HELP_BUFFER_DIALOG,
NULL, buffers_menu_update, TRUE,
n_buffers_menu_entries,
buffers_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<Documents>",
_("Documents Menu"),
GIMP_HELP_DOCUMENT_DIALOG,
NULL, documents_menu_update, TRUE,
n_documents_menu_entries,
documents_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<Templates>",
_("Templaes Menu"),
GIMP_HELP_TEMPLATE_DIALOG,
NULL, templates_menu_update, TRUE,
n_templates_menu_entries,
templates_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<Images>",
_("Images Menu"),
GIMP_HELP_IMAGE_DIALOG,
NULL, images_menu_update, TRUE,
n_images_menu_entries,
images_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<GradientEditor>",
_("Gradient Editor Menu"),
GIMP_HELP_GRADIENT_EDITOR_DIALOG,
NULL, gradient_editor_menu_update, TRUE,
n_gradient_editor_menu_entries,
gradient_editor_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<PaletteEditor>",
_("Palette Editor Menu"),
GIMP_HELP_PALETTE_EDITOR_DIALOG,
NULL, palette_editor_menu_update, TRUE,
n_palette_editor_menu_entries,
palette_editor_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<ColormapEditor>",
_("Indexed Palette Menu"),
GIMP_HELP_INDEXED_PALETTE_DIALOG,
NULL, colormap_editor_menu_update, TRUE,
n_colormap_editor_menu_entries,
colormap_editor_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<QMask>",
_("QuickMask Menu"),
GIMP_HELP_QMASK,
NULL, qmask_menu_update, TRUE,
n_qmask_menu_entries,
qmask_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<ErrorConsole>",
_("Error Console Menu"),
GIMP_HELP_ERRORS_DIALOG,
NULL, error_console_menu_update, TRUE,
n_error_console_menu_entries,

View File

@ -108,24 +108,28 @@ menus_init (Gimp *gimp)
global_menu_factory = gimp_menu_factory_new (gimp);
gimp_menu_factory_menu_register (global_menu_factory, "<Toolbox>",
_("Toolbox Menu"),
GIMP_HELP_TOOLBOX,
toolbox_menu_setup, NULL, FALSE,
n_toolbox_menu_entries,
toolbox_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<Image>",
_("Image Menu"),
GIMP_HELP_IMAGE_WINDOW,
image_menu_setup, image_menu_update, FALSE,
n_image_menu_entries,
image_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<Load>",
_("Open Menu"),
GIMP_HELP_FILE_OPEN,
file_open_menu_setup, NULL, FALSE,
n_file_open_menu_entries,
file_open_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<Save>",
_("Save Menu"),
GIMP_HELP_FILE_SAVE,
file_save_menu_setup,
file_save_menu_update, FALSE,
@ -133,102 +137,119 @@ menus_init (Gimp *gimp)
file_save_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<Layers>",
_("Layers Menu"),
GIMP_HELP_LAYER_DIALOG,
NULL, layers_menu_update, TRUE,
n_layers_menu_entries,
layers_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<Channels>",
_("Channels Menu"),
GIMP_HELP_CHANNEL_DIALOG,
NULL, channels_menu_update, TRUE,
n_channels_menu_entries,
channels_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<Vectors>",
_("Paths Menu"),
GIMP_HELP_PATH_DIALOG,
NULL, vectors_menu_update, TRUE,
n_vectors_menu_entries,
vectors_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<Dialogs>",
_("Dialogs Menu"),
GIMP_HELP_DOCK,
NULL, dialogs_menu_update, TRUE,
n_dialogs_menu_entries,
dialogs_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<Brushes>",
_("Brushes Menu"),
GIMP_HELP_BRUSH_DIALOG,
NULL, brushes_menu_update, TRUE,
n_brushes_menu_entries,
brushes_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<Patterns>",
_("Patterns Menu"),
GIMP_HELP_PATTERN_DIALOG,
NULL, patterns_menu_update, TRUE,
n_patterns_menu_entries,
patterns_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<Gradients>",
_("Gradients Menu"),
GIMP_HELP_GRADIENT_DIALOG,
NULL, gradients_menu_update, TRUE,
n_gradients_menu_entries,
gradients_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<Palettes>",
_("Palettes Menu"),
GIMP_HELP_PALETTE_DIALOG,
NULL, palettes_menu_update, TRUE,
n_palettes_menu_entries,
palettes_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<Buffers>",
_("Buffers Menu"),
GIMP_HELP_BUFFER_DIALOG,
NULL, buffers_menu_update, TRUE,
n_buffers_menu_entries,
buffers_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<Documents>",
_("Documents Menu"),
GIMP_HELP_DOCUMENT_DIALOG,
NULL, documents_menu_update, TRUE,
n_documents_menu_entries,
documents_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<Templates>",
_("Templaes Menu"),
GIMP_HELP_TEMPLATE_DIALOG,
NULL, templates_menu_update, TRUE,
n_templates_menu_entries,
templates_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<Images>",
_("Images Menu"),
GIMP_HELP_IMAGE_DIALOG,
NULL, images_menu_update, TRUE,
n_images_menu_entries,
images_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<GradientEditor>",
_("Gradient Editor Menu"),
GIMP_HELP_GRADIENT_EDITOR_DIALOG,
NULL, gradient_editor_menu_update, TRUE,
n_gradient_editor_menu_entries,
gradient_editor_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<PaletteEditor>",
_("Palette Editor Menu"),
GIMP_HELP_PALETTE_EDITOR_DIALOG,
NULL, palette_editor_menu_update, TRUE,
n_palette_editor_menu_entries,
palette_editor_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<ColormapEditor>",
_("Indexed Palette Menu"),
GIMP_HELP_INDEXED_PALETTE_DIALOG,
NULL, colormap_editor_menu_update, TRUE,
n_colormap_editor_menu_entries,
colormap_editor_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<QMask>",
_("QuickMask Menu"),
GIMP_HELP_QMASK,
NULL, qmask_menu_update, TRUE,
n_qmask_menu_entries,
qmask_menu_entries);
gimp_menu_factory_menu_register (global_menu_factory, "<ErrorConsole>",
_("Error Console Menu"),
GIMP_HELP_ERRORS_DIALOG,
NULL, error_console_menu_update, TRUE,
n_error_console_menu_entries,

View File

@ -46,6 +46,7 @@ static void gimp_dockable_style_set (GtkWidget *widget,
GtkStyle *prev_style);
static gboolean gimp_dockable_expose_event (GtkWidget *widget,
GdkEventExpose *event);
static gboolean gimp_dockable_popup_menu (GtkWidget *widget);
static void gimp_dockable_forall (GtkContainer *container,
gboolean include_internals,
@ -66,6 +67,7 @@ static gboolean gimp_dockable_menu_button_press (GtkWidget *button,
GimpDockable *dockable);
static void gimp_dockable_close_clicked (GtkWidget *button,
GimpDockable *dockable);
static gboolean gimp_dockable_show_menu (GimpDockable *dockable);
static GtkBinClass *parent_class = NULL;
@ -118,6 +120,7 @@ gimp_dockable_class_init (GimpDockableClass *klass)
widget_class->size_allocate = gimp_dockable_size_allocate;
widget_class->style_set = gimp_dockable_style_set;
widget_class->expose_event = gimp_dockable_expose_event;
widget_class->popup_menu = gimp_dockable_popup_menu;
container_class->forall = gimp_dockable_forall;
@ -157,6 +160,7 @@ gimp_dockable_init (GimpDockable *dockable)
GTK_WIDGET_UNSET_FLAGS (dockable->menu_button, GTK_CAN_FOCUS);
gtk_widget_set_parent (dockable->menu_button, GTK_WIDGET (dockable));
gtk_button_set_relief (GTK_BUTTON (dockable->menu_button), GTK_RELIEF_NONE);
gtk_widget_show (dockable->menu_button);
image = gtk_image_new_from_stock (GIMP_STOCK_MENU_LEFT, GTK_ICON_SIZE_MENU);
gtk_container_add (GTK_CONTAINER (dockable->menu_button), image);
@ -400,6 +404,12 @@ gimp_dockable_expose_event (GtkWidget *widget,
return GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
}
static gboolean
gimp_dockable_popup_menu (GtkWidget *widget)
{
return gimp_dockable_show_menu (GIMP_DOCKABLE (widget));
}
static void
gimp_dockable_forall (GtkContainer *container,
gboolean include_internals,
@ -450,9 +460,6 @@ gimp_dockable_new (const gchar *name,
dockable->set_context_func = set_context_func;
dockable->get_menu_func = get_menu_func;
if (get_menu_func)
gtk_widget_show (dockable->menu_button);
if (! get_preview_func)
{
switch (dockable->tab_style)
@ -610,6 +617,26 @@ gimp_dockable_real_get_menu (GimpDockable *dockable,
return NULL;
}
static gboolean
gimp_dockable_menu_button_press (GtkWidget *button,
GdkEventButton *bevent,
GimpDockable *dockable)
{
if (bevent->button == 1 && bevent->type == GDK_BUTTON_PRESS)
{
return gimp_dockable_show_menu (dockable);
}
return FALSE;
}
static void
gimp_dockable_close_clicked (GtkWidget *button,
GimpDockable *dockable)
{
gimp_dockbook_remove (dockable->dockbook, dockable);
}
static void
gimp_dockable_menu_position (GtkMenu *menu,
gint *x,
@ -653,34 +680,83 @@ gimp_dockable_menu_position (GtkMenu *menu,
*y = 0;
}
static gboolean
gimp_dockable_menu_button_press (GtkWidget *button,
GdkEventButton *bevent,
GimpDockable *dockable)
static void
gimp_dockable_menu_end (GimpDockable *dockable)
{
if (bevent->button == 1 && bevent->type == GDK_BUTTON_PRESS)
GimpItemFactory *dialog_item_factory;
gpointer dialog_item_factory_data;
dialog_item_factory = gimp_dockable_get_menu (dockable,
&dialog_item_factory_data);
if (dialog_item_factory)
gtk_menu_detach (GTK_MENU (GTK_ITEM_FACTORY (dialog_item_factory)->widget));
/* release gimp_dockable_show_menu()'s reference */
g_object_unref (dockable);
}
static gboolean
gimp_dockable_show_menu (GimpDockable *dockable)
{
GimpItemFactory *dockbook_item_factory;
GimpItemFactory *dialog_item_factory;
gpointer dialog_item_factory_data;
dockbook_item_factory = dockable->dockbook->item_factory;
if (! dockbook_item_factory)
return FALSE;
dialog_item_factory = gimp_dockable_get_menu (dockable,
&dialog_item_factory_data);
if (dialog_item_factory)
{
GimpItemFactory *item_factory;
gpointer item_factory_data;
GtkWidget *dialog_menu_widget;
GtkWidget *image;
item_factory = gimp_dockable_get_menu (dockable, &item_factory_data);
gimp_item_factory_set_label (GTK_ITEM_FACTORY (dockbook_item_factory),
"/dialog-menu",
dialog_item_factory->title);
gimp_item_factory_set_visible (GTK_ITEM_FACTORY (dockbook_item_factory),
"/dialog-menu", TRUE);
if (item_factory)
{
gimp_item_factory_popup_with_data (item_factory, item_factory_data,
gimp_dockable_menu_position,
dockable,
NULL);
return TRUE;
}
dialog_menu_widget =
gtk_item_factory_get_widget (GTK_ITEM_FACTORY (dockbook_item_factory),
"/dialog-menu");
image = gtk_image_new_from_stock (dockable->stock_id,
GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (dialog_menu_widget),
image);
gtk_widget_show (image);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (dialog_menu_widget),
GTK_ITEM_FACTORY (dialog_item_factory)->widget);
gimp_item_factory_update (dialog_item_factory,
dialog_item_factory_data);
}
else
{
gimp_item_factory_set_visible (GTK_ITEM_FACTORY (dockbook_item_factory),
"/dialog-menu", FALSE);
}
return FALSE;
}
gimp_item_factory_set_visible (GTK_ITEM_FACTORY (dockbook_item_factory),
"/Select Tab", FALSE);
static void
gimp_dockable_close_clicked (GtkWidget *button,
GimpDockable *dockable)
{
gimp_dockbook_remove (dockable->dockbook, dockable);
/* an item factory callback may destroy the dockable, so reference
* if for gimp_dockable_menu_end()
*/
g_object_ref (dockable);
gimp_item_factory_popup_with_data (dockbook_item_factory,
dockable,
gimp_dockable_menu_position,
dockable,
(GtkDestroyNotify) gimp_dockable_menu_end);
return TRUE;
}

View File

@ -95,14 +95,14 @@ GtkWidget * gimp_dockable_new (const gchar *name,
GimpDockableSetContextFunc set_context_func,
GimpDockableGetMenuFunc get_menu_func);
GtkWidget * gimp_dockable_get_tab_widget (GimpDockable *dockable,
GimpContext *context,
GimpTabStyle tab_style,
GtkIconSize size);
void gimp_dockable_set_context (GimpDockable *dockable,
GimpContext *context);
GimpItemFactory * gimp_dockable_get_menu (GimpDockable *dockable,
gpointer *item_factory_data);
GtkWidget * gimp_dockable_get_tab_widget (GimpDockable *dockable,
GimpContext *context,
GimpTabStyle tab_style,
GtkIconSize size);
void gimp_dockable_set_context (GimpDockable *dockable,
GimpContext *context);
GimpItemFactory * gimp_dockable_get_menu (GimpDockable *dockable,
gpointer *item_factory_data);
#endif /* __GIMP_DOCKABLE_H__ */

View File

@ -241,7 +241,7 @@ gimp_dockbook_new (GimpMenuFactory *menu_factory)
dockbook->item_factory = gimp_menu_factory_menu_new (menu_factory,
"<Dialogs>",
GTK_TYPE_MENU,
menu_factory->gimp,
dockbook,
FALSE);
gimp_help_connect (GTK_WIDGET (dockbook), gimp_dockbook_help_func,
@ -585,6 +585,11 @@ gimp_dockbook_tab_button_press (GtkWidget *widget,
{
GtkWidget *add_widget;
gimp_item_factory_set_visible (GTK_ITEM_FACTORY (dockbook->item_factory),
"/dialog-menu", FALSE);
gimp_item_factory_set_visible (GTK_ITEM_FACTORY (dockbook->item_factory),
"/Select Tab", TRUE);
add_widget =
gtk_item_factory_get_widget (GTK_ITEM_FACTORY (dockbook->item_factory),
"/Select Tab");

View File

@ -30,7 +30,6 @@
#include "gimpeditor.h"
#include "gimpdnd.h"
#include "gimpenummenu.h"
#include "gimpitemfactory.h"
#include "gimpmenufactory.h"
@ -45,7 +44,6 @@ static void gimp_editor_init (GimpEditor *editor);
static void gimp_editor_destroy (GtkObject *object);
static void gimp_editor_style_set (GtkWidget *widget,
GtkStyle *prev_style);
static gboolean gimp_editor_popup_menu (GtkWidget *widget);
static GtkIconSize gimp_editor_ensure_button_box (GimpEditor *editor);
@ -92,10 +90,9 @@ gimp_editor_class_init (GimpEditorClass *klass)
parent_class = g_type_class_peek_parent (klass);
object_class->destroy = gimp_editor_destroy;
object_class->destroy = gimp_editor_destroy;
widget_class->style_set = gimp_editor_style_set;
widget_class->popup_menu = gimp_editor_popup_menu;
widget_class->style_set = gimp_editor_style_set;
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("content_spacing",
@ -194,62 +191,6 @@ gimp_editor_style_set (GtkWidget *widget,
GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
}
static void
gimp_editor_menu_position (GtkMenu *menu,
gint *x,
gint *y,
gpointer data)
{
GtkRequisition requisition;
GtkWidget *editor;
GdkScreen *screen;
gint editor_x;
gint editor_y;
editor = (GtkWidget *) data;
gdk_window_get_origin (editor->window, &editor_x, &editor_y);
gtk_widget_size_request (GTK_WIDGET (menu), &requisition);
*x = editor_x + editor->allocation.x + 2;
*y = editor_y + editor->allocation.y + 2;
screen = gtk_widget_get_screen (GTK_WIDGET (menu));
if (*x + requisition.width > gdk_screen_get_width (screen))
*x -= requisition.width;
if (*x < 0)
*x = 0;
if (*y + requisition.height > gdk_screen_get_height (screen))
*y -= requisition.height;
if (*y < 0)
*y = 0;
}
static gboolean
gimp_editor_popup_menu (GtkWidget *widget)
{
GimpEditor *editor;
editor = GIMP_EDITOR (widget);
if (editor->item_factory)
{
gimp_item_factory_popup_with_data (editor->item_factory,
editor->item_factory_data,
gimp_editor_menu_position,
editor,
NULL);
return TRUE;
}
return FALSE;
}
GtkWidget *
gimp_editor_new (void)
{

View File

@ -363,7 +363,8 @@
#define GIMP_HELP_DOCK_IMAGE_MENU "gimp-dock-image-menu"
#define GIMP_HELP_DOCK_AUTO_BUTTON "gimp-dock-auto-button"
#define GIMP_HELP_DOCK_TAB_ADD "gimp-dock-tab-add"
#define GIMP_HELP_DOCK_TAB_REMOVE "gimp-dock-tab-remove"
#define GIMP_HELP_DOCK_TAB_CLOSE "gimp-dock-tab-close"
#define GIMP_HELP_DOCK_TAB_DETACH "gimp-dock-tab-detach"
#define GIMP_HELP_DOCK_PREVIEW_SIZE "gimp-dock-preview-size"
#define GIMP_HELP_DOCK_TAB_STYLE "gimp-dock-tab-style"
#define GIMP_HELP_DOCK_VIEW_AS_LIST "gimp-dock-view-as-list"

View File

@ -117,6 +117,7 @@ gimp_item_factory_init (GimpItemFactory *factory)
factory->gimp = NULL;
factory->update_func = NULL;
factory->update_on_popup = FALSE;
factory->title = NULL;
factory->help_id = NULL;
factory->translation_trash = NULL;
}
@ -128,6 +129,12 @@ gimp_item_factory_finalize (GObject *object)
factory = GIMP_ITEM_FACTORY (object);
if (factory->title)
{
g_free (factory->title);
factory->title = NULL;
}
if (factory->help_id)
{
g_free (factory->help_id);
@ -170,6 +177,9 @@ gimp_item_factory_destroy (GtkObject *object)
}
GTK_OBJECT_CLASS (parent_class)->destroy (object);
if (GTK_ITEM_FACTORY (factory)->widget)
g_object_unref (GTK_ITEM_FACTORY (factory)->widget);
}
@ -179,6 +189,7 @@ GimpItemFactory *
gimp_item_factory_new (Gimp *gimp,
GType container_type,
const gchar *factory_path,
const gchar *title,
const gchar *help_id,
GimpItemFactoryUpdateFunc update_func,
gboolean update_on_popup,
@ -193,6 +204,7 @@ gimp_item_factory_new (Gimp *gimp,
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (factory_path != NULL, NULL);
g_return_val_if_fail (title != NULL, NULL);
g_return_val_if_fail (help_id != NULL, NULL);
g_return_val_if_fail (factory_path[0] == '<', NULL);
g_return_val_if_fail (factory_path[strlen (factory_path) - 1] == '>', NULL);
@ -214,6 +226,7 @@ gimp_item_factory_new (Gimp *gimp,
factory->gimp = gimp;
factory->update_func = update_func;
factory->update_on_popup = update_on_popup;
factory->title = g_strdup (title);
factory->help_id = g_strdup (help_id);
list = g_hash_table_lookup (factory_class->factories, factory_path);
@ -234,6 +247,9 @@ gimp_item_factory_new (Gimp *gimp,
g_type_class_unref (factory_class);
if (GTK_ITEM_FACTORY (factory)->widget)
g_object_ref (GTK_ITEM_FACTORY (factory)->widget);
return factory;
}

View File

@ -50,6 +50,7 @@ struct _GimpItemFactory
Gimp *gimp;
GimpItemFactoryUpdateFunc update_func;
gboolean update_on_popup;
gchar *title;
gchar *help_id;
GList *translation_trash;
@ -68,6 +69,7 @@ GType gimp_item_factory_get_type (void) G_GNUC_CONST;
GimpItemFactory * gimp_item_factory_new (Gimp *gimp,
GType container_type,
const gchar *factory_path,
const gchar *title,
const gchar *help_id,
GimpItemFactoryUpdateFunc update_func,
gboolean update_on_popup,

View File

@ -106,6 +106,7 @@ gimp_menu_factory_finalize (GObject *object)
entry = (GimpMenuFactoryEntry *) list->data;
g_free (entry->identifier);
g_free (entry->title);
g_free (entry->help_id);
g_free (entry);
}
@ -133,6 +134,7 @@ gimp_menu_factory_new (Gimp *gimp)
void
gimp_menu_factory_menu_register (GimpMenuFactory *factory,
const gchar *identifier,
const gchar *title,
const gchar *help_id,
GimpItemFactorySetupFunc setup_func,
GimpItemFactoryUpdateFunc update_func,
@ -144,6 +146,7 @@ gimp_menu_factory_menu_register (GimpMenuFactory *factory,
g_return_if_fail (GIMP_IS_MENU_FACTORY (factory));
g_return_if_fail (identifier != NULL);
g_return_if_fail (title != NULL);
g_return_if_fail (help_id != NULL);
g_return_if_fail (n_entries > 0);
g_return_if_fail (entries != NULL);
@ -151,6 +154,7 @@ gimp_menu_factory_menu_register (GimpMenuFactory *factory,
entry = g_new0 (GimpMenuFactoryEntry, 1);
entry->identifier = g_strdup (identifier);
entry->title = g_strdup (title);
entry->help_id = g_strdup (help_id);
entry->setup_func = setup_func;
entry->update_func = update_func;
@ -184,6 +188,7 @@ gimp_menu_factory_menu_new (GimpMenuFactory *factory,
item_factory = gimp_item_factory_new (factory->gimp,
container_type,
entry->identifier,
entry->title,
entry->help_id,
entry->update_func,
entry->update_on_popup,