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

undeprecated the paint mode menu (ported to GimpEnumComboBox with

2005-02-08  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimpwidgets-constructors.[ch]: undeprecated the
	paint mode menu (ported to GimpEnumComboBox with separators).
	The separator code is quite hackish and therefore still
	implemented privately here.

	* app/widgets/gimpbrushselect.c
	* app/widgets/gimplayertreeview.c
	* app/widgets/gimppropwidgets.c: changed accordingly.
parent d23ada70
2005-02-08 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpwidgets-constructors.[ch]: undeprecated the
paint mode menu (ported to GimpEnumComboBox with separators).
The separator code is quite hackish and therefore still
implemented privately here.
* app/widgets/gimpbrushselect.c
* app/widgets/gimplayertreeview.c
* app/widgets/gimppropwidgets.c: changed accordingly.
2005-02-08 Michael Natterer <mitch@gimp.org>
* configure.in: depend on GTK+ >= 2.6.0 and pango >= 1.8.0.
......
......@@ -209,15 +209,16 @@ gimp_brush_select_constructor (GType type,
select);
/* Create the paint mode option menu */
select->paint_mode_menu =
gimp_paint_mode_menu_new (G_CALLBACK (gimp_brush_select_mode_update),
select,
TRUE,
gimp_context_get_paint_mode (dialog->context));
select->paint_mode_menu = gimp_paint_mode_menu_new (TRUE);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 2,
_("Mode:"), 0.0, 0.5,
select->paint_mode_menu, 2, FALSE);
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (select->paint_mode_menu),
gimp_context_get_paint_mode (dialog->context),
G_CALLBACK (gimp_brush_select_mode_update),
select);
spacing_adj = GIMP_BRUSH_FACTORY_VIEW (dialog->view)->spacing_adjustment;
/* Use passed spacing instead of brushes default */
......@@ -325,8 +326,16 @@ gimp_brush_select_mode_changed (GimpContext *context,
GimpLayerModeEffects paint_mode,
GimpBrushSelect *select)
{
gimp_paint_mode_menu_set_history (GTK_OPTION_MENU (select->paint_mode_menu),
paint_mode);
g_signal_handlers_block_by_func (select->paint_mode_menu,
gimp_brush_select_mode_update,
select);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (select->paint_mode_menu),
paint_mode);
g_signal_handlers_unblock_by_func (select->paint_mode_menu,
gimp_brush_select_mode_update,
select);
gimp_pdb_dialog_run_callback (GIMP_PDB_DIALOG (select), FALSE);
}
......@@ -343,12 +352,14 @@ static void
gimp_brush_select_mode_update (GtkWidget *widget,
GimpBrushSelect *select)
{
GimpLayerModeEffects paint_mode;
gint paint_mode;
paint_mode = (GimpLayerModeEffects)
GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "gimp-item-data"));
gimp_context_set_paint_mode (GIMP_PDB_DIALOG (select)->context, paint_mode);
if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget),
&paint_mode))
{
gimp_context_set_paint_mode (GIMP_PDB_DIALOG (select)->context,
(GimpLayerModeEffects) paint_mode);
}
}
static void
......
......@@ -288,14 +288,15 @@ gimp_layer_tree_view_init (GimpLayerTreeView *view)
/* Paint mode menu */
view->paint_mode_menu =
gimp_paint_mode_menu_new (G_CALLBACK (gimp_layer_tree_view_paint_mode_menu_callback),
view,
FALSE,
GIMP_NORMAL_MODE);
view->paint_mode_menu = gimp_paint_mode_menu_new (FALSE);
gtk_box_pack_start (GTK_BOX (hbox), view->paint_mode_menu, TRUE, TRUE, 0);
gtk_widget_show (view->paint_mode_menu);
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (view->paint_mode_menu),
GIMP_NORMAL_MODE,
G_CALLBACK (gimp_layer_tree_view_paint_mode_menu_callback),
view);
gimp_help_set_help_data (view->paint_mode_menu, NULL,
GIMP_HELP_LAYER_DIALOG_PAINT_MODE_MENU);
......@@ -922,20 +923,21 @@ gimp_layer_tree_view_paint_mode_menu_callback (GtkWidget *widget,
GimpLayerTreeView *view)
{
GimpImage *gimage;
GimpLayer *layer;
GimpLayer *layer = NULL;
gimage = GIMP_ITEM_TREE_VIEW (view)->gimage;
layer = (GimpLayer *)
GIMP_ITEM_TREE_VIEW_GET_CLASS (view)->get_active_item (gimage);
if (gimage)
layer = (GimpLayer *)
GIMP_ITEM_TREE_VIEW_GET_CLASS (view)->get_active_item (gimage);
if (layer)
{
GimpLayerModeEffects mode =
GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget),
"gimp-item-data"));
gint mode;
if (gimp_layer_get_mode (layer) != mode)
if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget),
&mode) &&
gimp_layer_get_mode (layer) != (GimpLayerModeEffects) mode)
{
GimpUndo *undo;
gboolean push_undo = TRUE;
......@@ -948,12 +950,12 @@ gimp_layer_tree_view_paint_mode_menu_callback (GtkWidget *widget,
push_undo = FALSE;
BLOCK();
gimp_layer_set_mode (layer, mode, push_undo);
gimp_layer_set_mode (layer, (GimpLayerModeEffects) mode, push_undo);
UNBLOCK();
gimp_image_flush (gimage);
if (!push_undo)
if (! push_undo)
gimp_undo_refresh_preview (undo);
}
}
......@@ -1032,7 +1034,7 @@ gimp_layer_tree_view_opacity_scale_changed (GtkAdjustment *adjustment,
gimp_image_flush (gimage);
if (!push_undo)
if (! push_undo)
gimp_undo_refresh_preview (undo);
}
}
......@@ -1067,8 +1069,14 @@ static void
gimp_layer_tree_view_update_options (GimpLayerTreeView *view,
GimpLayer *layer)
{
gimp_paint_mode_menu_set_history (GTK_OPTION_MENU (view->paint_mode_menu),
layer->mode);
BLOCK (view->paint_mode_menu,
gimp_layer_tree_view_paint_mode_menu_callback);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (view->paint_mode_menu),
layer->mode);
UNBLOCK (view->paint_mode_menu,
gimp_layer_tree_view_paint_mode_menu_callback);
if (layer->preserve_trans !=
GTK_TOGGLE_BUTTON (view->preserve_trans_toggle)->active)
......
......@@ -107,10 +107,12 @@ gimp_prop_paint_mode_menu_new (GObject *config,
property_name, &value,
NULL);
menu = gimp_paint_mode_menu_new (G_CALLBACK (gimp_prop_paint_menu_callback),
config,
with_behind_mode,
value);
menu = gimp_paint_mode_menu_new (with_behind_mode);
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (menu),
value,
G_CALLBACK (gimp_prop_paint_menu_callback),
config);
set_param_spec (G_OBJECT (menu), menu, param_spec);
......@@ -125,28 +127,18 @@ static void
gimp_prop_paint_menu_callback (GtkWidget *widget,
GObject *config)
{
if (GTK_IS_MENU (widget->parent))
{
GtkWidget *menu;
menu = gtk_menu_get_attach_widget (GTK_MENU (widget->parent));
if (menu)
{
GParamSpec *param_spec;
gint value;
param_spec = get_param_spec (G_OBJECT (menu));
if (! param_spec)
return;
GParamSpec *param_spec;
gint value;
value = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget),
"gimp-item-data"));
param_spec = get_param_spec (G_OBJECT (widget));
if (! param_spec)
return;
g_object_set (config,
param_spec->name, value,
NULL);
}
if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value))
{
g_object_set (config,
param_spec->name, value,
NULL);
}
}
......@@ -161,7 +153,16 @@ gimp_prop_paint_menu_notify (GObject *config,
param_spec->name, &value,
NULL);
gimp_paint_mode_menu_set_history (GTK_OPTION_MENU (menu), value);
g_signal_handlers_block_by_func (menu,
gimp_prop_paint_menu_callback,
config);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (menu), value);
g_signal_handlers_unblock_by_func (menu,
gimp_prop_paint_menu_callback,
config);
}
......
......@@ -20,11 +20,6 @@
#include <gtk/gtk.h>
#ifdef __GNUC__
#warning GIMP_DISABLE_DEPRECATED
#endif
#undef GIMP_DISABLE_DEPRECATED
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
......@@ -34,89 +29,142 @@
#include "gimp-intl.h"
/* local function prototypes */
static gboolean gimp_paint_mode_menu_separator_func (GtkTreeModel *model,
GtkTreeIter *iter,
gpointer data);
/* public functions */
static void
gimp_int_store_insert_separator_after (GimpIntStore *store,
gint value,
gint separator_value)
{
GtkTreeIter value_iter;
GtkTreeIter sep_iter;
g_return_if_fail (GIMP_IS_INT_STORE (store));
if (gimp_int_store_lookup_by_value (GTK_TREE_MODEL (store),
value, &value_iter))
{
gtk_list_store_insert_after (GTK_LIST_STORE (store),
&sep_iter, &value_iter);
gtk_list_store_set (GTK_LIST_STORE (store), &sep_iter,
GIMP_INT_STORE_VALUE, separator_value,
-1);
}
}
GtkWidget *
gimp_paint_mode_menu_new (GCallback callback,
gpointer data,
gboolean with_behind_mode,
GimpLayerModeEffects initial)
gimp_paint_mode_menu_new (gboolean with_behind_mode)
{
GtkWidget *menu;
GtkListStore *store;
GtkWidget *combo;
if (with_behind_mode)
{
menu = gimp_int_option_menu_new
(FALSE, callback, data, initial,
_("Normal"), GIMP_NORMAL_MODE, NULL,
_("Dissolve"), GIMP_DISSOLVE_MODE, NULL,
_("Behind"), GIMP_BEHIND_MODE, NULL,
_("Color erase"), GIMP_COLOR_ERASE_MODE, NULL,
"---", 0, NULL,
_("Multiply"), GIMP_MULTIPLY_MODE, NULL,
_("Divide"), GIMP_DIVIDE_MODE, NULL,
_("Screen"), GIMP_SCREEN_MODE, NULL,
_("Overlay"), GIMP_OVERLAY_MODE, NULL,
"---", 0, NULL,
_("Dodge"), GIMP_DODGE_MODE, NULL,
_("Burn"), GIMP_BURN_MODE, NULL,
_("Hard light"), GIMP_HARDLIGHT_MODE, NULL,
_("Soft light"), GIMP_SOFTLIGHT_MODE, NULL,
_("Grain extract"), GIMP_GRAIN_EXTRACT_MODE, NULL,
_("Grain merge"), GIMP_GRAIN_MERGE_MODE, NULL,
"---", 0, NULL,
_("Difference"), GIMP_DIFFERENCE_MODE, NULL,
_("Addition"), GIMP_ADDITION_MODE, NULL,
_("Subtract"), GIMP_SUBTRACT_MODE, NULL,
_("Darken only"), GIMP_DARKEN_ONLY_MODE, NULL,
_("Lighten only"), GIMP_LIGHTEN_ONLY_MODE, NULL,
"---", 0, NULL,
_("Hue"), GIMP_HUE_MODE, NULL,
_("Saturation"), GIMP_SATURATION_MODE, NULL,
_("Color"), GIMP_COLOR_MODE, NULL,
_("Value"), GIMP_VALUE_MODE, NULL,
NULL);
store = gimp_enum_store_new_with_values (GIMP_TYPE_LAYER_MODE_EFFECTS,
23,
GIMP_NORMAL_MODE,
GIMP_DISSOLVE_MODE,
GIMP_BEHIND_MODE,
GIMP_COLOR_ERASE_MODE,
GIMP_MULTIPLY_MODE,
GIMP_DIVIDE_MODE,
GIMP_SCREEN_MODE,
GIMP_OVERLAY_MODE,
GIMP_DODGE_MODE,
GIMP_BURN_MODE,
GIMP_HARDLIGHT_MODE,
GIMP_SOFTLIGHT_MODE,
GIMP_GRAIN_EXTRACT_MODE,
GIMP_GRAIN_MERGE_MODE,
GIMP_DIFFERENCE_MODE,
GIMP_ADDITION_MODE,
GIMP_SUBTRACT_MODE,
GIMP_DARKEN_ONLY_MODE,
GIMP_LIGHTEN_ONLY_MODE,
GIMP_HUE_MODE,
GIMP_SATURATION_MODE,
GIMP_COLOR_MODE,
GIMP_VALUE_MODE);
gimp_int_store_insert_separator_after (GIMP_INT_STORE (store),
GIMP_COLOR_ERASE_MODE, -1);
}
else
{
menu = gimp_int_option_menu_new
(FALSE, callback, data, initial,
_("Normal"), GIMP_NORMAL_MODE, NULL,
_("Dissolve"), GIMP_DISSOLVE_MODE, NULL,
"---", 0, NULL,
_("Multiply"), GIMP_MULTIPLY_MODE, NULL,
_("Divide"), GIMP_DIVIDE_MODE, NULL,
_("Screen"), GIMP_SCREEN_MODE, NULL,
_("Overlay"), GIMP_OVERLAY_MODE, NULL,
"---", 0, NULL,
_("Dodge"), GIMP_DODGE_MODE, NULL,
_("Burn"), GIMP_BURN_MODE, NULL,
_("Hard light"), GIMP_HARDLIGHT_MODE, NULL,
_("Soft light"), GIMP_SOFTLIGHT_MODE, NULL,
_("Grain extract"), GIMP_GRAIN_EXTRACT_MODE, NULL,
_("Grain merge"), GIMP_GRAIN_MERGE_MODE, NULL,
"---", 0, NULL,
_("Difference"), GIMP_DIFFERENCE_MODE, NULL,
_("Addition"), GIMP_ADDITION_MODE, NULL,
_("Subtract"), GIMP_SUBTRACT_MODE, NULL,
_("Darken only"), GIMP_DARKEN_ONLY_MODE, NULL,
_("Lighten only"), GIMP_LIGHTEN_ONLY_MODE, NULL,
"---", 0, NULL,
_("Hue"), GIMP_HUE_MODE, NULL,
_("Saturation"), GIMP_SATURATION_MODE, NULL,
_("Color"), GIMP_COLOR_MODE, NULL,
_("Value"), GIMP_VALUE_MODE, NULL,
NULL);
store = gimp_enum_store_new_with_values (GIMP_TYPE_LAYER_MODE_EFFECTS,
21,
GIMP_NORMAL_MODE,
GIMP_DISSOLVE_MODE,
GIMP_MULTIPLY_MODE,
GIMP_DIVIDE_MODE,
GIMP_SCREEN_MODE,
GIMP_OVERLAY_MODE,
GIMP_DODGE_MODE,
GIMP_BURN_MODE,
GIMP_HARDLIGHT_MODE,
GIMP_SOFTLIGHT_MODE,
GIMP_GRAIN_EXTRACT_MODE,
GIMP_GRAIN_MERGE_MODE,
GIMP_DIFFERENCE_MODE,
GIMP_ADDITION_MODE,
GIMP_SUBTRACT_MODE,
GIMP_DARKEN_ONLY_MODE,
GIMP_LIGHTEN_ONLY_MODE,
GIMP_HUE_MODE,
GIMP_SATURATION_MODE,
GIMP_COLOR_MODE,
GIMP_VALUE_MODE);
gimp_int_store_insert_separator_after (GIMP_INT_STORE (store),
GIMP_DISSOLVE_MODE, -1);
}
return menu;
gimp_int_store_insert_separator_after (GIMP_INT_STORE (store),
GIMP_OVERLAY_MODE, -1);
gimp_int_store_insert_separator_after (GIMP_INT_STORE (store),
GIMP_GRAIN_MERGE_MODE, -1);
gimp_int_store_insert_separator_after (GIMP_INT_STORE (store),
GIMP_LIGHTEN_ONLY_MODE, -1);
combo = g_object_new (GIMP_TYPE_ENUM_COMBO_BOX,
"model", store,
NULL);
g_object_unref (store);
gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (combo),
gimp_paint_mode_menu_separator_func,
GINT_TO_POINTER (-1),
NULL);
return combo;
}
void
gimp_paint_mode_menu_set_history (GtkOptionMenu *menu,
GimpLayerModeEffects value)
/* private functions */
static gboolean
gimp_paint_mode_menu_separator_func (GtkTreeModel *model,
GtkTreeIter *iter,
gpointer data)
{
gimp_int_option_menu_set_history (menu, value);
gint value;
gtk_tree_model_get (model, iter, GIMP_INT_STORE_VALUE, &value, -1);
return value == GPOINTER_TO_INT (data);
}
......@@ -20,13 +20,7 @@
#define __GIMP_WIDGETS_CONSTRUCTORS_H__
GtkWidget * gimp_paint_mode_menu_new (GCallback callback,
gpointer data,
gboolean with_behind_mode,
GimpLayerModeEffects initial);
void gimp_paint_mode_menu_set_history (GtkOptionMenu *menu,
GimpLayerModeEffects value);
GtkWidget * gimp_paint_mode_menu_new (gboolean with_behind_mode);
#endif /* __GIMP_WIDGETS_CONSTRUCTORS_H__ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment