added a dialog factory for displays and register "gimp-no-image-window"

2008-03-23  Michael Natterer  <mitch@gimp.org>

	* app/dialogs/dialogs.[ch]: added a dialog factory for displays
	and register "gimp-no-image-window" with it.

	* app/display/gimpdisplay.[ch]: add a GimpDialogFactory parameter
	to gimp_display_new() and pass it on to gimp_display_shell_new().

	* app/display/gimpdisplayshell.[ch]: keep the passed
	GimpDialogFactory around. When the shell becomes empty, add it to
	the dialog factory and resize it to the remembered size; when it
	becomes non-empty, remove it from the dialog factory again.

	* app/gui/gui-vtable.c: pass the display dialog factory to
	gimp_display_new().


svn path=/trunk/; revision=25177
This commit is contained in:
Michael Natterer 2008-03-23 13:40:39 +00:00 committed by Michael Natterer
parent f9f24c59f0
commit 54d306e8ea
8 changed files with 156 additions and 41 deletions

View File

@ -1,3 +1,19 @@
2008-03-23 Michael Natterer <mitch@gimp.org>
* app/dialogs/dialogs.[ch]: added a dialog factory for displays
and register "gimp-no-image-window" with it.
* app/display/gimpdisplay.[ch]: add a GimpDialogFactory parameter
to gimp_display_new() and pass it on to gimp_display_shell_new().
* app/display/gimpdisplayshell.[ch]: keep the passed
GimpDialogFactory around. When the shell becomes empty, add it to
the dialog factory and resize it to the remembered size; when it
becomes non-empty, remove it from the dialog factory again.
* app/gui/gui-vtable.c: pass the display dialog factory to
gimp_display_new().
2008-03-23 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpdialogfactory.c: cleanup (move variables to

View File

@ -40,6 +40,7 @@
GimpDialogFactory *global_dialog_factory = NULL;
GimpDialogFactory *global_dock_factory = NULL;
GimpDialogFactory *global_toolbox_factory = NULL;
GimpDialogFactory *global_display_factory = NULL;
#define FOREIGN(id,singleton,remember_size) \
@ -257,6 +258,11 @@ dialogs_init (Gimp *gimp,
gimp_dialog_factory_set_constructor (global_dock_factory,
dialogs_dockable_constructor);
global_display_factory = gimp_dialog_factory_new ("display",
gimp_get_user_context (gimp),
menu_factory,
NULL);
for (i = 0; i < G_N_ELEMENTS (toplevel_entries); i++)
gimp_dialog_factory_register_entry (global_dialog_factory,
toplevel_entries[i].identifier,
@ -284,6 +290,17 @@ dialogs_init (Gimp *gimp,
dock_entries[i].session_managed,
dock_entries[i].remember_size,
dock_entries[i].remember_if_open);
gimp_dialog_factory_register_entry (global_display_factory,
"gimp-no-image-window",
NULL, NULL,
NULL, NULL,
NULL,
-1,
TRUE,
TRUE,
TRUE,
FALSE);
}
void
@ -314,6 +331,12 @@ dialogs_exit (Gimp *gimp)
g_object_unref (global_dock_factory);
global_dock_factory = NULL;
}
if (global_display_factory)
{
g_object_unref (global_display_factory);
global_display_factory = NULL;
}
}
GtkWidget *

View File

