Commit 5a43e55c authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

added GimpWindowTypeHint enum.

2003-11-20  Sven Neumann  <sven@gimp.org>

	* app/widgets/widgets-enums.[ch]: added GimpWindowTypeHint enum.

	* app/widgets/gimpwidgets-utils.{ch]: added a utility function
	that translates GimpWindowTypeHint to GdkWindowTypeHint.

	* app/config/gimpguiconfig.[ch]
	* app/config/gimprc-blurbs.h: added two new gimprc options that
	allow to configure which window type hint to set on the toolbox
	and on dock windows.

	* app/widgets/gimpdock.[ch}: use the window type hint from gimprc.
	Introduced construct properties and got rid of gimp_dock_construct().

	* app/widgets/gimpimagedock.c
	* app/widgets/gimptoolbox.c: changed accordingly.

	* app/gui/preferences-dialog.c (prefs_dialog_new): let the Themes
	frame expand.
parent 9a7229ac
2003-11-20 Sven Neumann <sven@gimp.org>
* app/widgets/widgets-enums.[ch]: added GimpWindowTypeHint enum.
* app/widgets/gimpwidgets-utils.{ch]: added a utility function
that translates GimpWindowTypeHint to GdkWindowTypeHint.
* app/config/gimpguiconfig.[ch]
* app/config/gimprc-blurbs.h: added two new gimprc options that
allow to configure which window type hint to set on the toolbox
and on dock windows.
* app/widgets/gimpdock.[ch}: use the window type hint from gimprc.
Introduced construct properties and got rid of gimp_dock_construct().
* app/widgets/gimpimagedock.c
* app/widgets/gimptoolbox.c: changed accordingly.
* app/gui/preferences-dialog.c (prefs_dialog_new): let the Themes
frame expand.
2003-11-20 Michael Natterer <mitch@gimp.org>
 
