From 5de9756f9ad500e2d16b254667544e20176497e3 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Tue, 11 May 2004 12:13:31 +0000 Subject: [PATCH] app/widgets/Makefile.am app/widgets/widgets-types.h added new widget, 2004-05-11 Sven Neumann * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpcontainercombobox.[ch]: added new widget, almost finished. * app/widgets/gimpcontainerview.[ch]: added convenience functions to get and set the GimpContainerView properties. * app/widgets/gimpcontainerbox.c: use the convenience functions. * app/gui/file-new-dialog.c: use the new GimpContainerComboBox. * etc/templaterc: use "pixels" as the unit for pixel sized templates. --- ChangeLog | 16 + app/dialogs/image-new-dialog.c | 23 +- app/gui/file-new-dialog.c | 23 +- app/widgets/Makefile.am | 2 + app/widgets/gimpcontainerbox.c | 81 +----- app/widgets/gimpcontainercombobox.c | 435 ++++++++++++++++++++++++++++ app/widgets/gimpcontainercombobox.h | 58 ++++ app/widgets/gimpcontainerview.c | 50 ++++ app/widgets/gimpcontainerview.h | 20 ++ app/widgets/widgets-types.h | 1 + etc/templaterc | 16 +- 11 files changed, 612 insertions(+), 113 deletions(-) create mode 100644 app/widgets/gimpcontainercombobox.c create mode 100644 app/widgets/gimpcontainercombobox.h diff --git a/ChangeLog b/ChangeLog index 867653ee93..68dbf0b0bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2004-05-11 Sven Neumann + + * app/widgets/Makefile.am + * app/widgets/widgets-types.h + * app/widgets/gimpcontainercombobox.[ch]: added new widget, almost + finished. + + * app/widgets/gimpcontainerview.[ch]: added convenience functions + to get and set the GimpContainerView properties. + + * app/widgets/gimpcontainerbox.c: use the convenience functions. + + * app/gui/file-new-dialog.c: use the new GimpContainerComboBox. + + * etc/templaterc: use "pixels" as the unit for pixel sized templates. + 2004-05-11 Michael Natterer * app/widgets/gimpchanneltreeview.c diff --git a/app/dialogs/image-new-dialog.c b/app/dialogs/image-new-dialog.c index 3ad427c53a..aea81a2b73 100644 --- a/app/dialogs/image-new-dialog.c +++ b/app/dialogs/image-new-dialog.c @@ -36,7 +36,8 @@ #include "core/gimpimage-new.h" #include "core/gimptemplate.h" -#include "widgets/gimpcontainermenuimpl.h" +#include "widgets/gimpcontainercombobox.h" +#include "widgets/gimpcontainerview.h" #include "widgets/gimphelp-ids.h" #include "widgets/gimptemplateeditor.h" @@ -52,7 +53,7 @@ typedef struct GtkWidget *dialog; GtkWidget *confirm_dialog; - GtkWidget *template_menu; + GtkWidget *combo; GtkWidget *editor; Gimp *gimp; @@ -81,7 +82,6 @@ file_new_dialog_new (Gimp *gimp) FileNewDialog *dialog; GtkWidget *main_vbox; GtkWidget *table; - GtkWidget *optionmenu; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); @@ -124,22 +124,13 @@ file_new_dialog_new (Gimp *gimp) gtk_box_pack_start (GTK_BOX (main_vbox), table, FALSE, FALSE, 0); gtk_widget_show (table); - optionmenu = gtk_option_menu_new (); + dialog->combo = gimp_container_combo_box_new (gimp->templates, NULL, 16, 0); gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, _("_Template:"), 1.0, 0.5, - optionmenu, 1, FALSE); + dialog->combo, 1, FALSE); - dialog->template_menu = gimp_container_menu_new (gimp->templates, - NULL, 16, 0); - gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), - dialog->template_menu); - gtk_widget_show (dialog->template_menu); - - gimp_container_menu_select_item (GIMP_CONTAINER_MENU (dialog->template_menu), - NULL); - - g_signal_connect (dialog->template_menu, "select_item", + g_signal_connect (dialog->combo, "select_item", G_CALLBACK (file_new_template_select), dialog); @@ -168,7 +159,7 @@ file_new_dialog_set (GtkWidget *widget, if (template) { - gimp_container_menu_select_item (GIMP_CONTAINER_MENU (dialog->template_menu), + gimp_container_view_select_item (GIMP_CONTAINER_VIEW (dialog->combo), GIMP_VIEWABLE (template)); } else diff --git a/app/gui/file-new-dialog.c b/app/gui/file-new-dialog.c index 3ad427c53a..aea81a2b73 100644 --- a/app/gui/file-new-dialog.c +++ b/app/gui/file-new-dialog.c @@ -36,7 +36,8 @@ #include "core/gimpimage-new.h" #include "core/gimptemplate.h" -#include "widgets/gimpcontainermenuimpl.h" +#include "widgets/gimpcontainercombobox.h" +#include "widgets/gimpcontainerview.h" #include "widgets/gimphelp-ids.h" #include "widgets/gimptemplateeditor.h" @@ -52,7 +53,7 @@ typedef struct GtkWidget *dialog; GtkWidget *confirm_dialog; - GtkWidget *template_menu; + GtkWidget *combo; GtkWidget *editor; Gimp *gimp; @@ -81,7 +82,6 @@ file_new_dialog_new (Gimp *gimp) FileNewDialog *dialog; GtkWidget *main_vbox; GtkWidget *table; - GtkWidget *optionmenu; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); @@ -124,22 +124,13 @@ file_new_dialog_new (Gimp *gimp) gtk_box_pack_start (GTK_BOX (main_vbox), table, FALSE, FALSE, 0); gtk_widget_show (table); - optionmenu = gtk_option_menu_new (); + dialog->combo = gimp_container_combo_box_new (gimp->templates, NULL, 16, 0); gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, _("_Template:"), 1.0, 0.5, - optionmenu, 1, FALSE); + dialog->combo, 1, FALSE); - dialog->template_menu = gimp_container_menu_new (gimp->templates, - NULL, 16, 0); - gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), - dialog->template_menu); - gtk_widget_show (dialog->template_menu); - - gimp_container_menu_select_item (GIMP_CONTAINER_MENU (dialog->template_menu), - NULL); - - g_signal_connect (dialog->template_menu, "select_item", + g_signal_connect (dialog->combo, "select_item", G_CALLBACK (file_new_template_select), dialog); @@ -168,7 +159,7 @@ file_new_dialog_set (GtkWidget *widget, if (template) { - gimp_container_menu_select_item (GIMP_CONTAINER_MENU (dialog->template_menu), + gimp_container_view_select_item (GIMP_CONTAINER_VIEW (dialog->combo), GIMP_VIEWABLE (template)); } else diff --git a/app/widgets/Makefile.am b/app/widgets/Makefile.am index 9de0f65529..4597a9ad7f 100644 --- a/app/widgets/Makefile.am +++ b/app/widgets/Makefile.am @@ -51,6 +51,8 @@ libappwidgets_a_sources = \ gimpcomponenteditor.h \ gimpcontainerbox.c \ gimpcontainerbox.h \ + gimpcontainercombobox.c \ + gimpcontainercombobox.h \ gimpcontainereditor.c \ gimpcontainereditor.h \ gimpcontainergridview.c \ diff --git a/app/widgets/gimpcontainerbox.c b/app/widgets/gimpcontainerbox.c index f68061e2d6..6174ee3242 100644 --- a/app/widgets/gimpcontainerbox.c +++ b/app/widgets/gimpcontainerbox.c @@ -41,29 +41,11 @@ #include "gimppropwidgets.h" -enum -{ - PROP_0, - PROP_CONTAINER, - PROP_CONTEXT, - PROP_REORDERABLE -}; - - static void gimp_container_box_class_init (GimpContainerBoxClass *klass); static void gimp_container_box_init (GimpContainerBox *box); static void gimp_container_box_view_iface_init (GimpContainerViewInterface *view_iface); static void gimp_container_box_docked_iface_init (GimpDockedInterface *docked_iface); -static void gimp_container_box_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec); -static void gimp_container_box_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec); - static GtkWidget * gimp_container_box_get_preview (GimpDocked *docked, GimpContext *context, GtkIconSize size); @@ -128,14 +110,17 @@ gimp_container_box_class_init (GimpContainerBoxClass *klass) parent_class = g_type_class_peek_parent (klass); - object_class->set_property = gimp_container_box_set_property; - object_class->get_property = gimp_container_box_get_property; + object_class->set_property = gimp_container_view_set_property; + object_class->get_property = gimp_container_view_get_property; - g_object_class_override_property (object_class, PROP_CONTAINER, + g_object_class_override_property (object_class, + GIMP_CONTAINER_VIEW_PROP_CONTAINER, "container"); - g_object_class_override_property (object_class, PROP_CONTEXT, + g_object_class_override_property (object_class, + GIMP_CONTAINER_VIEW_PROP_CONTEXT, "context"); - g_object_class_override_property (object_class, PROP_REORDERABLE, + g_object_class_override_property (object_class, + GIMP_CONTAINER_VIEW_PROP_REORDERABLE, "reorderable"); } @@ -166,56 +151,6 @@ gimp_container_box_docked_iface_init (GimpDockedInterface *docked_iface) docked_iface->set_context = gimp_container_box_set_context; } -static void -gimp_container_box_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - GimpContainerView *view = GIMP_CONTAINER_VIEW (object); - - switch (property_id) - { - case PROP_CONTAINER: - gimp_container_view_set_container (view, g_value_get_object (value)); - break; - case PROP_CONTEXT: - gimp_container_view_set_context (view, g_value_get_object (value)); - break; - case PROP_REORDERABLE: - gimp_container_view_set_reorderable (view, g_value_get_boolean (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -gimp_container_box_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - GimpContainerView *view = GIMP_CONTAINER_VIEW (object); - - switch (property_id) - { - case PROP_CONTAINER: - g_value_set_object (value, gimp_container_view_get_container (view)); - break; - case PROP_CONTEXT: - g_value_set_object (value, gimp_container_view_get_context (view)); - break; - case PROP_REORDERABLE: - g_value_set_boolean (value, gimp_container_view_get_reorderable (view)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - void gimp_container_box_set_size_request (GimpContainerBox *box, gint width, diff --git a/app/widgets/gimpcontainercombobox.c b/app/widgets/gimpcontainercombobox.c new file mode 100644 index 0000000000..622859a110 --- /dev/null +++ b/app/widgets/gimpcontainercombobox.c @@ -0,0 +1,435 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * gimpcontainercombobox.c + * Copyright (C) 2003 Michael Natterer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "config.h" + +#include + +#include + +#include "widgets-types.h" + +#include "core/gimpcontainer.h" +#include "core/gimpcontext.h" +#include "core/gimpviewable.h" + +#include "gimpcellrendererviewable.h" +#include "gimpcontainercombobox.h" +#include "gimpcontainerview.h" +#include "gimppreviewrenderer.h" + + +enum +{ + COLUMN_RENDERER, + COLUMN_NAME, + NUM_COLUMNS +}; + + +static void gimp_container_combo_box_class_init (GimpContainerComboBoxClass *klass); +static void gimp_container_combo_box_init (GimpContainerComboBox *view); + +static void gimp_container_combo_box_view_iface_init (GimpContainerViewInterface *view_iface); + +static gpointer gimp_container_combo_box_insert_item (GimpContainerView *view, + GimpViewable *viewable, + gint index); +static void gimp_container_combo_box_remove_item (GimpContainerView *view, + GimpViewable *viewable, + gpointer insert_data); +static void gimp_container_combo_box_reorder_item (GimpContainerView *view, + GimpViewable *viewable, + gint new_index, + gpointer insert_data); +static void gimp_container_combo_box_rename_item (GimpContainerView *view, + GimpViewable *viewable, + gpointer insert_data); +static gboolean gimp_container_combo_box_select_item (GimpContainerView *view, + GimpViewable *viewable, + gpointer insert_data); +static void gimp_container_combo_box_clear_items (GimpContainerView *view); +static void gimp_container_combo_box_set_preview_size (GimpContainerView *view); + +static void gimp_container_combo_box_changed (GtkComboBox *combo_box); + + +static GtkComboBoxClass *parent_class = NULL; +static GimpContainerViewInterface *parent_view_iface = NULL; + + +GType +gimp_container_combo_box_get_type (void) +{ + static GType view_type = 0; + + if (! view_type) + { + static const GTypeInfo view_info = + { + sizeof (GimpContainerComboBoxClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) gimp_container_combo_box_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (GimpContainerComboBox), + 0, /* n_preallocs */ + (GInstanceInitFunc) gimp_container_combo_box_init, + }; + + static const GInterfaceInfo view_iface_info = + { + (GInterfaceInitFunc) gimp_container_combo_box_view_iface_init, + NULL, /* iface_finalize */ + NULL /* iface_data */ + }; + + view_type = g_type_register_static (GTK_TYPE_COMBO_BOX, + "GimpContainerComboBox", + &view_info, 0); + + g_type_add_interface_static (view_type, GIMP_TYPE_CONTAINER_VIEW, + &view_iface_info); + } + + return view_type; +} + +static void +gimp_container_combo_box_class_init (GimpContainerComboBoxClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkComboBoxClass *combo_box_class = GTK_COMBO_BOX_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + + object_class->set_property = gimp_container_view_set_property; + object_class->get_property = gimp_container_view_get_property; + + combo_box_class->changed = gimp_container_combo_box_changed; + + g_object_class_override_property (object_class, + GIMP_CONTAINER_VIEW_PROP_CONTAINER, + "container"); + g_object_class_override_property (object_class, + GIMP_CONTAINER_VIEW_PROP_CONTEXT, + "context"); + g_object_class_override_property (object_class, + GIMP_CONTAINER_VIEW_PROP_REORDERABLE, + "reorderable"); +} + +static void +gimp_container_combo_box_init (GimpContainerComboBox *combo_box) +{ + GtkListStore *store; + GtkCellLayout *layout; + GtkCellRenderer *cell; + + store = gtk_list_store_new (NUM_COLUMNS, + GIMP_TYPE_PREVIEW_RENDERER, + G_TYPE_STRING); + + gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box), GTK_TREE_MODEL (store)); + + g_object_unref (store); + + layout = GTK_CELL_LAYOUT (combo_box); + + cell = gimp_cell_renderer_viewable_new (); + gtk_cell_layout_pack_start (layout, cell, FALSE); + gtk_cell_layout_set_attributes (layout, cell, + "renderer", COLUMN_RENDERER, + NULL); + + cell = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (layout, cell, TRUE); + gtk_cell_layout_set_attributes (layout, cell, + "text", COLUMN_NAME, + NULL); +} + +static void +gimp_container_combo_box_view_iface_init (GimpContainerViewInterface *view_iface) +{ + parent_view_iface = g_type_interface_peek_parent (view_iface); + + view_iface->insert_item = gimp_container_combo_box_insert_item; + view_iface->remove_item = gimp_container_combo_box_remove_item; + view_iface->reorder_item = gimp_container_combo_box_reorder_item; + view_iface->rename_item = gimp_container_combo_box_rename_item; + view_iface->select_item = gimp_container_combo_box_select_item; + view_iface->clear_items = gimp_container_combo_box_clear_items; + view_iface->set_preview_size = gimp_container_combo_box_set_preview_size; + + view_iface->insert_data_free = (GDestroyNotify) g_free; + +} + +GtkWidget * +gimp_container_combo_box_new (GimpContainer *container, + GimpContext *context, + gint preview_size, + gint preview_border_width) +{ + GtkWidget *combo_box; + GimpContainerView *view; + + g_return_val_if_fail (container == NULL || GIMP_IS_CONTAINER (container), + NULL); + g_return_val_if_fail (context == NULL || GIMP_IS_CONTEXT (context), NULL); + + combo_box = g_object_new (GIMP_TYPE_CONTAINER_COMBO_BOX, NULL); + + view = GIMP_CONTAINER_VIEW (combo_box); + + gimp_container_view_set_preview_size (view, + preview_size, preview_border_width); + + if (container) + gimp_container_view_set_container (view, container); + + if (context) + gimp_container_view_set_context (view, context); + + return combo_box; +} + +static void +gimp_container_combo_box_set (GimpContainerComboBox *combo_box, + GtkTreeIter *iter, + GimpViewable *viewable) +{ + GimpContainerView *view = GIMP_CONTAINER_VIEW (combo_box); + GtkTreeModel *model; + GimpPreviewRenderer *renderer; + gchar *name; + gint preview_size; + gint border_width; + + model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box)); + + preview_size = gimp_container_view_get_preview_size (view, &border_width); + + name = gimp_viewable_get_description (viewable, NULL); + + renderer = gimp_preview_renderer_new (G_TYPE_FROM_INSTANCE (viewable), + preview_size, border_width, + FALSE); + gimp_preview_renderer_set_viewable (renderer, viewable); + gimp_preview_renderer_remove_idle (renderer); + +#if 0 + g_signal_connect (renderer, "update", + G_CALLBACK (gimp_container_combo_box_renderer_update), + combo_box); +#endif + + gtk_list_store_set (GTK_LIST_STORE (model), iter, + COLUMN_RENDERER, renderer, + COLUMN_NAME, name, + -1); + + g_object_unref (renderer); + g_free (name); +} + +/* GimpContainerView methods */ + +static gpointer +gimp_container_combo_box_insert_item (GimpContainerView *view, + GimpViewable *viewable, + gint index) +{ + GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (view)); + GtkTreeIter *iter; + + iter = g_new0 (GtkTreeIter, 1); + + if (index == -1) + gtk_list_store_append (GTK_LIST_STORE (model), iter); + else + gtk_list_store_insert (GTK_LIST_STORE (model), iter, index); + + gimp_container_combo_box_set (GIMP_CONTAINER_COMBO_BOX (view), + iter, viewable); + + return (gpointer) iter; +} + +static void +gimp_container_combo_box_remove_item (GimpContainerView *view, + GimpViewable *viewable, + gpointer insert_data) +{ + GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (view)); + GtkTreeIter *iter = insert_data; + + if (iter) + gtk_list_store_remove (GTK_LIST_STORE (model), iter); +} + +static void +gimp_container_combo_box_reorder_item (GimpContainerView *view, + GimpViewable *viewable, + gint new_index, + gpointer insert_data) +{ + GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (view)); + GimpContainer *container = gimp_container_view_get_container (view); + GtkTreeIter *iter = insert_data; + + if (!iter) + return; + + if (new_index == -1 || new_index == container->num_children - 1) + { + gtk_list_store_move_before (GTK_LIST_STORE (model), iter, NULL); + } + else if (new_index == 0) + { + gtk_list_store_move_after (GTK_LIST_STORE (model), iter, NULL); + } + else + { + GtkTreePath *path; + gint old_index; + + path = gtk_tree_model_get_path (model, iter); + old_index = gtk_tree_path_get_indices (path)[0]; + gtk_tree_path_free (path); + + if (new_index != old_index) + { + GtkTreeIter place; + + path = gtk_tree_path_new_from_indices (new_index, -1); + gtk_tree_model_get_iter (model, &place, path); + gtk_tree_path_free (path); + + if (new_index > old_index) + gtk_list_store_move_after (GTK_LIST_STORE (model), iter, &place); + else + gtk_list_store_move_before (GTK_LIST_STORE (model), iter, &place); + } + } +} + +static void +gimp_container_combo_box_rename_item (GimpContainerView *view, + GimpViewable *viewable, + gpointer insert_data) +{ + GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (view)); + GtkTreeIter *iter = insert_data; + + if (iter) + { + gchar *name = gimp_viewable_get_description (viewable, NULL); + + gtk_list_store_set (GTK_LIST_STORE (model), iter, + COLUMN_NAME, name, + -1); + + g_free (name); + } +} + +static gboolean +gimp_container_combo_box_select_item (GimpContainerView *view, + GimpViewable *viewable, + gpointer insert_data) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (view); + GtkTreeIter *iter = insert_data; + + if (iter) + { + gtk_combo_box_set_active_iter (combo_box, iter); + } + else + { + /* FIXME */ + } + + return TRUE; +} + +static void +gimp_container_combo_box_clear_items (GimpContainerView *view) +{ + GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (view)); + + gtk_list_store_clear (GTK_LIST_STORE (model)); + +#if 0 + parent_view_iface->clear_items (view); +#endif +} + +static void +gimp_container_combo_box_set_preview_size (GimpContainerView *view) +{ + GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (view)); + GtkTreeIter iter; + gboolean iter_valid; + gint preview_size; + gint border_width; + + preview_size = gimp_container_view_get_preview_size (view, &border_width); + + for (iter_valid = gtk_tree_model_get_iter_first (model, &iter); + iter_valid; + iter_valid = gtk_tree_model_iter_next (model, &iter)) + { + GimpPreviewRenderer *renderer; + + gtk_tree_model_get (model, &iter, + COLUMN_RENDERER, &renderer, + -1); + + gimp_preview_renderer_set_size (renderer, preview_size, border_width); + g_object_unref (renderer); + } +} + +static void +gimp_container_combo_box_changed (GtkComboBox *combo_box) +{ + GtkTreeIter iter; + + if (parent_class->changed) + parent_class->changed (combo_box); + + if (gtk_combo_box_get_active_iter (combo_box, &iter)) + { + GimpPreviewRenderer *renderer; + + gtk_tree_model_get (gtk_combo_box_get_model (combo_box), &iter, + COLUMN_RENDERER, &renderer, + -1); + + gimp_container_view_item_selected (GIMP_CONTAINER_VIEW (combo_box), + renderer->viewable); + g_object_unref (renderer); + } +} diff --git a/app/widgets/gimpcontainercombobox.h b/app/widgets/gimpcontainercombobox.h new file mode 100644 index 0000000000..58c945185e --- /dev/null +++ b/app/widgets/gimpcontainercombobox.h @@ -0,0 +1,58 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * gimpcontainercombobox.h + * Copyright (C) 2004 Sven Neumann + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __GIMP_CONTAINER_COMBO_BOX_H__ +#define __GIMP_CONTAINER_COMBO_BOX_H__ + + +#include + + +#define GIMP_TYPE_CONTAINER_COMBO_BOX (gimp_container_combo_box_get_type ()) +#define GIMP_CONTAINER_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CONTAINER_COMBO_BOX, GimpContainerComboBox)) +#define GIMP_CONTAINER_COMBO_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CONTAINER_COMBO_BOX, GimpContainerComboBoxClass)) +#define GIMP_IS_CONTAINER_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CONTAINER_COMBO_BOX)) +#define GIMP_IS_CONTAINER_COMBO_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CONTAINER_COMBO_BOX)) +#define GIMP_CONTAINER_COMBO_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CONTAINER_COMBO_BOX, GimpContainerComboBoxClass)) + + +typedef struct _GimpContainerComboBoxClass GimpContainerComboBoxClass; + +struct _GimpContainerComboBox +{ + GtkComboBox parent_instance; +}; + +struct _GimpContainerComboBoxClass +{ + GtkComboBoxClass parent_class; +}; + + +GType gimp_container_combo_box_get_type (void) G_GNUC_CONST; + +GtkWidget * gimp_container_combo_box_new (GimpContainer *container, + GimpContext *context, + gint preview_size, + gint preview_border_width); + + +#endif /* __GIMP_CONTAINER_COMBO_BOX_H__ */ diff --git a/app/widgets/gimpcontainerview.c b/app/widgets/gimpcontainerview.c index a474a31f60..3a5abd7281 100644 --- a/app/widgets/gimpcontainerview.c +++ b/app/widgets/gimpcontainerview.c @@ -763,6 +763,56 @@ gimp_container_view_item_context (GimpContainerView *view, gimp_container_view_context_item (view, viewable); } +void +gimp_container_view_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + GimpContainerView *view = GIMP_CONTAINER_VIEW (object); + + switch (property_id) + { + case GIMP_CONTAINER_VIEW_PROP_CONTAINER: + gimp_container_view_set_container (view, g_value_get_object (value)); + break; + case GIMP_CONTAINER_VIEW_PROP_CONTEXT: + gimp_container_view_set_context (view, g_value_get_object (value)); + break; + case GIMP_CONTAINER_VIEW_PROP_REORDERABLE: + gimp_container_view_set_reorderable (view, g_value_get_boolean (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +void +gimp_container_view_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + GimpContainerView *view = GIMP_CONTAINER_VIEW (object); + + switch (property_id) + { + case GIMP_CONTAINER_VIEW_PROP_CONTAINER: + g_value_set_object (value, gimp_container_view_get_container (view)); + break; + case GIMP_CONTAINER_VIEW_PROP_CONTEXT: + g_value_set_object (value, gimp_container_view_get_context (view)); + break; + case GIMP_CONTAINER_VIEW_PROP_REORDERABLE: + g_value_set_boolean (value, gimp_container_view_get_reorderable (view)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + static void gimp_container_view_clear_items (GimpContainerView *view) { diff --git a/app/widgets/gimpcontainerview.h b/app/widgets/gimpcontainerview.h index 3b2e2e70f0..504030c60b 100644 --- a/app/widgets/gimpcontainerview.h +++ b/app/widgets/gimpcontainerview.h @@ -26,6 +26,15 @@ #include "gimpeditor.h" +enum +{ + GIMP_CONTAINER_VIEW_PROP_0, + GIMP_CONTAINER_VIEW_PROP_CONTAINER, + GIMP_CONTAINER_VIEW_PROP_CONTEXT, + GIMP_CONTAINER_VIEW_PROP_REORDERABLE +}; + + #define GIMP_TYPE_CONTAINER_VIEW (gimp_container_view_interface_get_type ()) #define GIMP_CONTAINER_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CONTAINER_VIEW, GimpContainerView)) #define GIMP_IS_CONTAINER_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CONTAINER_VIEW)) @@ -123,5 +132,16 @@ void gimp_container_view_item_activated (GimpContainerView *view, void gimp_container_view_item_context (GimpContainerView *view, GimpViewable *item); +/* convenience functions */ + +void gimp_container_view_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); +void gimp_container_view_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); + #endif /* __GIMP_CONTAINER_VIEW_H__ */ diff --git a/app/widgets/widgets-types.h b/app/widgets/widgets-types.h index bf1b8055d2..b5511f61eb 100644 --- a/app/widgets/widgets-types.h +++ b/app/widgets/widgets-types.h @@ -90,6 +90,7 @@ typedef struct _GimpUndoEditor GimpUndoEditor; typedef struct _GimpContainerView GimpContainerView; /* dummy typedef */ typedef struct _GimpContainerBox GimpContainerBox; +typedef struct _GimpContainerComboBox GimpContainerComboBox; typedef struct _GimpContainerGridView GimpContainerGridView; typedef struct _GimpContainerTreeView GimpContainerTreeView; diff --git a/etc/templaterc b/etc/templaterc index 7a688d977f..122a913d39 100644 --- a/etc/templaterc +++ b/etc/templaterc @@ -5,7 +5,7 @@ (GimpTemplate "640x480" (width 640) (height 480) - (unit inches) + (unit pixels) (xresolution 72.000000) (yresolution 72.000000) (resolution-unit inches) @@ -14,7 +14,7 @@ (GimpTemplate "800x600" (width 800) (height 600) - (unit inches) + (unit pixels) (xresolution 72.000000) (yresolution 72.000000) (resolution-unit inches) @@ -23,7 +23,7 @@ (GimpTemplate "1024x768" (width 1024) (height 768) - (unit inches) + (unit pixels) (xresolution 72.000000) (yresolution 72.000000) (resolution-unit inches) @@ -32,7 +32,7 @@ (GimpTemplate "1600x1200" (width 1600) (height 1200) - (unit inches) + (unit pixels) (xresolution 72.000000) (yresolution 72.000000) (resolution-unit inches) @@ -153,7 +153,7 @@ (stock-id "gimp-web") (width 468) (height 60) - (unit inches) + (unit pixels) (xresolution 72.000000) (yresolution 72.000000) (resolution-unit inches) @@ -163,7 +163,7 @@ (stock-id "gimp-web") (width 728) (height 90) - (unit inches) + (unit pixels) (xresolution 72.000000) (yresolution 72.000000) (resolution-unit inches) @@ -173,7 +173,7 @@ (stock-id "gimp-video") (width 720) (height 576) - (unit millimeters) + (unit pixels) (xresolution 72.000000) (yresolution 72.000000) (resolution-unit inches) @@ -183,7 +183,7 @@ (stock-id "gimp-video") (width 720) (height 486) - (unit millimeters) + (unit pixels) (xresolution 72.000000) (yresolution 72.000000) (resolution-unit inches)