summaryrefslogtreecommitdiff
path: root/cut-n-paste-code
diff options
context:
space:
mode:
authorDarin Adler <darin@src.gnome.org>2002-01-21 22:49:40 +0000
committerDarin Adler <darin@src.gnome.org>2002-01-21 22:49:40 +0000
commitaaf205789a7294e70db3209a31438296cba415a8 (patch)
tree7370222068f28f0a2ed91c690527daed1f812de7 /cut-n-paste-code
parentc66ad8c74e2f845d0f02f22bcedc7126913a418b (diff)
downloadnautilus-aaf205789a7294e70db3209a31438296cba415a8.tar.gz
Get rid of code that passes around the "optimize for AA" flag.
* components/tree/nautilus-tree-view.c: (nautilus_tree_view_insert_model_node), (nautilus_tree_view_update_model_node): * libnautilus-private/nautilus-bookmark.c: (nautilus_bookmark_get_pixbuf): * libnautilus-private/nautilus-find-icon-image.c: (read_details), (get_themed_icon_file_path), (theme_has_icon), (nautilus_get_icon_file_name): * libnautilus-private/nautilus-find-icon-image.h: * libnautilus-private/nautilus-icon-container.c: (nautilus_icon_container_update_icon): * libnautilus-private/nautilus-icon-factory-private.h: * libnautilus-private/nautilus-icon-factory.c: (load_thumbnail_frame), (nautilus_icon_factory_init), (nautilus_icon_factory_destroy), (icon_theme_changed_callback), (should_display_image_file_as_itself), (nautilus_icon_factory_get_icon_for_file), (load_icon_from_path), (load_named_icon), (load_specific_icon), (load_icon_for_scaling), (load_icon_scale_if_necessary), (get_icon_from_cache), (nautilus_icon_factory_get_pixbuf_for_icon), (cache_key_hash), (cache_key_equal), (nautilus_icon_factory_get_pixbuf_for_file), (nautilus_icon_factory_get_pixbuf_from_name), (nautilus_icon_factory_get_thumbnail_frame): * libnautilus-private/nautilus-icon-factory.h: * libnautilus-private/nautilus-thumbnails.c: (nautilus_thumbnail_load_framed_image): * libnautilus-private/nautilus-thumbnails.h: * src/file-manager/fm-directory-view.c: (add_script_to_script_menus), (add_submenu_to_script_menus): * src/file-manager/fm-list-model.c: (fm_list_model_get_value): * src/file-manager/fm-properties-window.c: (get_pixbuf_for_properties_window): * src/nautilus-sidebar-title.c: (update_icon), (update_emblems): Get rid of code that passes around the "optimize for AA" flag. * cut-n-paste-code/widgets/gimphwrapbox/gtkhwrapbox.c: * cut-n-paste-code/widgets/gimphwrapbox/gtkhwrapbox.h: * cut-n-paste-code/widgets/gimphwrapbox/gtkwrapbox.c: * cut-n-paste-code/widgets/gimphwrapbox/gtkwrapbox.h: Roll in the latest version from gimp source tree. * icons: Overwrite all the non-aa versions with the aa versions. Remove all the aa versions.
Diffstat (limited to 'cut-n-paste-code')
-rw-r--r--cut-n-paste-code/widgets/gimphwrapbox/gtkhwrapbox.c112
-rw-r--r--cut-n-paste-code/widgets/gimphwrapbox/gtkhwrapbox.h24
-rw-r--r--cut-n-paste-code/widgets/gimphwrapbox/gtkwrapbox.c295
-rw-r--r--cut-n-paste-code/widgets/gimphwrapbox/gtkwrapbox.h46
4 files changed, 240 insertions, 237 deletions
diff --git a/cut-n-paste-code/widgets/gimphwrapbox/gtkhwrapbox.c b/cut-n-paste-code/widgets/gimphwrapbox/gtkhwrapbox.c
index e6de3af41..8c78bafc6 100644
--- a/cut-n-paste-code/widgets/gimphwrapbox/gtkhwrapbox.c
+++ b/cut-n-paste-code/widgets/gimphwrapbox/gtkhwrapbox.c
@@ -19,9 +19,12 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+
#include "gtkhwrapbox.h"
-#include <gtk/gtksignal.h>
-#include <math.h>
/* --- prototypes --- */
@@ -94,7 +97,6 @@ gtk_hwrap_box_init (GtkHWrapBox *hwbox)
{
hwbox->max_child_width = 0;
hwbox->max_child_height = 0;
- hwbox->request_stored_height = FALSE;
}
GtkWidget*
@@ -125,55 +127,6 @@ get_child_requisition (GtkWrapBox *wbox,
gtk_widget_get_child_requisition (child, child_requisition);
}
-#if 0
-static void
-_gtk_hwrap_box_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- GtkHWrapBox *this = GTK_HWRAP_BOX (widget);
- GtkWrapBox *wbox = GTK_WRAP_BOX (widget);
- GtkWrapBoxChild *child;
- guint area = 0;
-
- g_return_if_fail (requisition != NULL);
-
- /*<h2v-off>*/
- requisition->width = 0;
- requisition->height = 0;
- this->max_child_width = 0;
- this->max_child_height = 0;
-
- for (child = wbox->children; child; child = child->next)
- if (GTK_WIDGET_VISIBLE (child->widget))
- {
- GtkRequisition child_requisition;
-
- gtk_widget_size_request (child->widget, &child_requisition);
-
- area += child_requisition.width * child_requisition.height;
- this->max_child_width = MAX (this->max_child_width, child_requisition.width);
- this->max_child_height = MAX (this->max_child_height, child_requisition.height);
- }
- if (wbox->homogeneous)
- area = this->max_child_width * this->max_child_height * wbox->n_children;
-
- if (area)
- {
- requisition->width = sqrt (area * wbox->aspect_ratio);
- requisition->height = area / requisition->width;
- }
- else
- {
- requisition->width = 0;
- requisition->height = 0;
- }
-
- requisition->width += GTK_CONTAINER (wbox)->border_width * 2;
- requisition->height += GTK_CONTAINER (wbox)->border_width * 2;
- /*<h2v-on>*/
-}
-#endif
-
static gfloat
get_layout_size (GtkHWrapBox *this,
guint max_width,
@@ -226,7 +179,6 @@ get_layout_size (GtkHWrapBox *this,
return MAX (total_height, 1);
}
-
static void
gtk_hwrap_box_size_request (GtkWidget *widget,
GtkRequisition *requisition)
@@ -236,7 +188,7 @@ gtk_hwrap_box_size_request (GtkWidget *widget,
GtkWrapBoxChild *child;
gfloat ratio_dist, layout_width = 0;
guint row_inc = 0;
-
+
g_return_if_fail (requisition != NULL);
requisition->width = 0;
@@ -244,7 +196,6 @@ gtk_hwrap_box_size_request (GtkWidget *widget,
this->max_child_width = 0;
this->max_child_height = 0;
-
/* size_request all children */
for (child = wbox->children; child; child = child->next)
if (GTK_WIDGET_VISIBLE (child->widget))
@@ -253,8 +204,8 @@ gtk_hwrap_box_size_request (GtkWidget *widget,
gtk_widget_size_request (child->widget, &child_requisition);
- this->max_child_width = MAX (this->max_child_width, child_requisition.width);
- this->max_child_height = MAX (this->max_child_height, child_requisition.height);
+ this->max_child_width = MAX (this->max_child_width, (guint) child_requisition.width);
+ this->max_child_height = MAX (this->max_child_height, (guint) child_requisition.height);
}
/* figure all possible layouts */
@@ -264,27 +215,32 @@ gtk_hwrap_box_size_request (GtkWidget *widget,
{
gfloat layout_height;
gfloat ratio, dist;
- GtkRequisition *saved_requisition;
layout_width += row_inc;
layout_height = get_layout_size (this, layout_width, &row_inc);
ratio = layout_width / layout_height; /*<h2v-skip>*/
dist = MAX (ratio, wbox->aspect_ratio) - MIN (ratio, wbox->aspect_ratio);
- if (dist < ratio_dist ||
- (this->request_stored_height &&
- layout_height == this->request_this_height_next_time))
+ if (dist < ratio_dist)
{
ratio_dist = dist;
requisition->width = layout_width;
requisition->height = layout_height;
}
- saved_requisition = g_new0 (GtkRequisition, 1);
- saved_requisition->width = layout_width;
- saved_requisition->height = layout_height;
+
+ /* g_print ("ratio for width %d height %d = %f\n",
+ (gint) layout_width,
+ (gint) layout_height,
+ ratio);
+ */
}
while (row_inc);
+
requisition->width += GTK_CONTAINER (wbox)->border_width * 2; /*<h2v-skip>*/
requisition->height += GTK_CONTAINER (wbox)->border_width * 2; /*<h2v-skip>*/
+ /* g_print ("choosen: width %d, height %d\n",
+ requisition->width,
+ requisition->height);
+ */
}
static GSList*
@@ -326,7 +282,7 @@ reverse_list_row_children (GtkWrapBox *wbox,
{
get_child_requisition (wbox, child->widget, &child_requisition);
if (width + wbox->hspacing + child_requisition.width > row_width ||
- child->forced_break)
+ child->wrapped)
break;
width += wbox->hspacing + child_requisition.width;
*max_child_size = MAX (*max_child_size, (guint) child_requisition.height);
@@ -350,7 +306,8 @@ layout_row (GtkWrapBox *wbox,
gboolean vexpand)
{
GSList *slist;
- guint n_children = 0, n_expand_children = 0, have_expand_children = 0, total_width = 0;
+ guint n_children = 0, n_expand_children = 0, have_expand_children = 0;
+ gint total_width = 0;
gfloat x, width, extra;
GtkAllocation child_allocation;
@@ -493,7 +450,6 @@ struct _Line
Line *next;
};
-
static void
layout_rows (GtkWrapBox *wbox,
GtkAllocation *area)
@@ -502,11 +458,10 @@ layout_rows (GtkWrapBox *wbox,
guint min_height;
gboolean vexpand;
GSList *slist;
+ Line *line_list = NULL;
+ guint total_height = 0, n_expand_lines = 0, n_lines = 0;
gfloat shrink_height;
guint children_per_line;
- Line *line_list = NULL;
- int total_height = 0;
- guint n_expand_lines = 0, n_lines = 0;
next_child = wbox->children;
slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox,
@@ -538,18 +493,11 @@ layout_rows (GtkWrapBox *wbox,
&vexpand);
slist = g_slist_reverse (slist);
}
- GTK_HWRAP_BOX (wbox)->request_this_height_next_time = total_height;
- if (!(GTK_HWRAP_BOX (wbox)->request_stored_height )) {
- g_signal_emit_by_name (wbox, "need_reallocation", NULL);
- GTK_HWRAP_BOX (wbox)->request_stored_height = TRUE;
- }
- if (total_height > area->height) {
- shrink_height = total_height - area->height;
- g_signal_emit_by_name (wbox, "need_reallocation", NULL);
- }
+
+ if (total_height > (guint) area->height)
+ shrink_height = total_height - area->height;
else
shrink_height = 0;
-
if (1) /* reverse lines and shrink */
{
@@ -645,7 +593,7 @@ gtk_hwrap_box_size_allocate (GtkWidget *widget,
{
GtkWrapBox *wbox = GTK_WRAP_BOX (widget);
GtkAllocation area;
- guint border = GTK_CONTAINER (wbox)->border_width; /*<h2v-skip>*/
+ gint border = GTK_CONTAINER (wbox)->border_width; /*<h2v-skip>*/
widget->allocation = *allocation;
area.x = allocation->x + border;
@@ -659,6 +607,6 @@ gtk_hwrap_box_size_allocate (GtkWidget *widget,
allocation->height);
*/
/*<h2v-on>*/
-
+
layout_rows (wbox, &area);
}
diff --git a/cut-n-paste-code/widgets/gimphwrapbox/gtkhwrapbox.h b/cut-n-paste-code/widgets/gimphwrapbox/gtkhwrapbox.h
index b7b43ec71..cb894836d 100644
--- a/cut-n-paste-code/widgets/gimphwrapbox/gtkhwrapbox.h
+++ b/cut-n-paste-code/widgets/gimphwrapbox/gtkhwrapbox.h
@@ -19,16 +19,14 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
+
#ifndef __GTK_HWRAP_BOX_H__
#define __GTK_HWRAP_BOX_H__
#include "gtkwrapbox.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+G_BEGIN_DECLS
/* --- type macros --- */
@@ -37,7 +35,7 @@ extern "C" {
#define GTK_HWRAP_BOX_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_HWRAP_BOX, GtkHWrapBoxClass))
#define GTK_IS_HWRAP_BOX(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_HWRAP_BOX))
#define GTK_IS_HWRAP_BOX_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_HWRAP_BOX))
-#define GTK_HWRAP_BOX_GET_CLASS(obj) (GTK_HWRAP_BOX_CLASS (((GtkObject*) (obj))->klass))
+#define GTK_HWRAP_BOX_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_HWRAP_BOX, GtkHWrapBoxClass))
/* --- typedefs --- */
@@ -51,12 +49,9 @@ struct _GtkHWrapBox
GtkWrapBox parent_widget;
/*<h2v-off>*/
- guint16 max_child_width;
- guint16 max_child_height;
+ guint max_child_width;
+ guint max_child_height;
/*<h2v-on>*/
-
- gboolean request_stored_height;
- guint16 request_this_height_next_time;
};
struct _GtkHWrapBoxClass
@@ -66,13 +61,10 @@ struct _GtkHWrapBoxClass
/* --- prototypes --- */
-GtkType gtk_hwrap_box_get_type (void);
-GtkWidget* gtk_hwrap_box_new (gboolean homogeneous);
-
+GtkType gtk_hwrap_box_get_type (void) G_GNUC_CONST;
+GtkWidget * gtk_hwrap_box_new (gboolean homogeneous);
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+G_END_DECLS
#endif /* __GTK_HWRAP_BOX_H__ */
diff --git a/cut-n-paste-code/widgets/gimphwrapbox/gtkwrapbox.c b/cut-n-paste-code/widgets/gimphwrapbox/gtkwrapbox.c
index 220d8f448..49daa3405 100644
--- a/cut-n-paste-code/widgets/gimphwrapbox/gtkwrapbox.c
+++ b/cut-n-paste-code/widgets/gimphwrapbox/gtkwrapbox.c
@@ -19,10 +19,10 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
-#include <math.h>
-#include <gtk/gtksignal.h>
-#include "gtkwrapbox.h"
+#include "config.h"
+
+#include "gtkwrapbox.h"
/* --- arguments --- */
@@ -38,21 +38,15 @@ enum {
ARG_CHILD_LIMIT
};
enum {
- CHILD_ARG_0,
- CHILD_ARG_POSITION,
- CHILD_ARG_HEXPAND,
- CHILD_ARG_HFILL,
- CHILD_ARG_VEXPAND,
- CHILD_ARG_VFILL,
- CHILD_ARG_FORCED_BREAK
-};
-
-enum {
- NEED_REALLOCATION,
- LAST_SIGNAL
+ CHILD_PROP_0,
+ CHILD_PROP_POSITION,
+ CHILD_PROP_HEXPAND,
+ CHILD_PROP_HFILL,
+ CHILD_PROP_VEXPAND,
+ CHILD_PROP_VFILL,
+ CHILD_PROP_WRAPPED
};
-static guint signals[LAST_SIGNAL];
/* --- prototypes --- */
static void gtk_wrap_box_class_init (GtkWrapBoxClass *klass);
@@ -63,10 +57,18 @@ static void gtk_wrap_box_get_arg (GtkObject *object,
static void gtk_wrap_box_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
+static void gtk_wrap_box_set_child_property (GtkContainer *container,
+ GtkWidget *child,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gtk_wrap_box_get_child_property (GtkContainer *container,
+ GtkWidget *child,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
static void gtk_wrap_box_map (GtkWidget *widget);
static void gtk_wrap_box_unmap (GtkWidget *widget);
-static gint gtk_wrap_box_expose (GtkWidget *widget,
- GdkEventExpose *event);
static void gtk_wrap_box_add (GtkContainer *container,
GtkWidget *widget);
static void gtk_wrap_box_remove (GtkContainer *container,
@@ -119,48 +121,64 @@ gtk_wrap_box_class_init (GtkWrapBoxClass *class)
widget_class = GTK_WIDGET_CLASS (class);
container_class = GTK_CONTAINER_CLASS (class);
- parent_class = gtk_type_class (GTK_TYPE_CONTAINER);
+ parent_class = g_type_class_peek_parent (class);
object_class->set_arg = gtk_wrap_box_set_arg;
object_class->get_arg = gtk_wrap_box_get_arg;
widget_class->map = gtk_wrap_box_map;
widget_class->unmap = gtk_wrap_box_unmap;
- widget_class->expose_event = gtk_wrap_box_expose;
container_class->add = gtk_wrap_box_add;
container_class->remove = gtk_wrap_box_remove;
container_class->forall = gtk_wrap_box_forall;
container_class->child_type = gtk_wrap_box_child_type;
+ container_class->set_child_property = gtk_wrap_box_set_child_property;
+ container_class->get_child_property = gtk_wrap_box_get_child_property;
class->rlist_line_children = NULL;
gtk_object_add_arg_type ("GtkWrapBox::homogeneous",
- G_TYPE_BOOLEAN, GTK_ARG_READWRITE, ARG_HOMOGENEOUS);
+ GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_HOMOGENEOUS);
gtk_object_add_arg_type ("GtkWrapBox::justify",
GTK_TYPE_JUSTIFICATION, GTK_ARG_READWRITE, ARG_JUSTIFY);
gtk_object_add_arg_type ("GtkWrapBox::hspacing",
- G_TYPE_UINT, GTK_ARG_READWRITE, ARG_HSPACING);
+ GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_HSPACING);
gtk_object_add_arg_type ("GtkWrapBox::vspacing",
- G_TYPE_UINT, GTK_ARG_READWRITE, ARG_VSPACING);
+ GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_VSPACING);
gtk_object_add_arg_type ("GtkWrapBox::line_justify",
GTK_TYPE_JUSTIFICATION, GTK_ARG_READWRITE, ARG_LINE_JUSTIFY);
gtk_object_add_arg_type ("GtkWrapBox::aspect_ratio",
- G_TYPE_FLOAT, GTK_ARG_READWRITE, ARG_ASPECT_RATIO);
+ GTK_TYPE_FLOAT, GTK_ARG_READWRITE, ARG_ASPECT_RATIO);
gtk_object_add_arg_type ("GtkWrapBox::current_ratio",
- G_TYPE_FLOAT, GTK_ARG_READABLE, ARG_CURRENT_RATIO);
+ GTK_TYPE_FLOAT, GTK_ARG_READABLE, ARG_CURRENT_RATIO);
gtk_object_add_arg_type ("GtkWrapBox::max_children_per_line",
- G_TYPE_UINT, GTK_ARG_READWRITE, ARG_CHILD_LIMIT);
-
- signals[NEED_REALLOCATION] = g_signal_new
- ("need_reallocation",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GtkWrapBoxClass,
- need_reallocation),
- NULL, NULL,
- gtk_marshal_NONE__NONE,
- G_TYPE_NONE, 0);
+ GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_CHILD_LIMIT);
+
+ gtk_container_class_install_child_property (container_class, CHILD_PROP_POSITION,
+ g_param_spec_int ("position", NULL, NULL,
+ -1, G_MAXINT, 0,
+ G_PARAM_READWRITE));
+ gtk_container_class_install_child_property (container_class, CHILD_PROP_HEXPAND,
+ g_param_spec_boolean ("hexpand", NULL, NULL,
+ FALSE,
+ G_PARAM_READWRITE));
+ gtk_container_class_install_child_property (container_class, CHILD_PROP_HFILL,
+ g_param_spec_boolean ("hfill", NULL, NULL,
+ FALSE,
+ G_PARAM_READWRITE));
+ gtk_container_class_install_child_property (container_class, CHILD_PROP_VEXPAND,
+ g_param_spec_boolean ("vexpand", NULL, NULL,
+ FALSE,
+ G_PARAM_READWRITE));
+ gtk_container_class_install_child_property (container_class, CHILD_PROP_VFILL,
+ g_param_spec_boolean ("vfill", NULL, NULL,
+ FALSE,
+ G_PARAM_READWRITE));
+ gtk_container_class_install_child_property (container_class, CHILD_PROP_VFILL,
+ g_param_spec_boolean ("wrapped", NULL, NULL,
+ FALSE,
+ G_PARAM_READWRITE));
}
static void
@@ -252,7 +270,109 @@ gtk_wrap_box_get_arg (GtkObject *object,
GTK_VALUE_UINT (*arg) = wbox->child_limit;
break;
default:
- arg->type = G_TYPE_INVALID;
+ arg->type = GTK_TYPE_INVALID;
+ break;
+ }
+}
+
+static void
+gtk_wrap_box_set_child_property (GtkContainer *container,
+ GtkWidget *child,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GtkWrapBox *wbox = GTK_WRAP_BOX (container);
+ gboolean hexpand = FALSE, hfill = FALSE, vexpand = FALSE, vfill = FALSE, wrapped = FALSE;
+
+ if (property_id != CHILD_PROP_POSITION)
+ gtk_wrap_box_query_child_packing (wbox, child, &hexpand, &hfill, &vexpand, &vfill, &wrapped);
+
+ switch (property_id)
+ {
+ case CHILD_PROP_POSITION:
+ gtk_wrap_box_reorder_child (wbox, child, g_value_get_int (value));
+ break;
+ case CHILD_PROP_HEXPAND:
+ gtk_wrap_box_set_child_packing (wbox, child,
+ g_value_get_boolean (value), hfill,
+ vexpand, vfill,
+ wrapped);
+ break;
+ case CHILD_PROP_HFILL:
+ gtk_wrap_box_set_child_packing (wbox, child,
+ hexpand, g_value_get_boolean (value),
+ vexpand, vfill,
+ wrapped);
+ break;
+ case CHILD_PROP_VEXPAND:
+ gtk_wrap_box_set_child_packing (wbox, child,
+ hexpand, hfill,
+ g_value_get_boolean (value), vfill,
+ wrapped);
+ break;
+ case CHILD_PROP_VFILL:
+ gtk_wrap_box_set_child_packing (wbox, child,
+ hexpand, hfill,
+ vexpand, g_value_get_boolean (value),
+ wrapped);
+ break;
+ case CHILD_PROP_WRAPPED:
+ gtk_wrap_box_set_child_packing (wbox, child,
+ hexpand, hfill,
+ vexpand, vfill,
+ g_value_get_boolean (value));
+ break;
+ default:
+ GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gtk_wrap_box_get_child_property (GtkContainer *container,
+ GtkWidget *child,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GtkWrapBox *wbox = GTK_WRAP_BOX (container);
+ gboolean hexpand = FALSE, hfill = FALSE, vexpand = FALSE, vfill = FALSE, wrapped = FALSE;
+
+ if (property_id != CHILD_PROP_POSITION)
+ gtk_wrap_box_query_child_packing (wbox, child, &hexpand, &hfill, &vexpand, &vfill, &wrapped);
+
+ switch (property_id)
+ {
+ GtkWrapBoxChild *child_info;
+ int i;
+ case CHILD_PROP_POSITION:
+ i = 0;
+ for (child_info = wbox->children; child_info; child_info = child_info->next)
+ {
+ if (child_info->widget == child)
+ break;
+ i += 1;
+ }
+ g_value_set_int (value, child_info ? i : -1);
+ break;
+ case CHILD_PROP_HEXPAND:
+ g_value_set_boolean (value, hexpand);
+ break;
+ case CHILD_PROP_HFILL:
+ g_value_set_boolean (value, hfill);
+ break;
+ case CHILD_PROP_VEXPAND:
+ g_value_set_boolean (value, vexpand);
+ break;
+ case CHILD_PROP_VFILL:
+ g_value_set_boolean (value, vfill);
+ break;
+ case CHILD_PROP_WRAPPED:
+ g_value_set_boolean (value, wrapped);
+ break;
+ default:
+ GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
break;
}
}
@@ -354,6 +474,22 @@ gtk_wrap_box_pack (GtkWrapBox *wbox,
gboolean vexpand,
gboolean vfill)
{
+ g_return_if_fail (GTK_IS_WRAP_BOX (wbox));
+ g_return_if_fail (GTK_IS_WIDGET (child));
+ g_return_if_fail (child->parent == NULL);
+
+ gtk_wrap_box_pack_wrapped (wbox, child, hexpand, hfill, vexpand, vfill, FALSE);
+}
+
+void
+gtk_wrap_box_pack_wrapped (GtkWrapBox *wbox,
+ GtkWidget *child,
+ gboolean hexpand,
+ gboolean hfill,
+ gboolean vexpand,
+ gboolean vfill,
+ gboolean wrapped)
+{
GtkWrapBoxChild *child_info;
g_return_if_fail (GTK_IS_WRAP_BOX (wbox));
@@ -366,7 +502,7 @@ gtk_wrap_box_pack (GtkWrapBox *wbox,
child_info->hfill = hfill ? TRUE : FALSE;
child_info->vexpand = vexpand ? TRUE : FALSE;
child_info->vfill = vfill ? TRUE : FALSE;
- child_info->forced_break = FALSE;
+ child_info->wrapped = wrapped ? TRUE : FALSE;
child_info->next = NULL;
if (wbox->children)
{
@@ -451,7 +587,8 @@ gtk_wrap_box_query_child_packing (GtkWrapBox *wbox,
gboolean *hexpand,
gboolean *hfill,
gboolean *vexpand,
- gboolean *vfill)
+ gboolean *vfill,
+ gboolean *wrapped)
{
GtkWrapBoxChild *child_info;
@@ -472,27 +609,8 @@ gtk_wrap_box_query_child_packing (GtkWrapBox *wbox,
*vexpand = child_info->vexpand;
if (vfill)
*vfill = child_info->vfill;
- }
-}
-
-void
-gtk_wrap_box_query_child_forced_break (GtkWrapBox *wbox,
- GtkWidget *child,
- gboolean *forced_break)
-{
- GtkWrapBoxChild *child_info;
-
- g_return_if_fail (GTK_IS_WRAP_BOX (wbox));
- g_return_if_fail (GTK_IS_WIDGET (child));
-
- for (child_info = wbox->children; child_info; child_info = child_info->next)
- if (child_info->widget == child)
- break;
-
- if (child_info)
- {
- if (forced_break)
- *forced_break = child_info->forced_break;
+ if (wrapped)
+ *wrapped = child_info->wrapped;
}
}
@@ -502,7 +620,8 @@ gtk_wrap_box_set_child_packing (GtkWrapBox *wbox,
gboolean hexpand,
gboolean hfill,
gboolean vexpand,
- gboolean vfill)
+ gboolean vfill,
+ gboolean wrapped)
{
GtkWrapBoxChild *child_info;
@@ -513,45 +632,22 @@ gtk_wrap_box_set_child_packing (GtkWrapBox *wbox,
hfill = hfill != FALSE;
vexpand = vexpand != FALSE;
vfill = vfill != FALSE;
-
+ wrapped = wrapped != FALSE;
+
for (child_info = wbox->children; child_info; child_info = child_info->next)
if (child_info->widget == child)
break;
if (child_info &&
(child_info->hexpand != hexpand || child_info->vexpand != vexpand ||
- child_info->hfill != hfill || child_info->vfill != vfill))
+ child_info->hfill != hfill || child_info->vfill != vfill ||
+ child_info->wrapped != wrapped))
{
child_info->hexpand = hexpand;
child_info->hfill = hfill;
child_info->vexpand = vexpand;
child_info->vfill = vfill;
-
- if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_VISIBLE (wbox))
- gtk_widget_queue_resize (child);
- }
-}
-
-void
-gtk_wrap_box_set_child_forced_break (GtkWrapBox *wbox,
- GtkWidget *child,
- gboolean forced_break)
-{
- GtkWrapBoxChild *child_info;
-
- g_return_if_fail (GTK_IS_WRAP_BOX (wbox));
- g_return_if_fail (GTK_IS_WIDGET (child));
-
- forced_break = forced_break != FALSE;
-
- for (child_info = wbox->children; child_info; child_info = child_info->next)
- if (child_info->widget == child)
- break;
-
- if (child_info &&
- (child_info->forced_break != forced_break))
- {
- child_info->forced_break = forced_break;
+ child_info->wrapped = wrapped;
if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_VISIBLE (wbox))
gtk_widget_queue_resize (child);
@@ -634,27 +730,6 @@ gtk_wrap_box_unmap (GtkWidget *widget)
gtk_widget_unmap (child->widget);
}
-static gint
-gtk_wrap_box_expose (GtkWidget *widget,
- GdkEventExpose *event)
-{
- GtkWrapBox *wbox = GTK_WRAP_BOX (widget);
- GtkWrapBoxChild *child;
- GdkEvent child_event;
-
- g_return_val_if_fail (event != NULL, FALSE);
-
- child_event.expose = *event;
- if (GTK_WIDGET_DRAWABLE (widget))
- for (child = wbox->children; child; child = child->next)
- if (GTK_WIDGET_DRAWABLE (child->widget) &&
- GTK_WIDGET_NO_WINDOW (child->widget) &&
- gtk_widget_intersect (child->widget, &event->area, &child_event.expose.area))
- gtk_widget_event (child->widget, &child_event);
-
- return TRUE;
-}
-
static void
gtk_wrap_box_add (GtkContainer *container,
GtkWidget *widget)
diff --git a/cut-n-paste-code/widgets/gimphwrapbox/gtkwrapbox.h b/cut-n-paste-code/widgets/gimphwrapbox/gtkwrapbox.h
index 04d71fc68..de204449f 100644
--- a/cut-n-paste-code/widgets/gimphwrapbox/gtkwrapbox.h
+++ b/cut-n-paste-code/widgets/gimphwrapbox/gtkwrapbox.h
@@ -19,16 +19,14 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
+
#ifndef __GTK_WRAP_BOX_H__
#define __GTK_WRAP_BOX_H__
#include <gtk/gtkcontainer.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+G_BEGIN_DECLS
/* --- type macros --- */
@@ -37,7 +35,7 @@ extern "C" {
#define GTK_WRAP_BOX_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_WRAP_BOX, GtkWrapBoxClass))
#define GTK_IS_WRAP_BOX(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_WRAP_BOX))
#define GTK_IS_WRAP_BOX_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_WRAP_BOX))
-#define GTK_WRAP_BOX_GET_CLASS(obj) (GTK_WRAP_BOX_CLASS (G_OBJECT_GET_CLASS (obj)))
+#define GTK_WRAP_BOX_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_WRAP_BOX, GtkWrapBoxClass))
/* --- typedefs --- */
@@ -45,9 +43,6 @@ typedef struct _GtkWrapBox GtkWrapBox;
typedef struct _GtkWrapBoxClass GtkWrapBoxClass;
typedef struct _GtkWrapBoxChild GtkWrapBoxChild;
-
- /* For nautilus usage, we should remove the
- aspect ratio capability */
/* --- GtkWrapBox --- */
struct _GtkWrapBox
{
@@ -72,12 +67,6 @@ struct _GtkWrapBoxClass
GtkAllocation *area,
guint *max_child_size,
gboolean *expand_line);
-
- /* This signal is added to tell parent widgets that
- the box doesn't have enough space in the new configuration,
- and that a resize is recommended. This can happen when a
- layout changes the box's allocation. */
- void (*need_reallocation) (GtkWrapBox *wbox);
};
struct _GtkWrapBoxChild
{
@@ -86,7 +75,7 @@ struct _GtkWrapBoxChild
guint hfill : 1;
guint vexpand : 1;
guint vfill : 1;
- guint forced_break : 1;
+ guint wrapped : 1;
GtkWrapBoxChild *next;
};
@@ -95,7 +84,7 @@ struct _GtkWrapBoxChild
/* --- prototypes --- */
-GtkType gtk_wrap_box_get_type (void);
+GtkType gtk_wrap_box_get_type (void) G_GNUC_CONST;
void gtk_wrap_box_set_homogeneous (GtkWrapBox *wbox,
gboolean homogeneous);
void gtk_wrap_box_set_hspacing (GtkWrapBox *wbox,
@@ -114,6 +103,13 @@ void gtk_wrap_box_pack (GtkWrapBox *wbox,
gboolean hfill,
gboolean vexpand,
gboolean vfill);
+void gtk_wrap_box_pack_wrapped (GtkWrapBox *wbox,
+ GtkWidget *child,
+ gboolean hexpand,
+ gboolean hfill,
+ gboolean vexpand,
+ gboolean vfill,
+ gboolean wrapped);
void gtk_wrap_box_reorder_child (GtkWrapBox *wbox,
GtkWidget *child,
gint position);
@@ -122,27 +118,19 @@ void gtk_wrap_box_query_child_packing (GtkWrapBox *wbox,
gboolean *hexpand,
gboolean *hfill,
gboolean *vexpand,
- gboolean *vfill);
-void gtk_wrap_box_query_child_forced_break (GtkWrapBox *wbox,
- GtkWidget *child,
- gboolean *forced_break);
+ gboolean *vfill,
+ gboolean *wrapped);
void gtk_wrap_box_set_child_packing (GtkWrapBox *wbox,
GtkWidget *child,
gboolean hexpand,
gboolean hfill,
gboolean vexpand,
- gboolean vfill);
-void gtk_wrap_box_set_child_forced_break (GtkWrapBox *wbox,
- GtkWidget *child,
- gboolean forced_break);
+ gboolean vfill,
+ gboolean wrapped);
guint* gtk_wrap_box_query_line_lengths (GtkWrapBox *wbox,
guint *n_lines);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
+G_END_DECLS
#endif /* __GTK_WRAP_BOX_H__ */