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

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.
parent a8ed5f6b
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
......@@ -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)
{
GimpDockable *dockable;
gint page_num;
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));
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
if (dockable)
gimp_dockbook_remove (dockbook, dockable);
if (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)
{
GimpDockable *dockable;
gint page_num;
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
if (dockable)
{
GimpDialogFactoryEntry *entry;
if (dockable)
entry = g_object_get_data (G_OBJECT (dockable),
"gimp-dialog-factory-entry");
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)
{
gchar *identifier;
gchar *substring = NULL;
substring = strstr (identifier, "grid");
identifier = g_strdup (entry->identifier);
if (substring && view_type == GIMP_VIEW_TYPE_GRID)
return;
substring = strstr (identifier, "grid");
if (! substring)
{
substring = strstr (identifier, "list");
if (! substring)
substring = strstr (identifier, "list");
if (substring && view_type == GIMP_VIEW_TYPE_LIST)
return;
}
if (substring)
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)
{
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);
}
}
gimp_dockbook_add (dockbook, GIMP_DOCKABLE (new_dockable),
page_num);
gimp_dockbook_remove (dockbook, dockable);
g_free (identifier);
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)
{
GimpDockable *dockable;
gint page_num;
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
if (dockable)
{
GimpContainerView *view;
if (dockable)
{
GimpContainerView *view;
view = gimp_container_view_get_by_dockable (dockable);
view = gimp_container_view_get_by_dockable (dockable);
if (view)
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)
{
GimpDockable *dockable;
gint page_num;
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
if (dockable)
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;
dockbook = (GimpDockbook *) gtk_item_factory_popup_data_from_widget (widget);
GimpDockbook *dockbook = GIMP_DOCKBOOK (data);
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);
......
......@@ -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);
......
......@@ -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;
if (GIMP_IS_CONTAINER_VIEW (widget))
gimp_container_view_set_context (GIMP_CONTAINER_VIEW (widget), context);
}
GimpContainerView *view = gimp_container_view_get_by_dockable (dockable);
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;
if (GIMP_IS_EDITOR (widget))
{
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