Binary compatible theme expansion
- From: Pavel Machek <pavel atrey karlin mff cuni cz>
- To: gtk-devel-list redhat com
- Subject: Binary compatible theme expansion
- Date: Mon, 22 Feb 1999 14:00:37 +0100
Hi!
Would this patch to gtk be acceptable? If so, please apply it. If not,
please let me know. It seems to me like if gtk-devel-list keeps
ignoring my mailings (I already mailed this one, but it looks like it
got lost.)
Pavel
PS: What it does? It makes themes expandable without breaking binary
compatibility, and it makes gdk identify-able via gdk_version()
function.
diff -ur gtk+-1.1.15.ofic/gdk/gdk.c gtk+-1.1.15/gdk/gdk.c
--- gtk+-1.1.15.ofic/gdk/gdk.c Mon Jan 18 00:09:46 1999
+++ gtk+-1.1.15/gdk/gdk.c Fri Feb 19 18:43:20 1999
@@ -421,6 +421,12 @@
gdk_initialized = 1;
}
+gchar *
+gdk_version (void)
+{
+ return "X";
+}
+
/*
*--------------------------------------------------------------
* gdk_exit
Only in gtk+-1.1.15/gdk: gdk.c~
diff -ur gtk+-1.1.15.ofic/gdk/gdk.h gtk+-1.1.15/gdk/gdk.h
--- gtk+-1.1.15.ofic/gdk/gdk.h Thu Jan 28 04:07:11 1999
+++ gtk+-1.1.15/gdk/gdk.h Fri Feb 19 18:42:00 1999
@@ -34,6 +34,7 @@
gchar ***argv);
void gdk_exit (gint error_code);
gchar* gdk_set_locale (void);
+gchar* gdk_version (void);
gboolean gdk_events_pending (void);
GdkEvent* gdk_event_get (void);
diff -ur gtk+-1.1.15.ofic/gtk/gtkbutton.c gtk+-1.1.15/gtk/gtkbutton.c
--- gtk+-1.1.15.ofic/gtk/gtkbutton.c Thu Jan 28 04:07:17 1999
+++ gtk+-1.1.15/gtk/gtkbutton.c Fri Feb 19 13:46:16 1999
@@ -420,17 +416,19 @@
button = GTK_BUTTON (widget);
- requisition->width = (GTK_CONTAINER (widget)->border_width + CHILD_SPACING +
+ requisition->width = (GTK_CONTAINER (widget)->border_width +
+ GTK_WIDGET (widget)->style->expand->button_child_spacing_x +
GTK_WIDGET (widget)->style->klass->xthickness) * 2;
- requisition->height = (GTK_CONTAINER (widget)->border_width + CHILD_SPACING +
+ requisition->height = (GTK_CONTAINER (widget)->border_width +
+ GTK_WIDGET (widget)->style->expand->button_child_spacing_y +
GTK_WIDGET (widget)->style->klass->ythickness) * 2;
if (GTK_WIDGET_CAN_DEFAULT (widget))
{
requisition->width += (GTK_WIDGET (widget)->style->klass->xthickness * 2 +
- DEFAULT_SPACING);
+ GTK_WIDGET (widget)->style->expand->button_default_spacing_x);
requisition->height += (GTK_WIDGET (widget)->style->klass->ythickness * 2 +
- DEFAULT_SPACING);
+ GTK_WIDGET (widget)->style->expand->button_default_spacing_y);
}
if (GTK_BIN (button)->child && GTK_WIDGET_VISIBLE (GTK_BIN (button)->child))
@@ -468,8 +466,11 @@
if (GTK_BIN (button)->child && GTK_WIDGET_VISIBLE (GTK_BIN (button)->child))
{
- child_allocation.x = (CHILD_SPACING + GTK_WIDGET (widget)->style->klass->xthickness);
- child_allocation.y = (CHILD_SPACING + GTK_WIDGET (widget)->style->klass->ythickness);
+ child_allocation.x = (GTK_WIDGET (widget)->style->klass->xthickness +
+ GTK_WIDGET (widget)->style->expand->button_child_spacing_x);
+ child_allocation.y = (GTK_WIDGET (widget)->style->klass->ythickness +
+ GTK_WIDGET (widget)->style->expand->button_child_spacing_y);
+
child_allocation.width = MAX (1, (gint)widget->allocation.width - child_allocation.x * 2 -
border_width * 2);
@@ -483,9 +484,11 @@
child_allocation.y += (GTK_WIDGET (widget)->style->klass->ythickness +
DEFAULT_TOP_POS);
child_allocation.width = MAX (1, (gint)child_allocation.width -
- (gint)(GTK_WIDGET (widget)->style->klass->xthickness * 2 + DEFAULT_SPACING));
+ (gint)(GTK_WIDGET (widget)->style->klass->xthickness * 2 +
+ GTK_WIDGET (widget)->style->expand->button_default_spacing_x));
child_allocation.height = MAX (1, (gint)child_allocation.height -
- (gint)(GTK_WIDGET (widget)->style->klass->xthickness * 2 + DEFAULT_SPACING));
+ (gint)(GTK_WIDGET (widget)->style->klass->xthickness * 2 +
+ GTK_WIDGET (widget)->style->expand->button_default_spacing_y));
}
gtk_widget_size_allocate (GTK_BIN (button)->child, &child_allocation);
@@ -552,8 +555,8 @@
{
x += widget->style->klass->xthickness;
y += widget->style->klass->ythickness;
- width -= 2 * x + DEFAULT_SPACING;
- height -= 2 * y + DEFAULT_SPACING;
+ width -= 2 * x + GTK_WIDGET (widget)->style->expand->button_default_spacing_x;
+ height -= 2 * y + GTK_WIDGET (widget)->style->expand->button_default_spacing_y;
x += DEFAULT_LEFT_POS;
y += DEFAULT_TOP_POS;
}
diff -ur gtk+-1.1.15.ofic/gtk/gtkcheckbutton.c gtk+-1.1.15/gtk/gtkcheckbutton.c
--- gtk+-1.1.15.ofic/gtk/gtkcheckbutton.c Thu Jan 28 04:07:18 1999
+++ gtk+-1.1.15/gtk/gtkcheckbutton.c Fri Feb 19 15:37:22 1999
@@ -20,12 +20,12 @@
#include "gtklabel.h"
-#define INDICATOR_SIZE 10
-#define INDICATOR_SPACING 2
+#define INDICATOR_SIZE_X 32
+#define INDICATOR_SIZE_Y 8
+#define INDICATOR_SPACING 1
#define CHECK_BUTTON_CLASS(w) GTK_CHECK_BUTTON_CLASS (GTK_OBJECT (w)->klass)
-
static void gtk_check_button_class_init (GtkCheckButtonClass *klass);
static void gtk_check_button_init (GtkCheckButton *check_button);
static void gtk_check_button_draw (GtkWidget *widget,
@@ -86,7 +86,6 @@
widget_class->size_allocate = gtk_check_button_size_allocate;
widget_class->expose_event = gtk_check_button_expose;
- class->indicator_size = INDICATOR_SIZE;
class->indicator_spacing = INDICATOR_SPACING;
class->draw_indicator = gtk_real_check_button_draw_indicator;
}
@@ -221,10 +220,10 @@
if (toggle_button->draw_indicator)
{
- requisition->width += (CHECK_BUTTON_CLASS (widget)->indicator_size +
+ requisition->width += (GTK_WIDGET (widget)->style->expand->check_indicator_size_x +
CHECK_BUTTON_CLASS (widget)->indicator_spacing * 3 + 2);
- temp = (CHECK_BUTTON_CLASS (widget)->indicator_size +
+ temp = (GTK_WIDGET (widget)->style->expand->check_indicator_size_y +
CHECK_BUTTON_CLASS (widget)->indicator_spacing * 2);
requisition->height = MAX (requisition->height, temp) + 2;
}
@@ -259,14 +258,14 @@
if (GTK_BIN (button)->child && GTK_WIDGET_VISIBLE (GTK_BIN (button)->child))
{
child_allocation.x = (GTK_CONTAINER (widget)->border_width +
- CHECK_BUTTON_CLASS (widget)->indicator_size +
+ GTK_WIDGET (widget)->style->expand->check_indicator_size_x +
CHECK_BUTTON_CLASS (widget)->indicator_spacing * 3 + 1 +
widget->allocation.x);
child_allocation.y = GTK_CONTAINER (widget)->border_width + 1 +
widget->allocation.y;
child_allocation.width = MAX (1, allocation->width -
(GTK_CONTAINER (widget)->border_width +
- CHECK_BUTTON_CLASS (widget)->indicator_size +
+ GTK_WIDGET (widget)->style->expand->check_indicator_size_x +
CHECK_BUTTON_CLASS (widget)->indicator_spacing * 3 + 1) -
GTK_CONTAINER (widget)->border_width - 1);
child_allocation.height = MAX (1, allocation->height - (GTK_CONTAINER (widget)->border_width + 1) * 2);
@@ -378,11 +377,12 @@
new_area.x, new_area.y,
new_area.width, new_area.height);
}
+
+ width = GTK_WIDGET (widget)->style->expand->check_indicator_size_x;
+ height = GTK_WIDGET (widget)->style->expand->check_indicator_size_y;
x = widget->allocation.x + CHECK_BUTTON_CLASS (widget)->indicator_spacing + GTK_CONTAINER (widget)->border_width;
- y = widget->allocation.y + (widget->allocation.height - CHECK_BUTTON_CLASS (widget)->indicator_size) / 2;
- width = CHECK_BUTTON_CLASS (widget)->indicator_size;
- height = CHECK_BUTTON_CLASS (widget)->indicator_size;
+ y = widget->allocation.y + (widget->allocation.height - height) / 2;
if (GTK_TOGGLE_BUTTON (widget)->active)
{
Only in gtk+-1.1.15/gtk: gtkcheckbutton.c~
diff -ur gtk+-1.1.15.ofic/gtk/gtkcheckbutton.h gtk+-1.1.15/gtk/gtkcheckbutton.h
--- gtk+-1.1.15.ofic/gtk/gtkcheckbutton.h Tue Jun 16 07:19:14 1998
+++ gtk+-1.1.15/gtk/gtkcheckbutton.h Fri Feb 19 14:00:52 1999
@@ -48,7 +48,6 @@
{
GtkToggleButtonClass parent_class;
- guint16 indicator_size;
guint16 indicator_spacing;
void (* draw_indicator) (GtkCheckButton *check_button,
diff -ur gtk+-1.1.15.ofic/gtk/gtkentry.c gtk+-1.1.15/gtk/gtkentry.c
--- gtk+-1.1.15.ofic/gtk/gtkentry.c Thu Jan 28 06:06:40 1999
+++ gtk+-1.1.15/gtk/gtkentry.c Fri Feb 19 18:52:35 1999
@@ -526,7 +526,6 @@
g_free (entry->text_mb);
entry->text_mb = NULL;
- if (entry->backing_pixmap)
if (entry->backing_pixmap)
gdk_pixmap_unref (entry->backing_pixmap);
@@ -1304,7 +1303,9 @@
and copy it to the text_area.
Otherwise draw to text_area directly for better speed.
*/
- use_backing_pixmap = GTK_WIDGET_HAS_FOCUS (widget) && (entry->text != NULL);
+
+ use_backing_pixmap = GTK_WIDGET_HAS_FOCUS (widget) && (entry->text != NULL) &&
+ strncmp(gdk_version(), "curses", 6);
if (use_backing_pixmap)
{
gtk_entry_make_backing_pixmap (entry, width, height);
diff -ur gtk+-1.1.15.ofic/gtk/gtklayout.c gtk+-1.1.15/gtk/gtklayout.c
--- gtk+-1.1.15.ofic/gtk/gtklayout.c Thu Jan 28 06:06:40 1999
+++ gtk+-1.1.15/gtk/gtklayout.c Fri Feb 19 13:51:34 1999
@@ -25,6 +25,7 @@
#include "gtksignal.h"
#include "gtkprivate.h"
#include "gdk/gdkx.h"
+#include "gdk/gdk.h"
typedef struct _GtkLayoutAdjData GtkLayoutAdjData;
typedef struct _GtkLayoutChild GtkLayoutChild;
diff -ur gtk+-1.1.15.ofic/gtk/gtkradiobutton.c gtk+-1.1.15/gtk/gtkradiobutton.c
--- gtk+-1.1.15.ofic/gtk/gtkradiobutton.c Thu Jan 28 04:07:36 1999
+++ gtk+-1.1.15/gtk/gtkradiobutton.c Fri Feb 19 15:37:21 1999
@@ -400,11 +400,11 @@
new_area.x, new_area.y,
new_area.width, new_area.height);
}
-
+
+ width = GTK_WIDGET (widget)->style->expand->check_indicator_size_x;
+ height = GTK_WIDGET (widget)->style->expand->check_indicator_size_y;
x = widget->allocation.x + CHECK_BUTTON_CLASS (widget)->indicator_spacing + GTK_CONTAINER (widget)->border_width;
- y = widget->allocation.y + (widget->allocation.height - CHECK_BUTTON_CLASS (widget)->indicator_size) / 2;
- width = CHECK_BUTTON_CLASS (widget)->indicator_size;
- height = CHECK_BUTTON_CLASS (widget)->indicator_size;
+ y = widget->allocation.y + (widget->allocation.height - height) / 2;
if (GTK_TOGGLE_BUTTON (widget)->active)
shadow_type = GTK_SHADOW_IN;
diff -ur gtk+-1.1.15.ofic/gtk/gtkstyle.c gtk+-1.1.15/gtk/gtkstyle.c
--- gtk+-1.1.15.ofic/gtk/gtkstyle.c Sun Jan 17 23:19:45 1999
+++ gtk+-1.1.15/gtk/gtkstyle.c Fri Feb 19 15:29:56 1999
@@ -287,7 +287,7 @@
gint width,
gint height,
GtkOrientation orientation);
-
+static void gtk_style_expand_init (GtkStyleExpand *e);
static void gtk_style_shade (GdkColor *a, GdkColor *b, gdouble k);
static void rgb_to_hls (gdouble *r, gdouble *g, gdouble *b);
@@ -458,6 +458,8 @@
style->text_gc[i] = NULL;
style->base_gc[i] = NULL;
}
+ style->expand = g_new0(GtkStyleExpand, 1);
+ gtk_style_expand_init(style->expand);
return style;
}
@@ -560,6 +562,24 @@
style->ref_count -= 1;
if (style->ref_count == 0)
gtk_style_destroy (style);
+}
+
+static void
+gtk_style_expand_init(GtkStyleExpand *e)
+{
+ e->button_child_spacing_x = 1;
+ e->button_child_spacing_y = 1;
+ e->button_default_top_pos = 4;
+ e->button_default_spacing_x = 7;
+ e->button_default_spacing_y = 7;
+ e->check_indicator_size_x = 10;
+ e->check_indicator_size_y = 10;
+ e->check_indicator_spacing = 2;
+ e->check_menu_size = 12;
+ e->list_cell_spacing = 1;
+ e->list_extra_space_y = 1;
+ e->label_extra_pad_y = 1;
+ e->radio_menu_size = 8;
}
static void
Only in gtk+-1.1.15/gtk: gtkstyle.c~
diff -ur gtk+-1.1.15.ofic/gtk/gtkstyle.h gtk+-1.1.15/gtk/gtkstyle.h
--- gtk+-1.1.15.ofic/gtk/gtkstyle.h Sun Jan 17 23:19:45 1999
+++ gtk+-1.1.15/gtk/gtkstyle.h Fri Feb 19 16:36:48 1999
@@ -29,6 +29,7 @@
typedef struct _GtkStyle GtkStyle;
typedef struct _GtkStyleClass GtkStyleClass;
+typedef struct _GtkStyleExpand GtkStyleExpand;
/* Some forward declarations needed to rationalize the header
* files.
@@ -93,7 +94,10 @@
* was created
*/
GSList *styles;
-};
+ GtkStyleExpand *expand; /* This should serve just as klass,
+ except that it is done in way to
+ preserve binary compatibility */
+ };
struct _GtkStyleClass
{
@@ -334,6 +338,23 @@
gint width,
gint height,
GtkOrientation orientation);
+};
+
+struct _GtkStyleExpand {
+ guint button_child_spacing_x;
+ guint button_child_spacing_y;
+ guint button_default_top_pos;
+ guint button_default_spacing_x;
+ guint button_default_spacing_y;
+ guint check_indicator_size_x;
+ guint check_indicator_size_y;
+ guint check_indicator_spacing; /* UNUSED */
+ guint check_menu_size;
+ guint list_cell_spacing;
+ guint list_extra_space_y;
+ guint label_extra_pad_y;
+ guint radio_menu_size;
+
};
GtkStyle* gtk_style_new (void);
diff -ur gtk+-1.1.15.ofic/gtk/gtktogglebutton.c gtk+-1.1.15/gtk/gtktogglebutton.c
--- gtk+-1.1.15.ofic/gtk/gtktogglebutton.c Thu Jan 21 01:46:27 1999
+++ gtk+-1.1.15/gtk/gtktogglebutton.c Fri Feb 19 20:02:58 1999
@@ -20,6 +20,7 @@
#include "gtkmain.h"
#include "gtksignal.h"
#include "gtktogglebutton.h"
+#include <string.h>
#define DEFAULT_LEFT_POS 4
diff -ur gtk+-1.1.15.ofic/gtk/testgtk.c gtk+-1.1.15/gtk/testgtk.c
--- gtk+-1.1.15.ofic/gtk/testgtk.c Thu Jan 28 04:07:36 1999
+++ gtk+-1.1.15/gtk/testgtk.c Fri Feb 19 13:51:34 1999
@@ -8411,7 +8411,7 @@
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_policy (GTK_WINDOW (window), FALSE, FALSE, FALSE);
gtk_widget_set_name (window, "main window");
- gtk_widget_set_usize (window, 200, 400);
+ gtk_widget_set_usize (window, MIN(200,gdk_screen_width()), MIN(400,gdk_screen_height()));
gtk_widget_set_uposition (window, 20, 20);
gtk_signal_connect (GTK_OBJECT (window), "destroy",
--
The best software in life is free (not shareware)! Pavel
GCM d? s-: !g p?:+ au- a--@ w+ v- C++@ UL+++ L++ N++ E++ W--- M- Y- R+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]