Derive GimpDisplayShell from GtkVBox instead of GimpImageWindow

...and pack the widget into a separately created GimpImageWindow.
This commit is contained in:
Michael Natterer
2009-09-29 20:56:14 +02:00
parent 253b8e2cbe
commit 59274856ad
4 changed files with 33 additions and 43 deletions

View File

@ -42,6 +42,7 @@
#include "gimpdisplayshell-handlers.h" #include "gimpdisplayshell-handlers.h"
#include "gimpdisplayshell-icon.h" #include "gimpdisplayshell-icon.h"
#include "gimpdisplayshell-transform.h" #include "gimpdisplayshell-transform.h"
#include "gimpimagewindow.h"
#include "gimp-intl.h" #include "gimp-intl.h"
@ -353,6 +354,7 @@ gimp_display_new (Gimp *gimp,
GimpDialogFactory *display_factory) GimpDialogFactory *display_factory)
{ {
GimpDisplay *display; GimpDisplay *display;
GtkWidget *window;
gint ID; gint ID;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
@ -381,24 +383,34 @@ gimp_display_new (Gimp *gimp,
gimp_display_connect (display, image); gimp_display_connect (display, image);
/* create the shell for the image */ /* create the shell for the image */
window = g_object_new (GIMP_TYPE_IMAGE_WINDOW,
"menu-factory", menu_factory,
"display-factory", display_factory,
/* The window position will be overridden by the
* dialog factory, it is only really used on first
* startup.
*/
display->image ? NULL : "window-position",
GTK_WIN_POS_CENTER,
NULL);
display->shell = gimp_display_shell_new (display, unit, scale, display->shell = gimp_display_shell_new (display, unit, scale,
menu_factory, popup_manager, popup_manager);
display_factory);
/* FIXME image window */ /* FIXME image window */
gimp_image_window_add_shell (GIMP_IMAGE_WINDOW (display->shell), gimp_image_window_add_shell (GIMP_IMAGE_WINDOW (window),
GIMP_DISPLAY_SHELL (display->shell)); GIMP_DISPLAY_SHELL (display->shell));
/* FIXME image window */ /* FIXME image window */
gimp_image_window_set_active_shell (GIMP_IMAGE_WINDOW (display->shell), gimp_image_window_set_active_shell (GIMP_IMAGE_WINDOW (window),
GIMP_DISPLAY_SHELL (display->shell)); GIMP_DISPLAY_SHELL (display->shell));
/* FIXME image window */ /* FIXME image window */
g_signal_connect (GIMP_IMAGE_WINDOW (display->shell)->statusbar, "cancel", g_signal_connect (GIMP_IMAGE_WINDOW (window)->statusbar, "cancel",
G_CALLBACK (gimp_display_progress_canceled), G_CALLBACK (gimp_display_progress_canceled),
display); display);
gtk_widget_show (display->shell); gtk_widget_show (window);
/* add the display to the list */ /* add the display to the list */
gimp_container_add (gimp->displays, GIMP_OBJECT (display)); gimp_container_add (gimp->displays, GIMP_OBJECT (display));

View File

@ -74,6 +74,7 @@
#include "gimpdisplayshell-selection.h" #include "gimpdisplayshell-selection.h"
#include "gimpdisplayshell-title.h" #include "gimpdisplayshell-title.h"
#include "gimpdisplayshell-transform.h" #include "gimpdisplayshell-transform.h"
#include "gimpimagewindow.h"
#include "gimpstatusbar.h" #include "gimpstatusbar.h"
#include "gimp-log.h" #include "gimp-log.h"
@ -136,7 +137,7 @@ static const guint8 * gimp_display_shell_get_icc_profile
G_DEFINE_TYPE_WITH_CODE (GimpDisplayShell, gimp_display_shell, G_DEFINE_TYPE_WITH_CODE (GimpDisplayShell, gimp_display_shell,
GIMP_TYPE_IMAGE_WINDOW, GTK_TYPE_VBOX,
G_IMPLEMENT_INTERFACE (GIMP_TYPE_PROGRESS, G_IMPLEMENT_INTERFACE (GIMP_TYPE_PROGRESS,
gimp_display_shell_progress_iface_init) gimp_display_shell_progress_iface_init)
G_IMPLEMENT_INTERFACE (GIMP_TYPE_COLOR_MANAGED, G_IMPLEMENT_INTERFACE (GIMP_TYPE_COLOR_MANAGED,
@ -381,6 +382,8 @@ gimp_display_shell_init (GimpDisplayShell *shell)
GDK_VISIBILITY_NOTIFY_MASK | GDK_VISIBILITY_NOTIFY_MASK |
GDK_SCROLL_MASK)); GDK_SCROLL_MASK));
gtk_box_set_spacing (GTK_BOX (shell), 1);
/* zoom model callback */ /* zoom model callback */
g_signal_connect_swapped (shell->zoom, "zoomed", g_signal_connect_swapped (shell->zoom, "zoomed",
G_CALLBACK (gimp_display_shell_scale_changed), G_CALLBACK (gimp_display_shell_scale_changed),
@ -764,9 +767,7 @@ GtkWidget *
gimp_display_shell_new (GimpDisplay *display, gimp_display_shell_new (GimpDisplay *display,
GimpUnit unit, GimpUnit unit,
gdouble scale, gdouble scale,
GimpMenuFactory *menu_factory, GimpUIManager *popup_manager)
GimpUIManager *popup_manager,
GimpDialogFactory *display_factory)
{ {
GimpDisplayShell *shell; GimpDisplayShell *shell;
GimpColorDisplayStack *filter; GimpColorDisplayStack *filter;
@ -783,23 +784,13 @@ gimp_display_shell_new (GimpDisplay *display,
gint shell_height; gint shell_height;
g_return_val_if_fail (GIMP_IS_DISPLAY (display), NULL); 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_UI_MANAGER (popup_manager), NULL);
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (display_factory), NULL);
/* the toplevel shell */ /* the toplevel shell */
shell = g_object_new (GIMP_TYPE_DISPLAY_SHELL, shell = g_object_new (GIMP_TYPE_DISPLAY_SHELL,
"menu-factory", menu_factory, "popup-manager", popup_manager,
"display-factory", display_factory, "display", display,
"popup-manager", popup_manager, "unit", unit,
"display", display,
"unit", unit,
/* The window position will be overridden by the
* dialog factory, it is only really used on first
* startup.
*/
display->image ? NULL : "window-position",
GTK_WIN_POS_CENTER,
NULL); NULL);
if (display->image) if (display->image)
@ -879,14 +870,9 @@ gimp_display_shell_new (GimpDisplay *display,
/* first, set up the container hierarchy *********************************/ /* first, set up the container hierarchy *********************************/
/* the vbox containing all widgets */
/* FIXME this will be the shell */
shell->disp_vbox = gtk_vbox_new (FALSE, 1);
/* a hbox for the inner_table and the vertical scrollbar */ /* a hbox for the inner_table and the vertical scrollbar */
upper_hbox = gtk_hbox_new (FALSE, 1); upper_hbox = gtk_hbox_new (FALSE, 1);
gtk_box_pack_start (GTK_BOX (shell->disp_vbox), upper_hbox, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (shell), upper_hbox, TRUE, TRUE, 0);
gtk_widget_show (upper_hbox); gtk_widget_show (upper_hbox);
/* the table containing origin, rulers and the canvas */ /* the table containing origin, rulers and the canvas */
@ -904,7 +890,7 @@ gimp_display_shell_new (GimpDisplay *display,
/* the hbox containing the quickmask button, vertical scrollbar and /* the hbox containing the quickmask button, vertical scrollbar and
the navigation button */ the navigation button */
lower_hbox = gtk_hbox_new (FALSE, 1); lower_hbox = gtk_hbox_new (FALSE, 1);
gtk_box_pack_start (GTK_BOX (shell->disp_vbox), lower_hbox, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (shell), lower_hbox, FALSE, FALSE, 0);
gtk_widget_show (lower_hbox); gtk_widget_show (lower_hbox);
/* create the scrollbars *************************************************/ /* create the scrollbars *************************************************/

View File

@ -19,9 +19,6 @@
#define __GIMP_DISPLAY_SHELL_H__ #define __GIMP_DISPLAY_SHELL_H__
#include "gimpimagewindow.h"
/* Apply to a float the same rounding mode used in the renderer */ /* Apply to a float the same rounding mode used in the renderer */
#define PROJ_ROUND(coord) ((gint) RINT (coord)) #define PROJ_ROUND(coord) ((gint) RINT (coord))
#define PROJ_ROUND64(coord) ((gint64) RINT (coord)) #define PROJ_ROUND64(coord) ((gint64) RINT (coord))
@ -60,12 +57,10 @@ typedef struct _GimpDisplayShellClass GimpDisplayShellClass;
struct _GimpDisplayShell struct _GimpDisplayShell
{ {
GimpImageWindow parent_instance; GtkVBox parent_instance;
/* --- cacheline 2 boundary (128 bytes) was 20 bytes ago --- */ /* --- cacheline 2 boundary (128 bytes) was 20 bytes ago --- */
GtkWidget *disp_vbox; /* FIXME temp hack */
GimpDisplay *display; GimpDisplay *display;
GimpUIManager *popup_manager; GimpUIManager *popup_manager;
@ -215,7 +210,7 @@ struct _GimpDisplayShell
struct _GimpDisplayShellClass struct _GimpDisplayShellClass
{ {
GimpImageWindowClass parent_class; GtkVBoxClass parent_class;
void (* scaled) (GimpDisplayShell *shell); void (* scaled) (GimpDisplayShell *shell);
void (* scrolled) (GimpDisplayShell *shell); void (* scrolled) (GimpDisplayShell *shell);
@ -228,9 +223,7 @@ GType gimp_display_shell_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_display_shell_new (GimpDisplay *display, GtkWidget * gimp_display_shell_new (GimpDisplay *display,
GimpUnit unit, GimpUnit unit,
gdouble scale, gdouble scale,
GimpMenuFactory *menu_factory, GimpUIManager *popup_manager);
GimpUIManager *popup_manager,
GimpDialogFactory *display_factory);
GimpImageWindow * gimp_display_shell_get_window (GimpDisplayShell *shell); GimpImageWindow * gimp_display_shell_get_window (GimpDisplayShell *shell);

View File

@ -478,10 +478,9 @@ gimp_image_window_add_shell (GimpImageWindow *window,
window->shells = g_list_append (window->shells, shell); window->shells = g_list_append (window->shells, shell);
/* FIXME multiple shells */ /* FIXME multiple shells */
gtk_box_pack_start (GTK_BOX (window->main_vbox), gtk_box_pack_start (GTK_BOX (window->main_vbox), GTK_WIDGET (shell),
shell->disp_vbox,
TRUE, TRUE, 0); TRUE, TRUE, 0);
gtk_widget_show (shell->disp_vbox); gtk_widget_show (GTK_WIDGET (shell));
} }
void void