added "icon_size" parameters to gimp_enum_stock_box_new[_with_range]().

2003-03-31  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimpenummenu.[ch]: added "icon_size" parameters
	to gimp_enum_stock_box_new[_with_range]().

	* app/tools/gimpcurvestool.c
	* app/widgets/gimppropwidgets.c: changed accordingly.

	* app/widgets/gimpeditor.[ch]: added gimp_editor_add_stock_box().

	* app/widgets/widgets-enums.[ch]: register GimpViewType with
	the type system.

	* app/widgets/gimpcontainerpopup.c: use a stock box for the
	view as list/grid buttons.
This commit is contained in:
Michael Natterer 2003-03-31 12:09:09 +00:00 committed by Michael Natterer
parent ff2757dff8
commit 529c5e71c4
11 changed files with 168 additions and 60 deletions

View File

@ -1,3 +1,19 @@
2003-03-31 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpenummenu.[ch]: added "icon_size" parameters
to gimp_enum_stock_box_new[_with_range]().
* app/tools/gimpcurvestool.c
* app/widgets/gimppropwidgets.c: changed accordingly.
* app/widgets/gimpeditor.[ch]: added gimp_editor_add_stock_box().
* app/widgets/widgets-enums.[ch]: register GimpViewType with
the type system.
* app/widgets/gimpcontainerpopup.c: use a stock box for the
view as list/grid buttons.
2003-03-31 Michael Natterer <mitch@gimp.org>
* plug-ins/common/xpm.c (save_image): free the original cmap

View File

@ -719,7 +719,7 @@ gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool)
gtk_widget_show (frame);
hbox = gimp_enum_stock_box_new (GIMP_TYPE_CURVE_TYPE,
"gimp-curve",
"gimp-curve", GTK_ICON_SIZE_MENU,
G_CALLBACK (curves_curve_type_callback),
c_tool,
&c_tool->curve_type);

View File

