Patches to gnome-icon-list & gnome-icon-sel
- From: Samuel Solon <ssolon usa net>
- To: gnome-list gnome org
- Subject: Patches to gnome-icon-list & gnome-icon-sel
- Date: Sat, 14 Nov 1998 14:09:54 -0700
Recent changes to gtk_scrolled_window have broken several other widgets.
I submit the following patches as fixes for gnome-icon-list and
gnome-icon-sel.
Index: gnome-icon-list.c
===================================================================
RCS file: /cvs/gnome/gnome-libs/libgnomeui/gnome-icon-list.c,v
retrieving revision 1.36
diff -u -r1.36 gnome-icon-list.c
--- gnome-icon-list.c 1998/11/05 22:09:03 1.36
+++ gnome-icon-list.c 1998/11/14 21:01:28
@@ -49,6 +49,12 @@
SYNC_REMOVE
} SyncType;
+enum {
+ ARG_0,
+ ARG_HADJUSTMENT,
+ ARG_VADJUSTMENT
+};
+
static guint gil_signals [LAST_SIGNAL] = { 0 };
/* Inheritance */
@@ -1334,6 +1340,57 @@
}
static void
+gil_set_arg (GtkObject *object,
+ GtkArg *arg,
+ guint arg_id)
+{
+ GnomeIconList *gil;
+ GtkAdjustment *adjustment;
+
+ gil = GNOME_ICON_LIST (object);
+
+ switch (arg_id) {
+ case ARG_HADJUSTMENT:
+ adjustment = GTK_VALUE_POINTER (*arg);
+ gnome_icon_list_set_hadjustment (gil, adjustment);
+ break;
+
+ case ARG_VADJUSTMENT:
+ adjustment = GTK_VALUE_POINTER (*arg);
+ gnome_icon_list_set_vadjustment (gil, adjustment);
+ break;
+
+ default:
+ break;
+ }
+
+}
+
+static void
+gil_get_arg (GtkObject *object,
+ GtkArg *arg,
+ guint arg_id)
+{
+ GnomeIconList *gil;
+
+ gil = GNOME_ICON_LIST (object);
+
+ switch (arg_id) {
+ case ARG_HADJUSTMENT:
+ GTK_VALUE_POINTER (*arg) = gil->hadj;
+ break;
+
+ case ARG_VADJUSTMENT:
+ GTK_VALUE_POINTER (*arg) = gil->adj;
+ break;
+
+ default:
+ arg->type = GTK_TYPE_INVALID;
+ break;
+ }
+}
+
+static void
gil_class_init (GilClass *gil_class)
{
GtkObjectClass *object_class;
@@ -1346,6 +1403,15 @@
parent_class = gtk_type_class (gnome_canvas_get_type ());
+ gtk_object_add_arg_type ("GnomeIconList::hadjustment",
+ GTK_TYPE_ADJUSTMENT,
+ GTK_ARG_READWRITE,
+ ARG_HADJUSTMENT);
+ gtk_object_add_arg_type ("GnomeIconList::vadjustment",
+ GTK_TYPE_ADJUSTMENT,
+ GTK_ARG_READWRITE,
+ ARG_VADJUSTMENT);
+
gil_signals [SELECT_ICON] =
gtk_signal_new (
"select_icon",
@@ -1382,7 +1448,9 @@
gtk_object_class_add_signals (object_class, gil_signals, LAST_SIGNAL);
object_class->destroy = gil_destroy;
-
+ object_class->set_arg = gil_set_arg;
+ object_class->get_arg = gil_get_arg;
+
widget_class->size_request = gil_size_request;
widget_class->size_allocate = gil_size_allocate;
widget_class->realize = gil_realize;
@@ -1477,6 +1545,69 @@
gnome_canvas_scroll_to (GNOME_CANVAS (gil), 0, adj->value);
}
+void
+gnome_icon_list_set_hadjustment (GnomeIconList *gil, GtkAdjustment *hadj)
+{
+ GtkAdjustment *old_adjustment;
+
+ /* hadj isn't used but is here for compatibility with GtkScrolledWindow */
+
+ g_return_if_fail (gil != NULL);
+ g_return_if_fail (IS_GIL (gil));
+ if (hadj)
+ g_return_if_fail (GTK_IS_ADJUSTMENT (hadj));
+
+ if (gil->hadj == hadj)
+ return;
+
+ old_adjustment = gil->hadj;
+
+ if (gil->hadj)
+ gtk_object_unref (GTK_OBJECT (gil->hadj));
+
+ gil->hadj = hadj;
+
+ if (gil->hadj) {
+ gtk_object_ref (GTK_OBJECT (gil->hadj));
+ }
+
+ if (!gil->hadj || !old_adjustment)
+ gtk_widget_queue_resize (GTK_WIDGET (gil));
+}
+
+void
+gnome_icon_list_set_vadjustment (GnomeIconList *gil, GtkAdjustment *vadj)
+{
+ GtkAdjustment *old_adjustment;
+
+ g_return_if_fail (gil != NULL);
+ g_return_if_fail (IS_GIL (gil));
+ if (vadj)
+ g_return_if_fail (GTK_IS_ADJUSTMENT (vadj));
+
+ if (gil->adj == vadj)
+ return;
+
+ old_adjustment = gil->adj;
+
+ if (gil->adj) {
+ gtk_signal_disconnect_by_data (GTK_OBJECT (gil->adj), gil);
+ gtk_object_unref (GTK_OBJECT (gil->adj));
+ }
+
+ gil->adj = vadj;
+
+ if (gil->adj) {
+ gtk_object_ref (GTK_OBJECT (gil->adj));
+ gtk_object_sink (GTK_OBJECT (gil->adj));
+ gtk_signal_connect (GTK_OBJECT (gil->adj), "value_changed",
+ GTK_SIGNAL_FUNC (gil_adj_value_changed), gil);
+ }
+
+ if (!gil->adj || !old_adjustment)
+ gtk_widget_queue_resize (GTK_WIDGET (gil));
+}
+
void
gnome_icon_list_construct (GnomeIconList *gil, guint icon_width, GtkAdjustment *adj, gboolean is_editable)
{
@@ -1486,16 +1617,11 @@
gnome_icon_list_set_icon_width (gil, icon_width);
gil->is_editable = is_editable;
- if (adj)
- gtk_object_ref (GTK_OBJECT (adj));
- else
- adj = GTK_ADJUSTMENT (
- gtk_adjustment_new (0, 0, 1, 0.1, 0.1, 0.1));
+ if (!adj)
+ adj = GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, 1, 0.1, 0.1, 0.1));
- gil->adj = adj;
+ gnome_icon_list_set_vadjustment (gil, adj);
- gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
- GTK_SIGNAL_FUNC (gil_adj_value_changed), gil);
}
Index: gnome-icon-list.h
===================================================================
RCS file: /cvs/gnome/gnome-libs/libgnomeui/gnome-icon-list.h,v
retrieving revision 1.20
diff -u -r1.20 gnome-icon-list.h
--- gnome-icon-list.h 1998/10/15 01:05:40 1.20
+++ gnome-icon-list.h 1998/11/14 21:01:28
@@ -39,7 +39,8 @@
GnomeCanvas canvas;
GtkAdjustment *adj; /* The scrolling adjustment we use */
-
+ GtkAdjustment *hadj; /* dummmy need for GtkScrolledWindow compat */
+
int icons; /* Number of icons in the IconList */
GList *icon_list; /* The list of icons */
@@ -104,6 +105,12 @@
guint icon_width,
GtkAdjustment *adj,
gboolean is_editable);
+
+void gnome_icon_list_set_hadjustment (GnomeIconList *gil,
+ GtkAdjustment *hadj);
+
+void gnome_icon_list_set_vadjustment (GnomeIconList *gil,
+ GtkAdjustment *vadj);
/* To avoid excesive recomputes during insertion/deletion */
void gnome_icon_list_freeze (GnomeIconList *gil);
Index: gnome-icon-sel.c
===================================================================
RCS file: /cvs/gnome/gnome-libs/libgnomeui/gnome-icon-sel.c,v
retrieving revision 1.4
diff -u -r1.4 gnome-icon-sel.c
--- gnome-icon-sel.c 1998/11/04 22:32:57 1.4
+++ gnome-icon-sel.c 1998/11/14 21:01:38
@@ -81,20 +81,25 @@
static void
gnome_icon_selection_init (GnomeIconSelection *gis)
{
+ GtkWidget* scrollw = gtk_scrolled_window_new(NULL, NULL);
+
gis->box = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(gis), gis->box);
-
+
gtk_widget_show(gis->box);
gis->clist = gtk_clist_new(1);
gtk_clist_set_row_height(GTK_CLIST(gis->clist),
ICON_SIZE + GNOME_PAD_SMALL);
- gtk_box_pack_end(GTK_BOX(gis->box) , gis->clist, TRUE, TRUE, 0);
+ gtk_container_add(GTK_CONTAINER(scrollw), gis->clist);
+
+ gtk_box_pack_end(GTK_BOX(gis->box) , scrollw, TRUE, TRUE, 0);
gtk_widget_show(gis->clist);
-
+ gtk_widget_show(scrollw);
+
gis->file_list = NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]