assorted goo
- From: Havoc Pennington <hp redhat com>
- To: gtk-devel-list gnome org
- Subject: assorted goo
- Date: 08 May 2001 19:44:07 -0400
The ChangeLogs in here more or less summarize I guess.
Among other things this enables toolbars/menubars with 1 pixel x/y
thickness, and makes their padding configurable, so you can have
really space-efficient menu/toolbars.
Havoc
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.1945
diff -u -u -r1.1945 ChangeLog
--- ChangeLog 2001/05/07 19:27:50 1.1945
+++ ChangeLog 2001/05/08 23:40:31
@@ -1,3 +1,32 @@
+2001-05-08 Havoc Pennington <hp redhat com>
+
+ * gtk/gtkstyle.c (gtk_default_draw_shadow): handle
+ xthickness/ythickness of 0 or 1 properly
+ (gtk_default_draw_resize_grip): clear the background behind the
+ resize grips, and align to bottom right if we square the
+ area to be drawn.
+
+ * gtk/gtkstatusbar.c (gtk_statusbar_init): set horizontal usize on
+ statusbar label to 1, so it doesn't make toplevels resize oddly
+ (gtk_statusbar_size_request): add grip size to request
+ (gtk_statusbar_size_allocate): hack so the hbox still works with
+ the grip size in the request
+
+ * gtk/gtktoolbar.c (gtk_toolbar_show_all): override to fix
+ bug where showing all on a toplevel makes the toolbar
+ button text appear despite the toolbar mode
+
+ * gtk/gtkmenubar.c: add internal padding style property
+
+ * gtk/gtktoolbar.c: Add internal padding style property; add
+ shadow type style property
+
+ * gtk/gtkmenubar.c (gtk_menu_bar_paint): paint box with widget
+ state; and put Container::border_width outside the frame
+
+ * gtk/gtktextview.c: don't draw focus rectangle if we're in
+ interior focus mode, we just use blinking cursor
+
2001-05-07 Alexander Larsson <alexl redhat com>
* demos/testpixbuf-save.c:
Index: demos/gtk-demo/Makefile.am
===================================================================
RCS file: /cvs/gnome/gtk+/demos/gtk-demo/Makefile.am,v
retrieving revision 1.12
diff -u -u -r1.12 Makefile.am
--- demos/gtk-demo/Makefile.am 2001/05/07 15:58:31 1.12
+++ demos/gtk-demo/Makefile.am 2001/05/08 23:40:31
@@ -5,6 +5,7 @@
## These should be in the order you want them to appear in the
## demo app, which means alphabetized by demo title, not filename
demos = @STRIP_BEGIN@ \
+ appwindow.c \
button_box.c \
colorsel.c \
dialog.c \
Index: demos/gtk-demo/appwindow.c
===================================================================
RCS file: appwindow.c
diff -N appwindow.c
--- /dev/null Tue May 5 16:32:27 1998
+++ appwindow.c Tue May 8 19:40:31 2001
@@ -0,0 +1,353 @@
+/* Application main window
+ *
+ * Demonstrates a typical application window, with menubar, toolbar, statusbar.
+ */
+
+#include <gtk/gtk.h>
+
+static GtkWidget *window = NULL;
+
+
+static void
+menuitem_cb (gpointer callback_data,
+ guint callback_action,
+ GtkWidget *widget)
+{
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (callback_data),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_CLOSE,
+ "You selected or toggled the menu item: \"%s\"",
+ gtk_item_factory_path_from_widget (widget));
+
+ /* Close dialog on user response */
+ g_signal_connectc (G_OBJECT (dialog),
+ "response",
+ G_CALLBACK (gtk_widget_destroy),
+ NULL,
+ FALSE);
+
+ gtk_widget_show (dialog);
+}
+
+
+static GtkItemFactoryEntry menu_items[] =
+{
+ { "/_File", NULL, 0, 0, "<Branch>" },
+ { "/File/tearoff1", NULL, menuitem_cb, 0, "<Tearoff>" },
+ { "/File/_New", "<control>N", menuitem_cb, 0, "<StockItem>", GTK_STOCK_NEW },
+ { "/File/_Open", "<control>O", menuitem_cb, 0, "<StockItem>", GTK_STOCK_OPEN },
+ { "/File/_Save", "<control>S", menuitem_cb, 0, "<StockItem>", GTK_STOCK_SAVE },
+ { "/File/Save _As...", NULL, menuitem_cb, 0, "<StockItem>", GTK_STOCK_SAVE },
+ { "/File/sep1", NULL, menuitem_cb, 0, "<Separator>" },
+ { "/File/_Quit", "<control>Q", menuitem_cb, 0, "<StockItem>", GTK_STOCK_QUIT },
+
+ { "/_Preferences", NULL, 0, 0, "<Branch>" },
+ { "/_Preferences/_Color", NULL, 0, 0, "<Branch>" },
+ { "/_Preferences/Color/_Red", NULL, menuitem_cb, 0, "<RadioItem>" },
+ { "/_Preferences/Color/_Green", NULL, menuitem_cb, 0, "/Preferences/Color/Red" },
+ { "/_Preferences/Color/_Blue", NULL, menuitem_cb, 0, "/Preferences/Color/Red" },
+ { "/_Preferences/_Shape", NULL, 0, 0, "<Branch>" },
+ { "/_Preferences/Shape/_Square", NULL, menuitem_cb, 0, "<RadioItem>" },
+ { "/_Preferences/Shape/_Rectangle", NULL, menuitem_cb, 0, "/Preferences/Shape/Square" },
+ { "/_Preferences/Shape/_Oval", NULL, menuitem_cb, 0, "/Preferences/Shape/Rectangle" },
+
+ { "/_Help", NULL, 0, 0, "<LastBranch>" },
+ { "/Help/_About", NULL, menuitem_cb, 0 },
+};
+
+static void
+toolbar_cb (GtkWidget *button,
+ gpointer data)
+{
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (data),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_CLOSE,
+ "You selected a toolbar button");
+
+ /* Close dialog on user response */
+ g_signal_connectc (G_OBJECT (dialog),
+ "response",
+ G_CALLBACK (gtk_widget_destroy),
+ NULL,
+ FALSE);
+
+ gtk_widget_show (dialog);
+}
+
+/* This function registers our custom toolbar icons, so they can be themed.
+ */
+static void
+register_stock_icons (void)
+{
+ static gboolean registered = FALSE;
+
+ if (!registered)
+ {
+ GdkPixbuf *pixbuf;
+ GtkIconFactory *factory;
+
+ static GtkStockItem items[] = {
+ { "demo-gtk-logo",
+ "_GTK!",
+ 0, 0, NULL }
+ };
+
+ registered = TRUE;
+
+ /* Register our stock items */
+ gtk_stock_add (items, G_N_ELEMENTS (items));
+
+ /* Add our custom icon factory to the list of defaults */
+ factory = gtk_icon_factory_new ();
+ gtk_icon_factory_add_default (factory);
+
+ /* Try current directory */
+ pixbuf = gdk_pixbuf_new_from_file ("./gtk-logo-rgb.gif", NULL);
+
+ /* Try install directory */
+ if (pixbuf == NULL)
+ pixbuf = gdk_pixbuf_new_from_file (DEMOCODEDIR"/gtk-logo-rgb.gif", NULL);
+
+ /* Register icon to accompany stock item */
+ if (pixbuf != NULL)
+ {
+ GtkIconSet *icon_set;
+ GdkPixbuf *transparent;
+
+ /* The gtk-logo-rgb icon has a white background, make it transparent */
+ transparent = gdk_pixbuf_add_alpha (pixbuf, TRUE, 0xff, 0xff, 0xff);
+
+ icon_set = gtk_icon_set_new_from_pixbuf (transparent);
+ gtk_icon_factory_add (factory, "demo-gtk-logo", icon_set);
+ gtk_icon_set_unref (icon_set);
+ g_object_unref (G_OBJECT (pixbuf));
+ g_object_unref (G_OBJECT (transparent));
+ }
+ else
+ g_warning ("failed to load GTK logo for toolbar");
+
+ /* Drop our reference to the factory, GTK will hold a reference. */
+ g_object_unref (G_OBJECT (factory));
+ }
+}
+
+static void
+update_statusbar (GtkTextBuffer *buffer,
+ GtkStatusbar *statusbar)
+{
+ gchar *msg;
+ gint row, col;
+ gint count;
+ GtkTextIter iter;
+
+ gtk_statusbar_pop (statusbar, 0); /* clear any previous message, underflow is allowed */
+
+ count = gtk_text_buffer_get_char_count (buffer);
+
+ gtk_text_buffer_get_iter_at_mark (buffer,
+ &iter,
+ gtk_text_buffer_get_insert (buffer));
+
+ row = gtk_text_iter_get_line (&iter);
+ col = gtk_text_iter_get_line_offset (&iter);
+
+ msg = g_strdup_printf ("Cursor at row %d column %d - %d chars in document",
+ row, col, count);
+
+ gtk_statusbar_push (statusbar, 0, msg);
+
+ g_free (msg);
+}
+
+static void
+mark_set_callback (GtkTextBuffer *buffer,
+ const GtkTextIter *new_location,
+ GtkTextMark *mark,
+ gpointer data)
+{
+ update_statusbar (buffer, GTK_STATUSBAR (data));
+}
+
+GtkWidget *
+do_appwindow (void)
+{
+ if (!window)
+ {
+ GtkWidget *table;
+ GtkWidget *toolbar;
+ GtkWidget *statusbar;
+ GtkWidget *contents;
+ GtkWidget *sw;
+ GtkTextBuffer *buffer;
+ GtkAccelGroup *accel_group;
+ GtkItemFactory *item_factory;
+
+ register_stock_icons ();
+
+ /* Create the toplevel window
+ */
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title (GTK_WINDOW (window), "Application Window");
+
+ /* NULL window variable when window is closed */
+ g_signal_connectc (G_OBJECT (window), "destroy",
+ G_CALLBACK (gtk_widget_destroyed),
+ &window, TRUE);
+
+ table = gtk_table_new (1, 4, FALSE);
+
+ gtk_container_add (GTK_CONTAINER (window), table);
+
+ /* Create the menubar
+ */
+
+ accel_group = gtk_accel_group_new ();
+ gtk_accel_group_attach (accel_group, GTK_OBJECT (window));
+ gtk_accel_group_unref (accel_group);
+
+ item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", accel_group);
+
+ /* Set up item factory to go away with the window */
+ gtk_object_ref (GTK_OBJECT (item_factory));
+ gtk_object_sink (GTK_OBJECT (item_factory));
+ g_object_set_data_full (G_OBJECT (window),
+ "<main>",
+ item_factory,
+ (GDestroyNotify) g_object_unref);
+
+ /* create menu items */
+ gtk_item_factory_create_items (item_factory, G_N_ELEMENTS (menu_items),
+ menu_items, window);
+
+ gtk_table_attach (GTK_TABLE (table),
+ gtk_item_factory_get_widget (item_factory, "<main>"),
+ 0, 1,
+ 0, 1,
+ GTK_EXPAND | GTK_FILL,
+ 0,
+ 0, 0);
+
+ /* Create the toolbar
+ */
+ toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL,
+ GTK_TOOLBAR_ICONS);
+ gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar),
+ GTK_ICON_SIZE_SMALL_TOOLBAR);
+
+ gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar),
+ GTK_STOCK_OPEN,
+ "This is a demo button with an 'open' icon",
+ NULL,
+ G_CALLBACK (toolbar_cb),
+ window, /* user data for callback */
+ -1); /* -1 means "append" */
+
+ gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar),
+ GTK_STOCK_QUIT,
+ "This is a demo button with a 'quit' icon",
+ NULL,
+ G_CALLBACK (toolbar_cb),
+ window, /* user data for callback */
+ -1); /* -1 means "append" */
+
+ gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
+
+ gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar),
+ "demo-gtk-logo",
+ "This is a demo button with a 'gtk' icon",
+ NULL,
+ G_CALLBACK (toolbar_cb),
+ window, /* user data for callback */
+ -1); /* -1 means "append" */
+
+ gtk_table_attach (GTK_TABLE (table),
+ toolbar,
+ 0, 1,
+ 1, 2,
+ GTK_EXPAND | GTK_FILL,
+ 0,
+ 0, 0);
+
+ /* Create document
+ */
+
+ sw = gtk_scrolled_window_new (NULL, NULL);
+
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
+
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
+ GTK_SHADOW_IN);
+
+ gtk_table_attach (GTK_TABLE (table),
+ sw,
+ 0, 1,
+ 2, 3,
+ GTK_EXPAND | GTK_FILL,
+ GTK_EXPAND | GTK_FILL,
+ 0, 0);
+
+ /* Set the scrolled window as geometry widget, so that
+ * when we set the default window size, the size will
+ * be the size of the scrolled window rather than the
+ * whole window.
+ */
+ gtk_window_set_geometry_hints (GTK_WINDOW (window),
+ sw, NULL, 0);
+
+ gtk_window_set_default_size (GTK_WINDOW (window),
+ 200, 200);
+
+ contents = gtk_text_view_new ();
+
+ gtk_container_add (GTK_CONTAINER (sw),
+ contents);
+
+ /* Create statusbar */
+
+ statusbar = gtk_statusbar_new ();
+ gtk_table_attach (GTK_TABLE (table),
+ statusbar,
+ 0, 1,
+ 3, 4,
+ GTK_EXPAND | GTK_FILL,
+ 0,
+ 0, 0);
+
+ /* Show text widget info in the statusbar */
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (contents));
+
+ g_signal_connectc (G_OBJECT (buffer),
+ "changed",
+ G_CALLBACK (update_statusbar),
+ statusbar, FALSE);
+
+ g_signal_connectc (G_OBJECT (buffer),
+ "mark_set", /* cursor moved */
+ G_CALLBACK (mark_set_callback),
+ statusbar, FALSE);
+
+ update_statusbar (buffer, GTK_STATUSBAR (statusbar));
+ }
+
+ if (!GTK_WIDGET_VISIBLE (window))
+ {
+ gtk_widget_show_all (window);
+ }
+ else
+ {
+ gtk_widget_destroy (window);
+ window = NULL;
+ }
+
+ return window;
+}
+
Index: demos/gtk-demo/gtk-logo-rgb.gif
===================================================================
RCS file: /cvs/gnome/gtk+/demos/gtk-demo/gtk-logo-rgb.gif,v
retrieving revision 1.1
diff -u -u -r1.1 gtk-logo-rgb.gif
Binary files /tmp/cvsIYG6my and gtk-logo-rgb.gif differ
Index: docs/Changes-2.0.txt
===================================================================
RCS file: /cvs/gnome/gtk+/docs/Changes-2.0.txt,v
retrieving revision 1.17
diff -u -u -r1.17 Changes-2.0.txt
--- docs/Changes-2.0.txt 2001/04/29 03:08:31 1.17
+++ docs/Changes-2.0.txt 2001/05/08 23:40:31
@@ -322,3 +322,13 @@
* GdkColorContext is gone; you probably weren't using it anyway.
Use GdkColormap and the gdk_rgb_* functions instead.
+
+* GtkMenuBar now draws the GtkContainer::border_width space outside
+ the frame, not inside the frame
+
+* In GTK 1.2, if an event handler returned TRUE it prevented
+ propagation of that event to parent widgets. That is, the
+ event signal would not be emitted on parent widgets. In
+ GTK 2.0, if an event handler returns TRUE, the current signal
+ emission on the current widget is immediately stopped. That is,
+ other callbacks connected to the signal will not be invoked.
\ No newline at end of file
Index: docs/reference/gdk-pixbuf/tmpl/animation.sgml
===================================================================
RCS file: /cvs/gnome/gtk+/docs/reference/gdk-pixbuf/tmpl/animation.sgml,v
retrieving revision 1.18
diff -u -u -r1.18 animation.sgml
--- docs/reference/gdk-pixbuf/tmpl/animation.sgml 2001/05/07 15:58:35 1.18
+++ docs/reference/gdk-pixbuf/tmpl/animation.sgml 2001/05/08 23:40:31
@@ -20,6 +20,31 @@
#GdkPixbufLoader
</para>
+<!-- ##### ENUM GdkPixbufFrameAction ##### -->
+<para>
+
+</para>
+
+ GDK_PIXBUF_FRAME_RETAIN:
+ GDK_PIXBUF_FRAME_DISPOSE:
+ GDK_PIXBUF_FRAME_REVERT:
+
+<!-- ##### STRUCT GdkPixbufFrame ##### -->
+<para>
+
+</para>
+
+ pixbuf:
+ x_offset:
+ y_offset:
+ delay_time:
+ elapsed:
+ action:
+ need_recomposite:
+ bg_transparent:
+ composited:
+ revert:
+
<!-- ##### STRUCT GdkPixbufAnimation ##### -->
<para>
This object describes an animation.
Index: docs/reference/gtk/tmpl/gtk-unused.sgml
===================================================================
RCS file: /cvs/gnome/gtk+/docs/reference/gtk/tmpl/gtk-unused.sgml,v
retrieving revision 1.38
diff -u -u -r1.38 gtk-unused.sgml
--- docs/reference/gtk/tmpl/gtk-unused.sgml 2001/05/07 15:58:38 1.38
+++ docs/reference/gtk/tmpl/gtk-unused.sgml 2001/05/08 23:40:31
@@ -1621,3 +1621,19 @@
@window:
@Returns:
+<!-- ##### FUNCTION gtk_window_set_decorations_hint ##### -->
+<para>
+
+</para>
+
+ window:
+ decorations:
+
+<!-- ##### FUNCTION gtk_window_set_functions_hint ##### -->
+<para>
+
+</para>
+
+ window:
+ functions:
+
Index: docs/reference/gtk/tmpl/gtkrc.sgml
===================================================================
RCS file: /cvs/gnome/gtk+/docs/reference/gtk/tmpl/gtkrc.sgml,v
retrieving revision 1.23
diff -u -u -r1.23 gtkrc.sgml
--- docs/reference/gtk/tmpl/gtkrc.sgml 2001/05/07 15:58:38 1.23
+++ docs/reference/gtk/tmpl/gtkrc.sgml 2001/05/08 23:40:31
@@ -495,7 +495,6 @@
#GtkRcStyle structures to form a #GtkStyle.
</para>
- parent_instance:
@name:
@bg_pixmap_name:
@font_desc:
Index: docs/reference/gtk/tmpl/gtkwindow.sgml
===================================================================
RCS file: /cvs/gnome/gtk+/docs/reference/gtk/tmpl/gtkwindow.sgml,v
retrieving revision 1.15
diff -u -u -r1.15 gtkwindow.sgml
--- docs/reference/gtk/tmpl/gtkwindow.sgml 2001/05/07 15:58:39 1.15
+++ docs/reference/gtk/tmpl/gtkwindow.sgml 2001/05/08 23:40:31
@@ -393,15 +393,6 @@
@setting:
-<!-- ##### FUNCTION gtk_window_set_decorations_hint ##### -->
-<para>
-
-</para>
-
- window:
- decorations:
-
-
<!-- ##### FUNCTION gtk_window_set_frame_dimensions ##### -->
<para>
@@ -412,15 +403,6 @@
@top:
@right:
@bottom:
-
-
-<!-- ##### FUNCTION gtk_window_set_functions_hint ##### -->
-<para>
-
-</para>
-
- window:
- functions:
<!-- ##### FUNCTION gtk_window_set_has_frame ##### -->
Index: gdk-pixbuf/ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/gdk-pixbuf/ChangeLog,v
retrieving revision 1.288
diff -u -u -r1.288 ChangeLog
--- gdk-pixbuf/ChangeLog 2001/05/07 15:58:40 1.288
+++ gdk-pixbuf/ChangeLog 2001/05/08 23:40:32
@@ -1,3 +1,9 @@
+2001-05-08 Havoc Pennington <hp redhat com>
+
+ * gdk-pixbuf-util.c (gdk_pixbuf_add_alpha): docs fixup,
+ and fix behavior to still subst color if the original image
+ had alpha
+
2001-05-04 Havoc Pennington <hp redhat com>
* pixops/pixops.c (pixops_process): merge fix from stable: Patch
Index: gdk-pixbuf/gdk-pixbuf-util.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk-pixbuf/gdk-pixbuf-util.c,v
retrieving revision 1.11
diff -u -u -r1.11 gdk-pixbuf-util.c
--- gdk-pixbuf/gdk-pixbuf-util.c 2001/05/07 15:58:41 1.11
+++ gdk-pixbuf/gdk-pixbuf-util.c 2001/05/08 23:40:32
@@ -30,18 +30,20 @@
/**
* gdk_pixbuf_add_alpha:
* @pixbuf: A pixbuf.
- * @substitute_color: Whether to substitute a color for zero opacity. If this
+ * @substitute_color: Whether to set a color to zero opacity. If this
* is #FALSE, then the (@r, @g, @b) arguments will be ignored.
* @r: Red value to substitute.
* @g: Green value to substitute.
* @b: Blue value to substitute.
*
- * Takes an existing pixbuf and adds an alpha channel to it. If the original
- * pixbuf already had alpha information, then the contents of the new pixbuf are
- * exactly the same as the original's. Otherwise, the new pixbuf will have all
- * pixels with full opacity if @substitute_color is #FALSE. If
- * @substitute_color is #TRUE, then the color specified by (@r, @g, @b) will be
- * substituted for zero opacity.
+ * Takes an existing pixbuf and adds an alpha channel to it.
+ * If the existing pixbuf already had an alpha channel, the channel
+ * values are copied from the original; otherwise, the alpha channel
+ * is initialized to 255 (full opacity).
+ *
+ * If @substitute_color is #TRUE, then the color specified by (@r, @g, @b) will be
+ * assigned zero opacity. That is, if you pass (255, 255, 255) for the
+ * substitute color, all white pixels will become fully transparent.
*
* Return value: A newly-created pixbuf with a reference count of 1.
**/
@@ -62,10 +64,12 @@
if (!new_pixbuf)
return NULL;
- return new_pixbuf;
- }
-
- new_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, pixbuf->width, pixbuf->height);
+ if (!substitute_color)
+ return new_pixbuf;
+ } else {
+ new_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, pixbuf->width, pixbuf->height);
+ }
+
if (!new_pixbuf)
return NULL;
@@ -75,16 +79,26 @@
src = pixbuf->pixels + y * pixbuf->rowstride;
dest = new_pixbuf->pixels + y * new_pixbuf->rowstride;
-
- for (x = 0; x < pixbuf->width; x++) {
- tr = *dest++ = *src++;
- tg = *dest++ = *src++;
- tb = *dest++ = *src++;
-
- if (substitute_color && tr == r && tg == g && tb == b)
- *dest++ = 0;
- else
- *dest++ = 255;
+
+ if (pixbuf->has_alpha) {
+ /* Just subst color, we already copied everything else */
+ for (x = 0; x < pixbuf->width; x++) {
+ if (src[0] == r && src[1] == g && src[2] == b)
+ dest[3] = 0;
+ src += 4;
+ dest += 4;
+ }
+ } else {
+ for (x = 0; x < pixbuf->width; x++) {
+ tr = *dest++ = *src++;
+ tg = *dest++ = *src++;
+ tb = *dest++ = *src++;
+
+ if (substitute_color && tr == r && tg == g && tb == b)
+ *dest++ = 0;
+ else
+ *dest++ = 255;
+ }
}
}
Index: gtk/gtkiconfactory.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkiconfactory.c,v
retrieving revision 1.11
diff -u -u -r1.11 gtkiconfactory.c
--- gtk/gtkiconfactory.c 2001/03/19 22:40:35 1.11
+++ gtk/gtkiconfactory.c 2001/05/08 23:40:32
@@ -297,7 +297,7 @@
if (icon_set)
return icon_set;
-
+
tmp_list = g_slist_next (tmp_list);
}
Index: gtk/gtkmenubar.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkmenubar.c,v
retrieving revision 1.24
diff -u -u -r1.24 gtkmenubar.c
--- gtk/gtkmenubar.c 2001/04/28 00:12:44 1.24
+++ gtk/gtkmenubar.c 2001/05/08 23:40:32
@@ -42,8 +42,8 @@
#define BORDER_SPACING 0
#define CHILD_SPACING 3
+#define DEFAULT_IPADDING 1
-
static void gtk_menu_bar_class_init (GtkMenuBarClass *klass);
static void gtk_menu_bar_size_request (GtkWidget *widget,
GtkRequisition *requisition);
@@ -141,6 +141,16 @@
GTK_TYPE_SHADOW_TYPE,
GTK_SHADOW_OUT,
G_PARAM_READABLE));
+
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_int ("internal_padding",
+ _("Internal padding"),
+ _("Amount of border space between the menubar shadow and the menu items"),
+ 0,
+ G_MAXINT,
+ DEFAULT_IPADDING,
+ G_PARAM_READABLE));
+
}
GtkWidget*
@@ -182,6 +192,7 @@
GList *children;
gint nchildren;
GtkRequisition child_requisition;
+ gint ipadding;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_MENU_BAR (widget));
@@ -189,7 +200,7 @@
requisition->width = 0;
requisition->height = 0;
-
+
if (GTK_WIDGET_VISIBLE (widget))
{
menu_bar = GTK_MENU_BAR (widget);
@@ -227,11 +238,15 @@
}
}
+ gtk_widget_style_get (widget, "internal_padding", &ipadding, NULL);
+
requisition->width += (GTK_CONTAINER (menu_bar)->border_width +
widget->style->xthickness +
+ ipadding +
BORDER_SPACING) * 2;
requisition->height += (GTK_CONTAINER (menu_bar)->border_width +
widget->style->ythickness +
+ ipadding +
BORDER_SPACING) * 2;
if (nchildren > 0)
@@ -250,6 +265,7 @@
GtkAllocation child_allocation;
GtkRequisition child_requisition;
guint offset;
+ gint ipadding;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_MENU_BAR (widget));
@@ -264,15 +280,19 @@
allocation->x, allocation->y,
allocation->width, allocation->height);
+ gtk_widget_style_get (widget, "internal_padding", &ipadding, NULL);
+
if (menu_shell->children)
{
child_allocation.x = (GTK_CONTAINER (menu_bar)->border_width +
widget->style->xthickness +
+ ipadding +
BORDER_SPACING);
offset = child_allocation.x; /* Window edge to menubar start */
child_allocation.y = (GTK_CONTAINER (menu_bar)->border_width +
widget->style->ythickness +
+ ipadding +
BORDER_SPACING);
child_allocation.height = MAX (1, (gint)allocation->height - child_allocation.y * 2);
@@ -319,13 +339,18 @@
if (GTK_WIDGET_DRAWABLE (widget))
{
+ gint border;
+
+ border = GTK_CONTAINER (widget)->border_width;
+
gtk_paint_box (widget->style,
widget->window,
- GTK_STATE_NORMAL,
+ GTK_WIDGET_STATE (widget),
get_shadow_type (GTK_MENU_BAR (widget)),
area, widget, "menubar",
- 0, 0,
- -1,-1);
+ border, border,
+ widget->allocation.width - border,
+ widget->allocation.height - border);
}
}
Index: gtk/gtkstatusbar.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkstatusbar.c,v
retrieving revision 1.27
diff -u -u -r1.27 gtkstatusbar.c
--- gtk/gtkstatusbar.c 2001/03/29 21:17:44 1.27
+++ gtk/gtkstatusbar.c 2001/05/08 23:40:32
@@ -30,6 +30,7 @@
#include "gtksignal.h"
#include "gtkstatusbar.h"
#include "gtkwindow.h"
+#include "gtkintl.h"
typedef struct _GtkStatusbarMsg GtkStatusbarMsg;
@@ -63,6 +64,10 @@
GdkEventButton *event);
static gboolean gtk_statusbar_expose_event (GtkWidget *widget,
GdkEventExpose *event);
+static void gtk_statusbar_size_request (GtkWidget *widget,
+ GtkRequisition *requisition);
+static void gtk_statusbar_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation);
static void gtk_statusbar_create_window (GtkStatusbar *statusbar);
static void gtk_statusbar_destroy_window (GtkStatusbar *statusbar);
@@ -109,8 +114,6 @@
object_class->destroy = gtk_statusbar_destroy;
- widget_class->size_allocate = gtk_statusbar_size_allocate;
-
widget_class->realize = gtk_statusbar_realize;
widget_class->unrealize = gtk_statusbar_unrealize;
widget_class->map = gtk_statusbar_map;
@@ -118,6 +121,9 @@
widget_class->button_press_event = gtk_statusbar_button_press;
widget_class->expose_event = gtk_statusbar_expose_event;
+
+ widget_class->size_request = gtk_statusbar_size_request;
+ widget_class->size_allocate = gtk_statusbar_size_allocate;
class->messages_mem_chunk = g_mem_chunk_new ("GtkStatusBar messages mem chunk",
sizeof (GtkStatusbarMsg),
@@ -145,27 +151,42 @@
GTK_TYPE_NONE, 2,
GTK_TYPE_UINT,
GTK_TYPE_STRING);
+
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_enum ("shadow_type",
+ _("Shadow type"),
+ _("Style of bevel around the statusbar text"),
+ GTK_TYPE_SHADOW_TYPE,
+ GTK_SHADOW_IN,
+ G_PARAM_READABLE));
}
static void
gtk_statusbar_init (GtkStatusbar *statusbar)
{
GtkBox *box;
-
+ GtkShadowType shadow_type;
+
box = GTK_BOX (statusbar);
box->spacing = 2;
box->homogeneous = FALSE;
statusbar->has_resize_grip = TRUE;
+
+ gtk_widget_style_get (GTK_WIDGET (statusbar), "shadow_type", &shadow_type, NULL);
statusbar->frame = gtk_frame_new (NULL);
- gtk_frame_set_shadow_type (GTK_FRAME (statusbar->frame), GTK_SHADOW_IN);
+ gtk_frame_set_shadow_type (GTK_FRAME (statusbar->frame), shadow_type);
gtk_box_pack_start (box, statusbar->frame, TRUE, TRUE, 0);
gtk_widget_show (statusbar->frame);
statusbar->label = gtk_label_new ("");
gtk_misc_set_alignment (GTK_MISC (statusbar->label), 0.0, 0.0);
+ /* don't expand the size request for the label; if we
+ * do that then toplevels weirdly resize
+ */
+ gtk_widget_set_usize (statusbar->label, 1, -1);
gtk_container_add (GTK_CONTAINER (statusbar->frame), statusbar->label);
gtk_widget_show (statusbar->label);
@@ -426,25 +447,6 @@
}
static void
-gtk_statusbar_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- GtkStatusbar *statusbar;
- GdkRectangle rect;
-
- statusbar = GTK_STATUSBAR (widget);
-
- GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
-
- get_grip_rect (statusbar, &rect);
-
- if (statusbar->grip_window)
- gdk_window_move_resize (statusbar->grip_window,
- rect.x, rect.y,
- rect.width, rect.height);
-}
-
-static void
gtk_statusbar_create_window (GtkStatusbar *statusbar)
{
GtkWidget *widget;
@@ -583,7 +585,7 @@
if (statusbar->has_resize_grip)
{
get_grip_rect (statusbar, &rect);
-
+
gtk_paint_resize_grip (widget->style,
widget->window,
GTK_WIDGET_STATE (widget),
@@ -600,4 +602,69 @@
}
return FALSE;
+}
+
+static void
+gtk_statusbar_size_request (GtkWidget *widget,
+ GtkRequisition *requisition)
+{
+ GtkStatusbar *statusbar;
+ GtkShadowType shadow_type;
+
+ statusbar = GTK_STATUSBAR (widget);
+
+ gtk_widget_style_get (GTK_WIDGET (statusbar), "shadow_type", &shadow_type, NULL);
+ gtk_frame_set_shadow_type (GTK_FRAME (statusbar->frame), shadow_type);
+
+ GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
+
+ if (statusbar->has_resize_grip)
+ {
+ GdkRectangle rect;
+
+ /* x, y in the grip rect depend on size allocation, but
+ * w, h do not so this is OK
+ */
+ get_grip_rect (statusbar, &rect);
+
+ requisition->width += rect.width;
+ requisition->height = MAX (requisition->height, rect.height);
+ }
+}
+
+static void
+gtk_statusbar_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ GtkStatusbar *statusbar;
+
+ statusbar = GTK_STATUSBAR (widget);
+
+ if (statusbar->has_resize_grip)
+ {
+ GdkRectangle rect;
+ GtkAllocation hbox_allocation;
+ GtkRequisition saved_req;
+
+ widget->allocation = *allocation; /* get_grip_rect needs this info */
+ get_grip_rect (statusbar, &rect);
+
+ if (statusbar->grip_window)
+ gdk_window_move_resize (statusbar->grip_window,
+ rect.x, rect.y,
+ rect.width, rect.height);
+
+ /* enter the bad hack zone */
+ saved_req = widget->requisition;
+ widget->requisition.width -= rect.width; /* HBox::size_allocate needs this */
+ if (widget->requisition.width < 0)
+ widget->requisition.width = 0;
+ GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
+ widget->requisition = saved_req;
+ }
+ else
+ {
+ /* chain up normally */
+ GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
+ }
}
Index: gtk/gtkstyle.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkstyle.c,v
retrieving revision 1.64
diff -u -u -r1.64 gtkstyle.c
--- gtk/gtkstyle.c 2001/05/01 01:36:33 1.64
+++ gtk/gtkstyle.c 2001/05/08 23:40:32
@@ -2116,103 +2116,188 @@
break;
case GTK_SHADOW_IN:
- gdk_draw_line (window, gc1,
- x, y + height - 1, x + width - 1, y + height - 1);
- gdk_draw_line (window, gc1,
- x + width - 1, y, x + width - 1, y + height - 1);
-
- gdk_draw_line (window, style->bg_gc[state_type],
- x + 1, y + height - 2, x + width - 2, y + height - 2);
- gdk_draw_line (window, style->bg_gc[state_type],
- x + width - 2, y + 1, x + width - 2, y + height - 2);
-
- gdk_draw_line (window, style->black_gc,
- x + 1, y + 1, x + width - 2, y + 1);
- gdk_draw_line (window, style->black_gc,
- x + 1, y + 1, x + 1, y + height - 2);
-
- gdk_draw_line (window, gc2,
- x, y, x + width - 1, y);
- gdk_draw_line (window, gc2,
- x, y, x, y + height - 1);
+ /* Light around right and bottom edge */
+
+ if (style->ythickness > 0)
+ gdk_draw_line (window, gc1,
+ x, y + height - 1, x + width - 1, y + height - 1);
+ if (style->xthickness > 0)
+ gdk_draw_line (window, gc1,
+ x + width - 1, y, x + width - 1, y + height - 1);
+
+ if (style->ythickness > 1)
+ gdk_draw_line (window, style->bg_gc[state_type],
+ x + 1, y + height - 2, x + width - 2, y + height - 2);
+ if (style->xthickness > 1)
+ gdk_draw_line (window, style->bg_gc[state_type],
+ x + width - 2, y + 1, x + width - 2, y + height - 2);
+
+ /* Dark around left and top */
+
+ if (style->ythickness > 1)
+ gdk_draw_line (window, style->black_gc,
+ x + 1, y + 1, x + width - 2, y + 1);
+ if (style->xthickness > 1)
+ gdk_draw_line (window, style->black_gc,
+ x + 1, y + 1, x + 1, y + height - 2);
+
+ if (style->ythickness > 0)
+ gdk_draw_line (window, gc2,
+ x, y, x + width - 1, y);
+ if (style->xthickness > 0)
+ gdk_draw_line (window, gc2,
+ x, y, x, y + height - 1);
break;
case GTK_SHADOW_OUT:
- gdk_draw_line (window, gc1,
- x + 1, y + height - 2, x + width - 2, y + height - 2);
- gdk_draw_line (window, gc1,
- x + width - 2, y + 1, x + width - 2, y + height - 2);
-
- gdk_draw_line (window, gc2,
- x, y, x + width - 1, y);
- gdk_draw_line (window, gc2,
- x, y, x, y + height - 1);
-
- gdk_draw_line (window, style->bg_gc[state_type],
- x + 1, y + 1, x + width - 2, y + 1);
- gdk_draw_line (window, style->bg_gc[state_type],
- x + 1, y + 1, x + 1, y + height - 2);
-
- gdk_draw_line (window, style->black_gc,
- x, y + height - 1, x + width - 1, y + height - 1);
- gdk_draw_line (window, style->black_gc,
- x + width - 1, y, x + width - 1, y + height - 1);
+ /* Dark around right and bottom edge */
+
+ if (style->ythickness > 0)
+ {
+ if (style->ythickness > 1)
+ {
+ gdk_draw_line (window, gc1,
+ x + 1, y + height - 2, x + width - 2, y + height - 2);
+ gdk_draw_line (window, style->black_gc,
+ x, y + height - 1, x + width - 1, y + height - 1);
+ }
+ else
+ {
+ gdk_draw_line (window, gc1,
+ x + 1, y + height - 1, x + width - 1, y + height - 1);
+ }
+ }
+
+ if (style->xthickness > 0)
+ {
+ if (style->xthickness > 1)
+ {
+ gdk_draw_line (window, gc1,
+ x + width - 2, y + 1, x + width - 2, y + height - 2);
+
+ gdk_draw_line (window, style->black_gc,
+ x + width - 1, y, x + width - 1, y + height - 1);
+ }
+ else
+ {
+ gdk_draw_line (window, gc1,
+ x + width - 1, y + 1, x + width - 1, y + height - 1);
+ }
+ }
+
+ /* Light around top and left */
+
+ if (style->ythickness > 0)
+ gdk_draw_line (window, gc2,
+ x, y, x + width - 1, y);
+ if (style->xthickness > 0)
+ gdk_draw_line (window, gc2,
+ x, y, x, y + height - 1);
+
+ if (style->ythickness > 1)
+ gdk_draw_line (window, style->bg_gc[state_type],
+ x + 1, y + 1, x + width - 2, y + 1);
+ if (style->xthickness > 1)
+ gdk_draw_line (window, style->bg_gc[state_type],
+ x + 1, y + 1, x + 1, y + height - 2);
break;
case GTK_SHADOW_ETCHED_IN:
case GTK_SHADOW_ETCHED_OUT:
- thickness_light = 1;
- thickness_dark = 1;
+ if (style->xthickness > 0)
+ {
+ if (style->xthickness > 1)
+ {
+ thickness_light = 1;
+ thickness_dark = 1;
+
+ for (i = 0; i < thickness_dark; i++)
+ {
+ gdk_draw_line (window, gc1,
+ x + width - i - 1,
+ y + i,
+ x + width - i - 1,
+ y + height - i - 1);
+ gdk_draw_line (window, gc2,
+ x + i,
+ y + i,
+ x + i,
+ y + height - i - 2);
+ }
- for (i = 0; i < thickness_dark; i++)
+ for (i = 0; i < thickness_light; i++)
+ {
+ gdk_draw_line (window, gc1,
+ x + thickness_dark + i,
+ y + thickness_dark + i,
+ x + thickness_dark + i,
+ y + height - thickness_dark - i - 1);
+ gdk_draw_line (window, gc2,
+ x + width - thickness_light - i - 1,
+ y + thickness_dark + i,
+ x + width - thickness_light - i - 1,
+ y + height - thickness_light - 1);
+ }
+ }
+ else
+ {
+ gdk_draw_line (window,
+ style->dark_gc[state_type],
+ x, y, x, y + height);
+ gdk_draw_line (window,
+ style->dark_gc[state_type],
+ x + width, y, x + width, y + height);
+ }
+ }
+
+ if (style->ythickness > 0)
{
- gdk_draw_line (window, gc1,
- x + i,
- y + height - i - 1,
- x + width - i - 1,
- y + height - i - 1);
- gdk_draw_line (window, gc1,
- x + width - i - 1,
- y + i,
- x + width - i - 1,
- y + height - i - 1);
+ if (style->ythickness > 1)
+ {
+ thickness_light = 1;
+ thickness_dark = 1;
+
+ for (i = 0; i < thickness_dark; i++)
+ {
+ gdk_draw_line (window, gc1,
+ x + i,
+ y + height - i - 1,
+ x + width - i - 1,
+ y + height - i - 1);
- gdk_draw_line (window, gc2,
- x + i,
- y + i,
- x + width - i - 2,
- y + i);
- gdk_draw_line (window, gc2,
- x + i,
- y + i,
- x + i,
- y + height - i - 2);
- }
+ gdk_draw_line (window, gc2,
+ x + i,
+ y + i,
+ x + width - i - 2,
+ y + i);
+ }
- for (i = 0; i < thickness_light; i++)
- {
- gdk_draw_line (window, gc1,
- x + thickness_dark + i,
- y + thickness_dark + i,
- x + width - thickness_dark - i - 1,
- y + thickness_dark + i);
- gdk_draw_line (window, gc1,
- x + thickness_dark + i,
- y + thickness_dark + i,
- x + thickness_dark + i,
- y + height - thickness_dark - i - 1);
+ for (i = 0; i < thickness_light; i++)
+ {
+ gdk_draw_line (window, gc1,
+ x + thickness_dark + i,
+ y + thickness_dark + i,
+ x + width - thickness_dark - i - 1,
+ y + thickness_dark + i);
- gdk_draw_line (window, gc2,
- x + thickness_dark + i,
- y + height - thickness_light - i - 1,
- x + width - thickness_light - 1,
- y + height - thickness_light - i - 1);
- gdk_draw_line (window, gc2,
- x + width - thickness_light - i - 1,
- y + thickness_dark + i,
- x + width - thickness_light - i - 1,
- y + height - thickness_light - 1);
+ gdk_draw_line (window, gc2,
+ x + thickness_dark + i,
+ y + height - thickness_light - i - 1,
+ x + width - thickness_light - 1,
+ y + height - thickness_light - i - 1);
+ }
+ }
+ else
+ {
+ gdk_draw_line (window,
+ style->dark_gc[state_type],
+ x, y, x + width, y);
+ gdk_draw_line (window,
+ style->dark_gc[state_type],
+ x, y + height, x + width, y + height);
+ }
}
+
break;
}
if (area)
@@ -4152,11 +4237,26 @@
{
gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
+ gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
+ }
+
+ /* make it square, aligning to bottom right */
+ if (width < height)
+ {
+ y += (height - width);
+ height = width;
+ }
+ else if (height < width)
+ {
+ x += (width - height);
+ width = height;
}
- /* make it square */
- if (width != height)
- width = height = MIN (width, height);
+ /* Clear background */
+ gdk_draw_rectangle (window,
+ style->bg_gc[state_type],
+ TRUE,
+ x, y, width, height);
switch (edge)
{
@@ -4204,6 +4304,7 @@
{
gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
+ gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
}
}
Index: gtk/gtktextview.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktextview.c,v
retrieving revision 1.83
diff -u -u -r1.83 gtktextview.c
--- gtk/gtktextview.c 2001/05/07 15:58:46 1.83
+++ gtk/gtktextview.c 2001/05/08 23:40:32
@@ -75,8 +75,6 @@
*
*/
-#define FOCUS_EDGE_WIDTH 1
-
#define SCREEN_WIDTH(widget) text_window_get_width (GTK_TEXT_VIEW (widget)->text_window)
#define SCREEN_HEIGHT(widget) text_window_get_height (GTK_TEXT_VIEW (widget)->text_window)
@@ -2146,11 +2144,20 @@
{
GtkTextView *text_view;
GSList *tmp_list;
-
+ gint focus_edge_width;
+ gboolean interior_focus;
+
text_view = GTK_TEXT_VIEW (widget);
- requisition->width = text_view->text_window->requisition.width + FOCUS_EDGE_WIDTH * 2;
- requisition->height = text_view->text_window->requisition.height + FOCUS_EDGE_WIDTH * 2;
+ gtk_widget_style_get (widget, "interior_focus", &interior_focus, NULL);
+
+ if (interior_focus)
+ focus_edge_width = 0;
+ else
+ focus_edge_width = 1;
+
+ requisition->width = text_view->text_window->requisition.width + focus_edge_width * 2;
+ requisition->height = text_view->text_window->requisition.height + focus_edge_width * 2;
if (text_view->left_window)
requisition->width += text_view->left_window->requisition.width;
@@ -2296,7 +2303,9 @@
GdkRectangle right_rect;
GdkRectangle top_rect;
GdkRectangle bottom_rect;
-
+ gint focus_edge_width;
+ gboolean interior_focus;
+
text_view = GTK_TEXT_VIEW (widget);
DV(g_print(G_STRLOC"\n"));
@@ -2313,8 +2322,15 @@
/* distribute width/height among child windows. Ensure all
* windows get at least a 1x1 allocation.
*/
+
+ gtk_widget_style_get (widget, "interior_focus", &interior_focus, NULL);
- width = allocation->width - FOCUS_EDGE_WIDTH * 2;
+ if (interior_focus)
+ focus_edge_width = 0;
+ else
+ focus_edge_width = 1;
+
+ width = allocation->width - focus_edge_width * 2;
if (text_view->left_window)
left_rect.width = text_view->left_window->requisition.width;
@@ -2336,7 +2352,7 @@
bottom_rect.width = text_rect.width;
- height = allocation->height - FOCUS_EDGE_WIDTH * 2;
+ height = allocation->height - focus_edge_width * 2;
if (text_view->top_window)
top_rect.height = text_view->top_window->requisition.height;
@@ -2358,8 +2374,8 @@
right_rect.height = text_rect.height;
/* Origins */
- left_rect.x = FOCUS_EDGE_WIDTH;
- top_rect.y = FOCUS_EDGE_WIDTH;
+ left_rect.x = focus_edge_width;
+ top_rect.y = focus_edge_width;
text_rect.x = left_rect.x + left_rect.width;
text_rect.y = top_rect.y + top_rect.height;
@@ -3328,10 +3344,15 @@
static void
gtk_text_view_draw_focus (GtkWidget *widget)
{
+ gboolean interior_focus;
+
+ /* We clear the focus if we are in interior focus mode. */
+ gtk_widget_style_get (widget, "interior_focus", &interior_focus, NULL);
+
if (GTK_WIDGET_DRAWABLE (widget))
{
- if (GTK_WIDGET_HAS_FOCUS (widget))
- {
+ if (GTK_WIDGET_HAS_FOCUS (widget) && !interior_focus)
+ {
gtk_paint_focus (widget->style, widget->window,
NULL, widget, "textview",
0, 0,
@@ -5394,16 +5415,26 @@
gint *window_x,
gint *window_y)
{
+ gint focus_edge_width;
+ gboolean interior_focus;
+
+ gtk_widget_style_get (GTK_WIDGET (text_view), "interior_focus", &interior_focus, NULL);
+
+ if (interior_focus)
+ focus_edge_width = 0;
+ else
+ focus_edge_width = 1;
+
if (window_x)
{
- *window_x = buffer_x - text_view->xoffset + FOCUS_EDGE_WIDTH;
+ *window_x = buffer_x - text_view->xoffset + focus_edge_width;
if (text_view->left_window)
*window_x += text_view->left_window->allocation.width;
}
if (window_y)
{
- *window_y = buffer_y - text_view->yoffset + FOCUS_EDGE_WIDTH;
+ *window_y = buffer_y - text_view->yoffset + focus_edge_width;
if (text_view->top_window)
*window_y += text_view->top_window->allocation.height;
}
@@ -5531,16 +5562,26 @@
gint *buffer_x,
gint *buffer_y)
{
+ gint focus_edge_width;
+ gboolean interior_focus;
+
+ gtk_widget_style_get (GTK_WIDGET (text_view), "interior_focus", &interior_focus, NULL);
+
+ if (interior_focus)
+ focus_edge_width = 0;
+ else
+ focus_edge_width = 1;
+
if (buffer_x)
{
- *buffer_x = widget_x - FOCUS_EDGE_WIDTH + text_view->xoffset;
+ *buffer_x = widget_x - focus_edge_width + text_view->xoffset;
if (text_view->left_window)
*buffer_x -= text_view->left_window->allocation.width;
}
if (buffer_y)
{
- *buffer_y = widget_y - FOCUS_EDGE_WIDTH + text_view->yoffset;
+ *buffer_y = widget_y - focus_edge_width + text_view->yoffset;
if (text_view->top_window)
*buffer_y -= text_view->top_window->allocation.height;
}
Index: gtk/gtktoolbar.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktoolbar.c,v
retrieving revision 1.52
diff -u -u -r1.52 gtktoolbar.c
--- gtk/gtktoolbar.c 2001/04/28 00:12:44 1.52
+++ gtk/gtktoolbar.c 2001/05/08 23:40:32
@@ -38,8 +38,9 @@
#include "gtkintl.h"
+#define DEFAULT_IPADDING 0
#define DEFAULT_SPACE_SIZE 5
-#define DEFAULT_SPACE_STYLE GTK_TOOLBAR_SPACE_EMPTY
+#define DEFAULT_SPACE_STYLE GTK_TOOLBAR_SPACE_LINE
#define DEFAULT_ICON_SIZE GTK_ICON_SIZE_LARGE_TOOLBAR
@@ -89,6 +90,7 @@
GtkAllocation *allocation);
static void gtk_toolbar_style_set (GtkWidget *widget,
GtkStyle *prev_style);
+static void gtk_toolbar_show_all (GtkWidget *widget);
static void gtk_toolbar_add (GtkContainer *container,
GtkWidget *widget);
static void gtk_toolbar_remove (GtkContainer *container,
@@ -184,6 +186,7 @@
widget_class->size_request = gtk_toolbar_size_request;
widget_class->size_allocate = gtk_toolbar_size_allocate;
widget_class->style_set = gtk_toolbar_style_set;
+ widget_class->show_all = gtk_toolbar_show_all;
container_class->add = gtk_toolbar_add;
container_class->remove = gtk_toolbar_remove;
@@ -223,7 +226,17 @@
G_MAXINT,
DEFAULT_SPACE_SIZE,
G_PARAM_READABLE));
+
gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_int ("internal_padding",
+ _("Internal padding"),
+ _("Amount of border space between the toolbar shadow and the buttons"),
+ 0,
+ G_MAXINT,
+ DEFAULT_IPADDING,
+ G_PARAM_READABLE));
+
+ gtk_widget_class_install_style_property (widget_class,
g_param_spec_enum ("space_style",
_("Space style"),
_("Whether spacers are vertical lines or just blank"),
@@ -237,7 +250,15 @@
_("Button relief"),
_("Type of bevel around toolbar buttons"),
GTK_TYPE_RELIEF_STYLE,
- GTK_RELIEF_NORMAL,
+ GTK_RELIEF_NONE,
+ G_PARAM_READABLE));
+
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_enum ("shadow_type",
+ _("Shadow type"),
+ _("Style of bevel around the toolbar"),
+ GTK_TYPE_SHADOW_TYPE,
+ GTK_SHADOW_OUT,
G_PARAM_READABLE));
}
@@ -445,15 +466,32 @@
GtkToolbar *toolbar;
GList *children;
GtkToolbarChild *child;
+ gint border_width;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_TOOLBAR (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
+ border_width = GTK_CONTAINER (widget)->border_width;
+
if (GTK_WIDGET_DRAWABLE (widget))
{
+ GtkShadowType shadow_type;
+
toolbar = GTK_TOOLBAR (widget);
+ gtk_widget_style_get (widget, "shadow_type", &shadow_type, NULL);
+
+ gtk_paint_box (widget->style,
+ widget->window,
+ GTK_WIDGET_STATE (widget),
+ shadow_type,
+ &event->area, widget, "toolbar",
+ widget->allocation.x + border_width,
+ widget->allocation.y + border_width,
+ widget->allocation.width - border_width,
+ widget->allocation.height - border_width);
+
for (children = toolbar->children; children; children = children->next)
{
child = children->data;
@@ -485,6 +523,7 @@
gint widget_maxw, widget_maxh;
GtkRequisition child_requisition;
gint space_size;
+ gint ipadding;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_TOOLBAR (widget));
@@ -562,6 +601,12 @@
requisition->height += nbuttons * button_maxh;
}
+ /* Extra spacing */
+ gtk_widget_style_get (widget, "internal_padding", &ipadding, NULL);
+
+ requisition->width += 2 * (widget->style->xthickness + ipadding);
+ requisition->height += 2 * (widget->style->ythickness + ipadding);
+
toolbar->button_maxw = button_maxw;
toolbar->button_maxh = button_maxh;
}
@@ -576,22 +621,29 @@
GtkToolbarChildSpace *child_space;
GtkAllocation alloc;
GtkRequisition child_requisition;
- gint border_width;
+ gint x_border_width, y_border_width;
gint space_size;
-
+ gint ipadding;
+
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_TOOLBAR (widget));
g_return_if_fail (allocation != NULL);
toolbar = GTK_TOOLBAR (widget);
widget->allocation = *allocation;
-
- border_width = GTK_CONTAINER (toolbar)->border_width;
+
+ x_border_width = GTK_CONTAINER (toolbar)->border_width;
+ y_border_width = GTK_CONTAINER (toolbar)->border_width;
+ gtk_widget_style_get (widget, "internal_padding", &ipadding, NULL);
+
+ x_border_width += 2 * (widget->style->xthickness + ipadding);
+ y_border_width += 2 * (widget->style->ythickness + ipadding);
+
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
- alloc.x = allocation->x + border_width;
+ alloc.x = allocation->x + x_border_width;
else
- alloc.y = allocation->y + border_width;
+ alloc.y = allocation->y + y_border_width;
space_size = get_space_size (toolbar);
@@ -681,6 +733,26 @@
}
static void
+child_show_all (GtkWidget *widget)
+{
+ /* Don't show our own children, since that would
+ * show labels we may intend to hide in icons-only mode
+ */
+ if (!g_object_get_data (G_OBJECT (widget),
+ "gtk-toolbar-is-child"))
+ gtk_widget_show_all (widget);
+}
+
+static void
+gtk_toolbar_show_all (GtkWidget *widget)
+{
+ gtk_container_foreach (GTK_CONTAINER (widget),
+ (GtkCallback) child_show_all,
+ NULL);
+ gtk_widget_show (widget);
+}
+
+static void
gtk_toolbar_add (GtkContainer *container,
GtkWidget *widget)
{
@@ -1161,6 +1233,13 @@
gtk_widget_show (child->icon);
}
+ if (type != GTK_TOOLBAR_CHILD_WIDGET)
+ {
+ /* Mark child as ours */
+ g_object_set_data (G_OBJECT (child->widget),
+ "gtk-toolbar-is-child",
+ GINT_TO_POINTER (TRUE));
+ }
gtk_widget_show (child->widget);
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]