@ -35,6 +35,7 @@
#include "gimpcontainereditor.h"
#include "gimpcontainerpopup.h"
#include "gimpcontainergridview.h"
#include "gimpcontainertreeview.h"
#include "gimpdialogfactory.h"
#include "gimppreview.h"
@ -68,9 +69,7 @@ static void gimp_container_popup_smaller_clicked (GtkWidget *button,
GimpContainerPopup *popup);
static void gimp_container_popup_larger_clicked (GtkWidget *button,
GimpContainerPopup *popup);
static void gimp_container_popup_list_clicked (GtkWidget *button,
GimpContainerPopup *popup);
static void gimp_container_popup_grid_clicked (GtkWidget *button,
static void gimp_container_popup_view_type_toggled(GtkWidget *button,
GimpContainerPopup *popup);
static void gimp_container_popup_dialog_clicked (GtkWidget *button,
GimpContainerPopup *popup);
@ -468,33 +467,21 @@ gimp_container_popup_create_view (GimpContainerPopup *popup,
editor = GIMP_EDITOR (popup->editor->view);
gimp_editor_add_button (editor, GTK_STOCK_ZOOM_OUT,
_("Smaller Previews"), NULL,
_("Smaller previews"), NULL,
G_CALLBACK (gimp_container_popup_smaller_clicked),
NULL,
popup);
gimp_editor_add_button (editor, GTK_STOCK_ZOOM_IN,
_("Larger Previews"), NULL,
_("Larger previews"), NULL,
G_CALLBACK (gimp_container_popup_larger_clicked),
NULL,
popup);
button =
gimp_editor_add_button (editor, GIMP_STOCK_LIST,
_("View as List"), NULL,
G_CALLBACK (gimp_container_popup_list_clicked),
NULL,
button = gimp_editor_add_stock_box (editor, GIMP_TYPE_VIEW_TYPE, "gimp",
G_CALLBACK (gimp_container_popup_view_type_toggled),
popup);
if (view_type == GIMP_VIEW_TYPE_LIST)
gtk_widget_set_sensitive (button, FALSE);
button =
gimp_editor_add_button (editor, GIMP_STOCK_GRID,
_("View as Grid"), NULL,
G_CALLBACK (gimp_container_popup_grid_clicked),
NULL,
popup);
if (view_type == GIMP_VIEW_TYPE_GRID)
gtk_widget_set_sensitive (button, FALSE);
gimp_radio_group_set_active (GTK_RADIO_BUTTON (button),
GINT_TO_POINTER (view_type));
if (popup->dialog_factory)
gimp_editor_add_button (editor, popup->dialog_stock_id,
@ -533,21 +520,33 @@ gimp_container_popup_larger_clicked (GtkWidget *button,
}
static void
gimp_container_popup_list_clicked (GtkWidget *button,
gimp_container_popup_view_type_toggled (GtkWidget *button,
GimpContainerPopup *popup)
{
gtk_container_remove (GTK_CONTAINER (popup->frame),
GTK_WIDGET (popup->editor));
gimp_container_popup_create_view (popup, GIMP_VIEW_TYPE_LIST);
if (GTK_TOGGLE_BUTTON (button)->active)
{
GimpViewType view_type;
view_type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button),
"gimp-item-data"));
switch (view_type)
{
case GIMP_VIEW_TYPE_LIST:
if (GIMP_IS_CONTAINER_TREE_VIEW (popup->editor->view))
return;
break;
case GIMP_VIEW_TYPE_GRID:
if (GIMP_IS_CONTAINER_GRID_VIEW (popup->editor->view))
return;
break;
}
static void
gimp_container_popup_grid_clicked (GtkWidget *button,
GimpContainerPopup *popup)
{
gtk_container_remove (GTK_CONTAINER (popup->frame),
GTK_WIDGET (popup->editor));
gimp_container_popup_create_view (popup, GIMP_VIEW_TYPE_GRID);
gimp_container_popup_create_view (popup, view_type);
}
}
static void

View File

@ -29,6 +29,7 @@
#include "gimpeditor.h"
#include "gimpdnd.h"
#include "gimpenummenu.h"
#include "gimpmenufactory.h"
@ -270,3 +271,58 @@ gimp_editor_add_button (GimpEditor *editor,
return button;
}
GtkWidget *
gimp_editor_add_stock_box (GimpEditor *editor,
GType enum_type,
const gchar *stock_prefix,
GCallback callback,
gpointer callback_data)
{
GtkWidget *hbox;
GtkWidget *first_button;
gint button_spacing;
GtkIconSize button_icon_size;
GList *children;
GList *list;
g_return_val_if_fail (GIMP_IS_EDITOR (editor), NULL);
g_return_val_if_fail (g_type_is_a (enum_type, G_TYPE_ENUM), NULL);
g_return_val_if_fail (stock_prefix != NULL, NULL);
gtk_widget_style_get (GTK_WIDGET (editor),
"button_spacing", &button_spacing,
"button_icon_size", &button_icon_size,
NULL);
if (! editor->button_box)
{
editor->button_box = gtk_hbox_new (TRUE, button_spacing);
gtk_box_pack_end (GTK_BOX (editor), editor->button_box, FALSE, FALSE, 0);
gtk_widget_show (editor->button_box);
}
hbox = gimp_enum_stock_box_new (enum_type, stock_prefix, button_icon_size,
callback, callback_data,
&first_button);
children = gtk_container_get_children (GTK_CONTAINER (hbox));
for (list = children; list; list = g_list_next (list))
{
GtkWidget *button = list->data;
g_object_ref (button);
gtk_container_remove (GTK_CONTAINER (hbox), button);
gtk_box_pack_start (GTK_BOX (editor->button_box), button,
TRUE, TRUE, 0);
g_object_unref (button);
}
g_list_free (children);
gtk_widget_destroy (hbox);
return first_button;
}

View File

@ -68,6 +68,11 @@ GtkWidget * gimp_editor_add_button (GimpEditor *editor,
GCallback callback,
GCallback extended_callback,
gpointer callback_data);
GtkWidget * gimp_editor_add_stock_box (GimpEditor *editor,
GType enum_type,
const gchar *stock_prefix,
GCallback callback,
gpointer callback_data);
#endif /* __GIMP_EDITOR_H__ */

View File

@ -599,6 +599,7 @@ gimp_enum_radio_frame_new_with_range (GType enum_type,
GtkWidget *
gimp_enum_stock_box_new (GType enum_type,
const gchar *stock_prefix,
GtkIconSize icon_size,
GCallback callback,
gpointer callback_data,
GtkWidget **first_button)
@ -613,7 +614,7 @@ gimp_enum_stock_box_new (GType enum_type,
box = gimp_enum_stock_box_new_with_range (enum_type,
enum_class->minimum,
enum_class->maximum,
stock_prefix,
stock_prefix, icon_size,
callback, callback_data,
first_button);
@ -627,6 +628,7 @@ gimp_enum_stock_box_new_with_range (GType enum_type,
gint minimum,
gint maximum,
const gchar *stock_prefix,
GtkIconSize icon_size,
GCallback callback,
gpointer callback_data,
GtkWidget **first_button)
@ -665,7 +667,7 @@ gimp_enum_stock_box_new_with_range (GType enum_type,
stock_id = g_strconcat (stock_prefix, "-", value->value_nick, NULL);
image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU);
image = gtk_image_new_from_stock (stock_id, icon_size);
g_free (stock_id);

View File

@ -123,6 +123,7 @@ GtkWidget * gimp_enum_radio_frame_new_with_range (GType enum_type,
GtkWidget * gimp_enum_stock_box_new (GType enum_type,
const gchar *stock_prefix,
GtkIconSize icon_size,
GCallback callback,
gpointer callback_data,
GtkWidget **first_button);
@ -130,6 +131,7 @@ GtkWidget * gimp_enum_stock_box_new_with_range (GType enum_type,
gint minimum,
gint maximum,
const gchar *stock_prefix,
GtkIconSize icon_size,
GCallback callback,
gpointer callback_data,
GtkWidget **first_button);

View File

@ -577,6 +577,7 @@ gimp_prop_enum_stock_box_new (GObject *config,
box = gimp_enum_stock_box_new_with_range (param_spec->value_type,
minimum, maximum,
stock_prefix,
GTK_ICON_SIZE_MENU,
G_CALLBACK (gimp_prop_radio_button_callback),
config,
&button);
@ -585,6 +586,7 @@ gimp_prop_enum_stock_box_new (GObject *config,
{
box = gimp_enum_stock_box_new (param_spec->value_type,
stock_prefix,
GTK_ICON_SIZE_MENU,
G_CALLBACK (gimp_prop_radio_button_callback),
config,
&button);

View File

@ -65,5 +65,24 @@ gimp_histogram_scale_get_type (void)
}
static const GEnumValue gimp_view_type_enum_values[] =
{
{ GIMP_VIEW_TYPE_LIST, N_("View as list"), "list" },
{ GIMP_VIEW_TYPE_GRID, N_("View as grid"), "grid" },
{ 0, NULL, NULL }
};
GType
gimp_view_type_get_type (void)
{
static GType enum_type = 0;
if (!enum_type)
enum_type = g_enum_register_static ("GimpViewType", gimp_view_type_enum_values);
return enum_type;
}
/* Generated data ends here */

View File

@ -59,6 +59,17 @@ typedef enum
} GimpHistogramScale;
#define GIMP_TYPE_VIEW_TYPE (gimp_view_type_get_type ())
GType gimp_view_type_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_VIEW_TYPE_LIST, /*< desc="View as list" >*/
GIMP_VIEW_TYPE_GRID /*< desc="View as grid" >*/
} GimpViewType;
/*
* non-registered enums; register them if needed
*/
@ -69,12 +80,6 @@ typedef enum /*< skip >*/
GIMP_PREVIEW_BG_WHITE
} GimpPreviewBG;
typedef enum /*< skip >*/
{
GIMP_VIEW_TYPE_GRID,
GIMP_VIEW_TYPE_LIST
} GimpViewType;
typedef enum /*< skip >*/
{
GIMP_DROP_NONE,

View File

@ -577,6 +577,7 @@ gimp_prop_enum_stock_box_new (GObject *config,
box = gimp_enum_stock_box_new_with_range (param_spec->value_type,
minimum, maximum,
stock_prefix,
GTK_ICON_SIZE_MENU,
G_CALLBACK (gimp_prop_radio_button_callback),
config,
&button);
@ -585,6 +586,7 @@ gimp_prop_enum_stock_box_new (GObject *config,
{
box = gimp_enum_stock_box_new (param_spec->value_type,
stock_prefix,
GTK_ICON_SIZE_MENU,
G_CALLBACK (gimp_prop_radio_button_callback),
config,
&button);