@ -23,6 +23,7 @@
extern GimpDialogFactory *global_dialog_factory;
extern GimpDialogFactory *global_dock_factory;
extern GimpDialogFactory *global_toolbox_factory;
extern GimpDialogFactory *global_display_factory;
void dialogs_init (Gimp *gimp,

View File

@ -348,7 +348,8 @@ gimp_display_new (Gimp *gimp,
GimpUnit unit,
gdouble scale,
GimpMenuFactory *menu_factory,
GimpUIManager *popup_manager)
GimpUIManager *popup_manager,
GimpDialogFactory *display_factory)
{
GimpDisplay *display;
gint ID;
@ -380,7 +381,8 @@ gimp_display_new (Gimp *gimp,
/* create the shell for the image */
display->shell = gimp_display_shell_new (display, unit, scale,
menu_factory, popup_manager);
menu_factory, popup_manager,
display_factory);
gtk_widget_show (display->shell);
g_signal_connect (GIMP_DISPLAY_SHELL (display->shell)->statusbar, "cancel",

View File

@ -64,7 +64,8 @@ GimpDisplay * gimp_display_new (Gimp *gimp,
GimpUnit unit,
gdouble scale,
GimpMenuFactory *menu_factory,
GimpUIManager *popup_manager);
GimpUIManager *popup_manager,
GimpDialogFactory *display_factory);
void gimp_display_delete (GimpDisplay *display);
gint gimp_display_get_ID (GimpDisplay *display);

View File

@ -47,8 +47,10 @@
#include "core/gimpsamplepoint.h"
#include "core/gimptemplate.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpmenufactory.h"
#include "widgets/gimpsessioninfo.h"
#include "widgets/gimpuimanager.h"
#include "widgets/gimpwidgets-utils.h"
@ -114,6 +116,8 @@ static void gimp_display_shell_screen_changed (GtkWidget *widget,
static gboolean gimp_display_shell_delete_event (GtkWidget *widget,
GdkEventAny *aevent);
static gboolean gimp_display_shell_popup_menu (GtkWidget *widget);
static void gimp_display_shell_style_set (GtkWidget *widget,
GtkStyle *prev_style);
static void gimp_display_shell_real_scaled (GimpDisplayShell *shell);
@ -203,6 +207,7 @@ gimp_display_shell_class_init (GimpDisplayShellClass *klass)
widget_class->screen_changed = gimp_display_shell_screen_changed;
widget_class->delete_event = gimp_display_shell_delete_event;
widget_class->popup_menu = gimp_display_shell_popup_menu;
widget_class->style_set = gimp_display_shell_style_set;
klass->scaled = gimp_display_shell_real_scaled;
klass->scrolled = NULL;
@ -580,6 +585,26 @@ gimp_display_shell_popup_menu (GtkWidget *widget)
return TRUE;
}
static void
gimp_display_shell_style_set (GtkWidget *widget,
GtkStyle *prev_style)
{
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (widget);
GtkRequisition menubar_req;
GtkRequisition statusbar_req;
GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
gtk_widget_size_request (shell->menubar, &menubar_req);
gtk_widget_size_request (shell->statusbar, &statusbar_req);
#if 0
/* this doesn't work */
gtk_widget_set_size_request (widget, -1,
menubar_req.height + statusbar_req.height);
#endif
}
static void
gimp_display_shell_real_scaled (GimpDisplayShell *shell)
{
@ -645,7 +670,8 @@ gimp_display_shell_new (GimpDisplay *display,
GimpUnit unit,
gdouble scale,
GimpMenuFactory *menu_factory,
GimpUIManager *popup_manager)
GimpUIManager *popup_manager,
GimpDialogFactory *display_factory)
{
GimpDisplayShell *shell;
GimpColorDisplayStack *filter;
@ -666,6 +692,7 @@ gimp_display_shell_new (GimpDisplay *display,
g_return_val_if_fail (GIMP_IS_DISPLAY (display), NULL);
g_return_val_if_fail (GIMP_IS_MENU_FACTORY (menu_factory), NULL);
g_return_val_if_fail (GIMP_IS_UI_MANAGER (popup_manager), NULL);
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (display_factory), NULL);
/* the toplevel shell */
shell = g_object_new (GIMP_TYPE_DISPLAY_SHELL,
@ -674,6 +701,8 @@ gimp_display_shell_new (GimpDisplay *display,
shell->display = display;
shell->display_factory = display_factory;
if (shell->display->image)
{
image_width = gimp_image_get_width (shell->display->image);
@ -1102,9 +1131,16 @@ gimp_display_shell_new (GimpDisplay *display,
}
if (shell->display->image)
{
gimp_display_shell_connect (shell);
}
else
{
gimp_statusbar_empty (GIMP_STATUSBAR (shell->statusbar));
gimp_dialog_factory_add_foreign (shell->display_factory,
"gimp-no-image-window",
GTK_WIDGET (shell));
}
gimp_display_shell_title_init (shell);
@ -1142,10 +1178,35 @@ gimp_display_shell_reconnect (GimpDisplayShell *shell)
void
gimp_display_shell_empty (GimpDisplayShell *shell)
{
GimpSessionInfo *session_info;
gint width;
gint height;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (GIMP_IS_DISPLAY (shell->display));
g_return_if_fail (shell->display->image == NULL);
/* get the NIW size before adding the display to the dialog factory
* so the window's current size doesn't affect the stored session
* info entry.
*/
session_info = gimp_dialog_factory_find_session_info (shell->display_factory,
"gimp-no-image-window");
if (session_info)
{
width = session_info->width;
height = session_info->height;
}
else
{
width = GTK_WIDGET (shell)->allocation.width;
height = GTK_WIDGET (shell)->allocation.height;
}
gimp_dialog_factory_add_foreign (shell->display_factory,
"gimp-no-image-window",
GTK_WIDGET (shell));
if (shell->fill_idle_id)
{
g_source_remove (shell->fill_idle_id);
@ -1166,6 +1227,8 @@ gimp_display_shell_empty (GimpDisplayShell *shell)
gimp_display_shell_appearance_update (shell);
gimp_display_shell_expose_full (shell);
gtk_window_resize (GTK_WINDOW (shell), width, height);
}
static gboolean
@ -1193,6 +1256,9 @@ gimp_display_shell_fill (GimpDisplayShell *shell,
g_return_if_fail (GIMP_IS_DISPLAY (shell->display));
g_return_if_fail (GIMP_IS_IMAGE (image));
gimp_dialog_factory_remove_dialog (shell->display_factory,
GTK_WIDGET (shell));
gimp_display_shell_set_unit (shell, unit);
gimp_display_shell_set_initial_scale (shell, scale,
&display_width, &display_height);

View File

@ -70,6 +70,8 @@ struct _GimpDisplayShell
GimpUIManager *menubar_manager;
GimpUIManager *popup_manager;
GimpDialogFactory *display_factory;
gdouble monitor_xres;
gdouble monitor_yres;
@ -209,7 +211,8 @@ GtkWidget * gimp_display_shell_new (GimpDisplay *display,
GimpUnit unit,
gdouble scale,
GimpMenuFactory *menu_factory,
GimpUIManager *popup_manager);
GimpUIManager *popup_manager,
GimpDialogFactory *display_factory);
void gimp_display_shell_reconnect (GimpDisplayShell *shell);

View File

@ -64,6 +64,8 @@
#include "menus/menus.h"
#include "dialogs/dialogs.h"
#include "gui-message.h"
#include "gui-vtable.h"
#include "themes.h"
@ -300,7 +302,8 @@ gui_display_create (Gimp *gimp,
display = gimp_display_new (gimp, image, unit, scale,
global_menu_factory,
image_managers->data);
image_managers->data,
global_display_factory);
}
if (gimp_context_get_display (context) == display)