* app/display/gimpdisplay.c (gimp_display_paint_area): when
......@@ -49,14 +49,14 @@ static void gimp_gui_config_get_property (GObject *object,
GParamSpec *pspec);
#define DEFAULT_THEME "Default"
#define DEFAULT_THEME "Default"
#ifdef G_OS_WIN32
#define DEFAULT_GIMP_HELP_BROWSER GIMP_HELP_BROWSER_WEB_BROWSER
#define DEFAULT_WEB_BROWSER "not used on Windows"
# define DEFAULT_GIMP_HELP_BROWSER GIMP_HELP_BROWSER_WEB_BROWSER
# define DEFAULT_WEB_BROWSER "not used on Windows"
#else
#define DEFAULT_GIMP_HELP_BROWSER GIMP_HELP_BROWSER_GIMP
#define DEFAULT_WEB_BROWSER "mozilla %s"
# define DEFAULT_GIMP_HELP_BROWSER GIMP_HELP_BROWSER_GIMP
# define DEFAULT_WEB_BROWSER "mozilla %s"
#endif
enum
......@@ -82,7 +82,9 @@ enum
PROP_THEME,
PROP_USE_HELP,
PROP_HELP_BROWSER,
PROP_WEB_BROWSER
PROP_WEB_BROWSER,
PROP_TOOLBOX_WINDOW_TYPE,
PROP_DOCK_WINDOW_TYPE
};
static GObjectClass *parent_class = NULL;
......@@ -221,6 +223,18 @@ gimp_gui_config_class_init (GimpGuiConfigClass *klass)
GIMP_PARAM_PATH_FILE,
DEFAULT_WEB_BROWSER,
0);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_TOOLBOX_WINDOW_TYPE,
"toolbox-window-type",
TOOLBOX_WINDOW_TYPE_BLURB,
GIMP_TYPE_WINDOW_TYPE_HINT,
GIMP_WINDOW_TYPE_HINT_NORMAL,
GIMP_PARAM_RESTART);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_DOCK_WINDOW_TYPE,
"dock-window-type",
DOCK_WINDOW_TYPE_BLURB,
GIMP_TYPE_WINDOW_TYPE_HINT,
GIMP_WINDOW_TYPE_HINT_UTILITY,
GIMP_PARAM_RESTART);
}
static void
......@@ -311,6 +325,12 @@ gimp_gui_config_set_property (GObject *object,
g_free (gui_config->web_browser);
gui_config->web_browser = g_value_dup_string (value);
break;
case PROP_TOOLBOX_WINDOW_TYPE:
gui_config->toolbox_window_type = g_value_get_enum (value);
break;
case PROP_DOCK_WINDOW_TYPE:
gui_config->dock_window_type = g_value_get_enum (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
......@@ -391,6 +411,12 @@ gimp_gui_config_get_property (GObject *object,
case PROP_WEB_BROWSER:
g_value_set_string (value, gui_config->web_browser);
break;
case PROP_TOOLBOX_WINDOW_TYPE:
g_value_set_enum (value, gui_config->toolbox_window_type);
break;
case PROP_DOCK_WINDOW_TYPE:
g_value_set_enum (value, gui_config->dock_window_type);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
......
......@@ -61,6 +61,8 @@ struct _GimpGuiConfig
gboolean use_help;
GimpHelpBrowserType help_browser;
gchar *web_browser;
GimpWindowTypeHint toolbox_window_type;
GimpWindowTypeHint dock_window_type;
gint last_tip; /* saved in sessionrc */
};
......
......@@ -77,6 +77,10 @@ N_("Tools such as fuzzy-select and bucket fill find regions based on a " \
#define DEFAULT_FULLSCREEN_VIEW_BLURB \
"Sets the default settings used when an image is viewed in fullscreen mode."
#define DOCK_WINDOW_TYPE_BLURB \
N_("The window type hint that is set on dock windows. This may affect " \
"the way your window manager decorates and handles dock windows.")
#define ENVIRON_PATH_BLURB \
"Sets the environ search path."
......@@ -313,6 +317,10 @@ N_("The tile cache is used to make sure the GIMP doesn't thrash " \
"the GIMP to use more memory. Conversely, a smaller cache size " \
"causes the GIMP to use more swap space and less memory.")
#define TOOLBOX_WINDOW_TYPE_BLURB \
N_("The window type hint that is set on the toolbox. This may affect " \
"how your window manager decorates and handles the toolbox window.")
#define TRANSPARENCY_TYPE_BLURB \
N_("Sets the manner in which transparency is displayed in images.")
......
......@@ -1206,7 +1206,7 @@ prefs_dialog_new (Gimp *gimp,
GTK_BOX (vbox2));
/* Themes */
vbox2 = prefs_frame_new (_("Select Theme"), GTK_CONTAINER (vbox), FALSE);
vbox2 = prefs_frame_new (_("Select Theme"), GTK_CONTAINER (vbox), TRUE);
{
GtkWidget *scrolled_win;
......
......@@ -1206,7 +1206,7 @@ prefs_dialog_new (Gimp *gimp,
GTK_BOX (vbox2));
/* Themes */
vbox2 = prefs_frame_new (_("Select Theme"), GTK_CONTAINER (vbox), FALSE);
vbox2 = prefs_frame_new (_("Select Theme"), GTK_CONTAINER (vbox), TRUE);
{
GtkWidget *scrolled_win;
......
......@@ -27,6 +27,9 @@
#include "widgets-types.h"
#include "config/gimpguiconfig.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpmarshal.h"
......@@ -35,6 +38,7 @@
#include "gimpdock.h"
#include "gimpdockable.h"
#include "gimpdockbook.h"
#include "gimpwidgets-utils.h"
#include "gimp-intl.h"
......@@ -42,6 +46,13 @@
#define DEFAULT_SEPARATOR_HEIGHT 6
enum
{
PROP_0,
PROP_CONTEXT,
PROP_DIALOG_FACTORY
};
enum
{
BOOK_ADDED,
......@@ -50,19 +61,33 @@ enum
};
static void gimp_dock_class_init (GimpDockClass *klass);
static void gimp_dock_init (GimpDock *dock);
static void gimp_dock_class_init (GimpDockClass *klass);
static void gimp_dock_init (GimpDock *dock);
static GtkWidget * gimp_dock_separator_new (GimpDock *dock);
static GObject * gimp_dock_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static void gimp_dock_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_dock_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_dock_dispose (GObject *object);
static void gimp_dock_destroy (GtkObject *object);
static void gimp_dock_destroy (GtkObject *object);
static void gimp_dock_style_set (GtkWidget *widget,
GtkStyle *prev_style);
static void gimp_dock_style_set (GtkWidget *widget,
GtkStyle *prev_style);
static void gimp_dock_real_book_added (GimpDock *dock,
GimpDockbook *dockbook);
static void gimp_dock_real_book_removed (GimpDock *dock,
GimpDockbook *dockbook);
static void gimp_dock_real_book_added (GimpDock *dock,
GimpDockbook *dockbook);
static void gimp_dock_real_book_removed (GimpDock *dock,
GimpDockbook *dockbook);
static GtkWidget * gimp_dock_separator_new (GimpDock *dock);
static void gimp_dock_separator_drag_leave (GtkWidget *widget,
GdkDragContext *context,
guint time,
......@@ -80,27 +105,10 @@ static gboolean gimp_dock_separator_drag_drop (GtkWidget *widget,
guint time,
GimpDock *dock);
/*
static gboolean gimp_dock_separator_button_press (GtkWidget *widget,
GdkEventButton *bevent,
gpointer data);
static gboolean gimp_dock_separator_button_release (GtkWidget *widget,
GdkEventButton *bevent,
gpointer data);
static void gimp_dock_separator_drag_begin (GtkWidget *widget,
GdkDragContext *context,
gpointer data);
static void gimp_dock_separator_drag_end (GtkWidget *widget,
GdkDragContext *context,
gpointer data);
*/
static GtkWindowClass *parent_class = NULL;
static guint dock_signals[LAST_SIGNAL] = { 0 };
static GtkTargetEntry dialog_target_table[] =
static GtkWindowClass *parent_class = NULL;
static guint dock_signals[LAST_SIGNAL] = { 0 };
static GtkTargetEntry dialog_target_table[] =
{
GIMP_TARGET_DIALOG
};
......@@ -137,11 +145,13 @@ gimp_dock_get_type (void)
static void
gimp_dock_class_init (GimpDockClass *klass)
{
GtkObjectClass *object_class;
GObjectClass *object_class;
GtkObjectClass *gtk_object_class;
GtkWidgetClass *widget_class;
object_class = GTK_OBJECT_CLASS (klass);
widget_class = GTK_WIDGET_CLASS (klass);
object_class = G_OBJECT_CLASS (klass);
gtk_object_class = GTK_OBJECT_CLASS (klass);
widget_class = GTK_WIDGET_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
......@@ -165,13 +175,29 @@ gimp_dock_class_init (GimpDockClass *klass)
G_TYPE_NONE, 1,
GIMP_TYPE_DOCKBOOK);
object_class->destroy = gimp_dock_destroy;
object_class->constructor = gimp_dock_constructor;
object_class->set_property = gimp_dock_set_property;
object_class->get_property = gimp_dock_get_property;
object_class->dispose = gimp_dock_dispose;
gtk_object_class->destroy = gimp_dock_destroy;
widget_class->style_set = gimp_dock_style_set;
widget_class->style_set = gimp_dock_style_set;
klass->setup = NULL;
klass->book_added = gimp_dock_real_book_added;
klass->book_removed = gimp_dock_real_book_removed;
klass->setup = NULL;
klass->book_added = gimp_dock_real_book_added;
klass->book_removed = gimp_dock_real_book_removed;
g_object_class_install_property (object_class, PROP_CONTEXT,
g_param_spec_object ("context", NULL, NULL,
GIMP_TYPE_CONTEXT,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class, PROP_DIALOG_FACTORY,
g_param_spec_object ("dialog-factory", NULL, NULL,
GIMP_TYPE_DIALOG_FACTORY,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("separator_height",
......@@ -190,7 +216,6 @@ gimp_dock_init (GimpDock *dock)
dock->context = NULL;
gtk_window_set_role (GTK_WINDOW (dock), "gimp-dock");
gtk_window_set_type_hint (GTK_WINDOW (dock), GDK_WINDOW_TYPE_HINT_UTILITY);
gtk_window_set_resizable (GTK_WINDOW (dock), TRUE);
dock->main_vbox = gtk_vbox_new (FALSE, 0);
......@@ -207,14 +232,71 @@ gimp_dock_init (GimpDock *dock)
}
static void
gimp_dock_destroy (GtkObject *object)
gimp_dock_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpDock *dock;
GimpDock *dock = GIMP_DOCK (object);
dock = GIMP_DOCK (object);
switch (property_id)
{
case PROP_CONTEXT:
dock->context = GIMP_CONTEXT (g_value_dup_object (value));
break;
case PROP_DIALOG_FACTORY:
dock->dialog_factory = GIMP_DIALOG_FACTORY (g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
while (dock->dockbooks)
gimp_dock_remove_book (dock, GIMP_DOCKBOOK (dock->dockbooks->data));
static void
gimp_dock_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpDock *dock = GIMP_DOCK (object);
switch (property_id)
{
case PROP_CONTEXT:
g_value_set_object (value, dock->context);
break;
case PROP_DIALOG_FACTORY:
g_value_set_object (value, dock->dialog_factory);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static GObject *
gimp_dock_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GObject *object;
GimpGuiConfig *config;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
config = GIMP_GUI_CONFIG (GIMP_DOCK (object)->context->gimp->config);
gtk_window_set_type_hint (GTK_WINDOW (object),
gimp_window_type_hint_to_gdk_hint (config->dock_window_type));
return object;
}
static void
gimp_dock_dispose (GObject *object)
{
GimpDock *dock = GIMP_DOCK (object);
if (dock->context)
{
......@@ -222,6 +304,17 @@ gimp_dock_destroy (GtkObject *object)
dock->context = NULL;
}
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
gimp_dock_destroy (GtkObject *object)
{
GimpDock *dock = GIMP_DOCK (object);
while (dock->dockbooks)
gimp_dock_remove_book (dock, GIMP_DOCKBOOK (dock->dockbooks->data));
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
......@@ -311,21 +404,6 @@ gimp_dock_separator_new (GimpDock *dock)
return event_box;
}
gboolean
gimp_dock_construct (GimpDock *dock,
GimpDialogFactory *dialog_factory,
GimpContext *context)
{
g_return_val_if_fail (GIMP_IS_DOCK (dock), FALSE);
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (dialog_factory), FALSE);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
dock->dialog_factory = dialog_factory;
dock->context = g_object_ref (context);
return TRUE;
}
void
gimp_dock_setup (GimpDock *dock,
const GimpDock *template)
......
......@@ -70,10 +70,6 @@ struct _GimpDockClass
GType gimp_dock_get_type (void) G_GNUC_CONST;
gboolean gimp_dock_construct (GimpDock *dock,
GimpDialogFactory *dialog_factory,
GimpContext *context);
void gimp_dock_setup (GimpDock *dock,
const GimpDock *template);
void gimp_dock_set_aux_info (GimpDock *dock,
......
......@@ -396,15 +396,16 @@ gimp_image_dock_new (GimpDialogFactory *dialog_factory,
g_return_val_if_fail (GIMP_IS_CONTAINER (image_container), NULL);
g_return_val_if_fail (GIMP_IS_CONTAINER (display_container), NULL);
image_dock = g_object_new (GIMP_TYPE_IMAGE_DOCK, NULL);
image_dock->image_container = image_container;
image_dock->display_container = display_container;
context = gimp_context_new (dialog_factory->context->gimp,
"Dock Context", NULL);
gimp_dock_construct (GIMP_DOCK (image_dock), dialog_factory, context);
image_dock = g_object_new (GIMP_TYPE_IMAGE_DOCK,
"context", context,
"dialog-factory", dialog_factory,
NULL);
image_dock->image_container = image_container;
image_dock->display_container = display_container;
gimp_help_connect (GTK_WIDGET (image_dock), gimp_standard_help_func,
GIMP_HELP_DOCK, NULL);
......
......@@ -396,15 +396,16 @@ gimp_image_dock_new (GimpDialogFactory *dialog_factory,
g_return_val_if_fail (GIMP_IS_CONTAINER (image_container), NULL);
g_return_val_if_fail (GIMP_IS_CONTAINER (display_container), NULL);
image_dock = g_object_new (GIMP_TYPE_IMAGE_DOCK, NULL);
image_dock->image_container = image_container;
image_dock->display_container = display_container;
context = gimp_context_new (dialog_factory->context->gimp,
"Dock Context", NULL);
gimp_dock_construct (GIMP_DOCK (image_dock), dialog_factory, context);
image_dock = g_object_new (GIMP_TYPE_IMAGE_DOCK,
"context", context,
"dialog-factory", dialog_factory,
NULL);
image_dock->image_container = image_container;
image_dock->display_container = display_container;
gimp_help_connect (GTK_WIDGET (image_dock), gimp_standard_help_func,
GIMP_HELP_DOCK, NULL);
......
......@@ -27,6 +27,8 @@
#include "widgets-types.h"
#include "config/gimpguiconfig.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimplist.h"
......@@ -165,13 +167,6 @@ gimp_toolbox_init (GimpToolbox *toolbox)
GtkWidget *vbox;
gtk_window_set_role (GTK_WINDOW (toolbox), "gimp-toolbox");
gtk_window_set_title (GTK_WINDOW (toolbox), _("The GIMP"));
/* Docks are utility windows by default, but the toolbox doesn't fit
* into this category. 'Normal' is not correct as well but there
* doesn't seem to be a better match :-(
*/
gtk_window_set_type_hint (GTK_WINDOW (toolbox), GDK_WINDOW_TYPE_HINT_NORMAL);
main_vbox = GIMP_DOCK (toolbox)->main_vbox;
......@@ -415,7 +410,7 @@ gimp_toolbox_set_geometry (GimpToolbox *toolbox)
gtk_window_set_geometry_hints (GTK_WINDOW (toolbox),
NULL,
&geometry,
&geometry,
GDK_HINT_MIN_SIZE |
GDK_HINT_RESIZE_INC |
GDK_HINT_USER_POS);
......@@ -426,23 +421,31 @@ GtkWidget *
gimp_toolbox_new (GimpDialogFactory *dialog_factory,
Gimp *gimp)
{
GimpContext *context;
GimpToolbox *toolbox;
GdkDisplay *display;
GList *list;
GimpContext *context;
GimpToolbox *toolbox;
GimpGuiConfig *config;
GdkDisplay *display;
GList *list;
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (dialog_factory), NULL);
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
context = gimp_get_user_context (gimp);
toolbox = g_object_new (GIMP_TYPE_TOOLBOX, NULL);
gimp_dock_construct (GIMP_DOCK (toolbox), dialog_factory, context);
toolbox = g_object_new (GIMP_TYPE_TOOLBOX,
"title", _("The GIMP"),
"context", context,
"dialog-factory", dialog_factory,
NULL);
gimp_help_connect (GTK_WIDGET (toolbox), gimp_standard_help_func,
GIMP_HELP_TOOLBOX, NULL);
config = GIMP_GUI_CONFIG (gimp->config);
gtk_window_set_type_hint (GTK_WINDOW (toolbox),
gimp_window_type_hint_to_gdk_hint (config->toolbox_window_type));
/* We need to know when the current device changes, so we can update
* the correct tool - to do this we connect to motion events.
* We can't just use EXTENSION_EVENTS_CURSOR though, since that
......
......@@ -688,3 +688,18 @@ gimp_rgb_set_gdk_color (GimpRGB *rgb,
gimp_rgb_set_uchar (rgb, r, g, b);
}
GdkWindowTypeHint
gimp_window_type_hint_to_gdk_hint (GimpWindowTypeHint hint)
{
switch (hint)
{
case GIMP_WINDOW_TYPE_HINT_NORMAL:
return GDK_WINDOW_TYPE_HINT_NORMAL;
case GIMP_WINDOW_TYPE_HINT_UTILITY:
return GDK_WINDOW_TYPE_HINT_UTILITY;
}
return GDK_WINDOW_TYPE_HINT_NORMAL;
}
......@@ -66,5 +66,7 @@ void gimp_rgb_get_gdk_color (const GimpRGB *rgb,
void gimp_rgb_set_gdk_color (GimpRGB *rgb,
const GdkColor *gdk_color);
GdkWindowTypeHint gimp_window_type_hint_to_gdk_hint (GimpWindowTypeHint hint);
#endif /* __GIMP_WIDGETS_UTILS_H__ */
......@@ -131,6 +131,25 @@ gimp_view_type_get_type (void)
}
static const GEnumValue gimp_window_type_hint_enum_values[] =
{
{ GIMP_WINDOW_TYPE_HINT_NORMAL, N_("Normal"), "normal" },
{ GIMP_WINDOW_TYPE_HINT_UTILITY, N_("Utility"), "utility" },
{ 0, NULL, NULL }
};
GType
gimp_window_type_hint_get_type (void)
{
static GType enum_type = 0;
if (!enum_type)
enum_type = g_enum_register_static ("GimpWindowTypeHint", gimp_window_type_hint_enum_values);
return enum_type;
}
static const GEnumValue gimp_zoom_type_enum_values[] =
{
{ GIMP_ZOOM_IN, N_("Zoom in"), "in" },
......
......@@ -99,6 +99,17 @@ typedef enum
} GimpViewType;
#define GIMP_TYPE_WINDOW_TYPE_HINT (gimp_window_type_hint_get_type ())
GType gimp_window_type_hint_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_WINDOW_TYPE_HINT_NORMAL, /*< desc="Normal" >*/
GIMP_WINDOW_TYPE_HINT_UTILITY /*< desc="Utility" >*/
} GimpWindowTypeHint;