Patches for #46238
- From: Federico Mena Quintero <federico ximian com>
- To: nautilus-list gnome org
- Subject: Patches for #46238
- Date: 18 Jul 2002 16:13:46 -0500
Hi,
I've made a number of changes to fix #46238, and would be grateful if
people could review them. The patches are attached with their
ChangeLogs.
Also, there is a new gnome.xml file for
$(prefix)/share/pixmaps/nautilus/gnome/. This theme description file is
the same as the original one, except for the hardcoded colors which I
removed. This makes the sidebar and the icon view follow the GTK+
theme.
Note that with this, some of the Nautilus widgets get backgrounds that
you don't expect - they should be using something other than
style->bg[foo], perhaps style->base[foo]. But those are separate bugs.
Federico
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/eel/ChangeLog,v
retrieving revision 1.424
diff -u -r1.424 ChangeLog
--- ChangeLog 18 Jul 2002 05:53:14 -0000 1.424
+++ ChangeLog 18 Jul 2002 21:04:15 -0000
@@ -1,3 +1,20 @@
+2002-07-18 Federico Mena Quintero <federico ximian com>
+
+ Fixes the eel part of #46238; see Nautilus for the rest of the fix.
+
+ * eel/eel-background.c (eel_background_ensure_realized): If we
+ fail to parse the color spec, don't default to white. Instead use
+ the background color from the widget's style.
+ (widget_style_set_cb): New callback for the widget's "style_set"
+ signal. We regenerate the background and its style when the theme
+ changes.
+ (eel_background_set_widget_style): We need a little hack here to
+ unset the GTK_USER_STYLE flag because otherwise we will not be
+ notified of theme changes through the "style_set" signal. The
+ real solution is not to use a style of our own, but rather paint
+ the widget by hand when needed.
+ (eel_background_init): Start with is_solid_color = TRUE.
+
2002-07-17 Frank Worsley <fworsley shaw ca>
* eel/eel-gtk-extensions.c:
Index: eel/eel-background.c
===================================================================
RCS file: /cvs/gnome/eel/eel/eel-background.c,v
retrieving revision 1.33
diff -u -r1.33 eel-background.c
--- eel/eel-background.c 11 May 2002 23:37:51 -0000 1.33
+++ eel/eel-background.c 18 Jul 2002 21:04:15 -0000
@@ -33,6 +33,7 @@
#include "eel-gtk-macros.h"
#include "eel-lib-self-check-functions.h"
#include "eel-string.h"
+#include <gtk/gtkprivate.h>
#include <gtk/gtkselection.h>
#include <gtk/gtksignal.h>
#include <libart_lgpl/art_rgb.h>
@@ -104,6 +105,11 @@
int background_entire_height;
GdkColor background_color;
gboolean background_changes_with_size;
+
+ /* Whether we should respond to style_set; turned off while setting the
+ * style ourselves.
+ */
+ guint respond_to_style_set : 1;
};
static void
@@ -169,6 +175,8 @@
background->details = g_new0 (EelBackgroundDetails, 1);
background->details->constant_size = FALSE;
+ background->details->is_solid_color = TRUE;
+ background->details->respond_to_style_set = TRUE;
}
/* The safe way to clear an image from a background is:
@@ -634,13 +642,30 @@
eel_background_ensure_realized (EelBackground *background, GdkWindow *window,
int entire_width, int entire_height)
{
+ GdkColor color;
int pixmap_width, pixmap_height;
char *start_color_spec;
GdkPixmap *pixmap;
GdkGC *gc;
+ /* Try to parse the color spec. If we fail, default to the style's color */
+
start_color_spec = eel_gradient_get_start_color_spec (background->details->color);
- eel_gdk_color_parse_with_white_default (start_color_spec, &background->details->background_color);
+
+ if (start_color_spec && eel_gdk_color_parse (start_color_spec, &color))
+ background->details->background_color = color;
+ else {
+ GtkWidget *widget;
+ GtkStyle *style;
+
+ /* Get the widget to which the window belongs and its style as well */
+ gdk_window_get_user_data (window, (void **) &widget);
+ g_assert (widget != NULL);
+
+ style = gtk_widget_get_style (widget);
+ background->details->background_color = style->bg[GTK_WIDGET_STATE (widget)];
+ }
+
g_free (start_color_spec);
/* If the pixmap doesn't change with the window size, never update
@@ -1133,6 +1158,7 @@
GtkWidget *widget)
{
GtkStyle *style;
+ gboolean old_respond_value;
g_return_if_fail (EEL_IS_BACKGROUND (background));
g_return_if_fail (GTK_IS_WIDGET (widget));
@@ -1142,8 +1168,18 @@
/* Bad hack to make font changing work: */
eel_background_set_style_font_from_default (style, gtk_widget_get_settings (widget));
-
+
+ old_respond_value = background->details->respond_to_style_set;
+ background->details->respond_to_style_set = FALSE;
gtk_widget_set_style (widget, style);
+ /* HACK: unset the USER_STYLE flag because otherwise we will not be
+ * notified of theme changes through the "style_set" signal. The real
+ * solution is not to use a style of our own, but rather paint the
+ * widget by hand when needed.
+ */
+ GTK_PRIVATE_UNSET_FLAG (widget, GTK_USER_STYLE);
+ background->details->respond_to_style_set = old_respond_value;
+
g_object_unref (style);
}
@@ -1292,6 +1328,7 @@
{
EelBackground *background;
GtkStyle *style;
+ gboolean old_respond_value;
background = eel_get_widget_background (widget);
@@ -1299,10 +1336,36 @@
eel_background_set_style_font_from_default (style, settings);
+ old_respond_value = background->details->respond_to_style_set;
+ background->details->respond_to_style_set = FALSE;
gtk_widget_set_style (widget, style);
+ /* HACK: unset the USER_STYLE flag because otherwise we will not be
+ * notified of theme changes through the "style_set" signal. The real
+ * solution is not to use a style of our own, but rather paint the
+ * widget by hand when needed.
+ */
+ GTK_PRIVATE_UNSET_FLAG (widget, GTK_USER_STYLE);
+ background->details->respond_to_style_set = old_respond_value;
+
g_object_unref (style);
}
+/* Callback used when the style of a widget changes. We have to regenerate its
+ * EelBackgroundStyle so that it will match the chosen GTK+ theme.
+ */
+static void
+widget_style_set_cb (GtkWidget *widget, GtkStyle *previous_style, gpointer data)
+{
+ EelBackground *background;
+
+ background = EEL_BACKGROUND (data);
+
+ if (!background->details->respond_to_style_set)
+ return;
+
+ eel_widget_background_changed (widget, background);
+}
+
/* Gets the background attached to a widget.
If the widget doesn't already have a EelBackground object,
@@ -1344,6 +1407,11 @@
settings = gtk_widget_get_settings (widget);
g_signal_connect_object (settings, "notify::gtk-font-name",
G_CALLBACK (eel_widget_font_changed), widget, G_CONNECT_SWAPPED);
+
+ g_signal_connect (widget, "style_set",
+ G_CALLBACK (widget_style_set_cb),
+ background);
+
return background;
}
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.5446
diff -u -r1.5446 ChangeLog
--- ChangeLog 18 Jul 2002 05:58:16 -0000 1.5446
+++ ChangeLog 18 Jul 2002 21:06:50 -0000
@@ -1,3 +1,25 @@
+2002-07-18 Federico Mena Quintero <federico ximian com>
+
+ Fixes the Nautilus part of #46238; see eel for the other part.
+
+ * components/hardware/nautilus-hardware-view.c
+ (nautilus_hardware_view_init): Do not set a hardcoded background
+ color; just use the color from the GTK+ theme. We still set up
+ the EelBackground as this handles dragged colors, but it does not
+ save them anywhere.
+
+ * components/notes/nautilus-notes.c (make_notes_view): Do not set
+ up an EelBackground at all for the text view; just let it use the
+ default color from the GTK+ theme. This code did not handle
+ dragged colors or anything, anyways.
+
+ * src/nautilus-property-browser.c
+ (nautilus_property_browser_init): Do not set a hardcoded
+ background color.
+
+ * src/nautilus-sidebar.c (nautilus_sidebar_style_set):
+ ::style_set() handler; we act as if the theme changed.
+
2002-07-17 Frank Worsley <fworsley shaw ca>
* src/nautilus-application.c: (save_window_geometry_timeout),
Index: components/hardware/nautilus-hardware-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/components/hardware/nautilus-hardware-view.c,v
retrieving revision 1.54
diff -u -r1.54 nautilus-hardware-view.c
--- components/hardware/nautilus-hardware-view.c 17 Apr 2002 13:46:11 -0000 1.54
+++ components/hardware/nautilus-hardware-view.c 18 Jul 2002 21:06:50 -0000
@@ -95,8 +95,6 @@
EEL_CLASS_BOILERPLATE (NautilusHardwareView, nautilus_hardware_view, GTK_TYPE_EVENT_BOX)
-#define HARDWARE_DEFAULT_BACKGROUND_COLOR "#DDDDBB"
-
static void
nautilus_hardware_view_class_init (NautilusHardwareViewClass *klass)
{
@@ -162,7 +160,6 @@
G_CALLBACK (hardware_view_load_location_callback), hardware_view, 0);
background = eel_get_widget_background (GTK_WIDGET (hardware_view));
- eel_background_set_color (background, HARDWARE_DEFAULT_BACKGROUND_COLOR);
/* prepare ourselves to receive dropped objects */
gtk_drag_dest_set (GTK_WIDGET (hardware_view),
Index: components/notes/nautilus-notes.c
===================================================================
RCS file: /cvs/gnome/nautilus/components/notes/nautilus-notes.c,v
retrieving revision 1.85
diff -u -r1.85 nautilus-notes.c
--- components/notes/nautilus-notes.c 21 May 2002 11:27:22 -0000 1.85
+++ components/notes/nautilus-notes.c 18 Jul 2002 21:06:50 -0000
@@ -29,7 +29,6 @@
#include <config.h>
-#include <eel/eel-background.h>
#include <eel/eel-debug.h>
#include <eel/eel-gtk-extensions.h>
#include <eel/eel-string.h>
@@ -54,8 +53,6 @@
#include <libnautilus-private/nautilus-undo-signal-handlers.h>
#endif
-#define NOTES_DEFAULT_BACKGROUND_COLOR "#FFFFBB"
-
#define SAVE_TIMEOUT (3 * 1000)
/* property bag getting and setting routines */
@@ -358,7 +355,6 @@
{
GtkWidget *vbox;
Notes *notes;
- EelBackground *background;
notes = g_new0 (Notes, 1);
notes->uri = g_strdup ("");
@@ -378,9 +374,6 @@
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (notes->note_text_field),
GTK_WRAP_WORD);
gtk_box_pack_start (GTK_BOX (vbox), notes->note_text_field, TRUE, TRUE, 0);
-
- background = eel_get_widget_background (notes->note_text_field);
- eel_background_set_color (background, NOTES_DEFAULT_BACKGROUND_COLOR);
g_signal_connect (notes->note_text_field, "focus_out_event",
G_CALLBACK (on_text_field_focus_out_event), notes);
Index: src/nautilus-property-browser.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-property-browser.c,v
retrieving revision 1.190
diff -u -r1.190 nautilus-property-browser.c
--- src/nautilus-property-browser.c 9 Jul 2002 08:48:13 -0000 1.190
+++ src/nautilus-property-browser.c 18 Jul 2002 21:06:51 -0000
@@ -32,7 +32,6 @@
#include "nautilus-property-browser.h"
#include "nautilus-signaller.h"
-#include <eel/eel-background.h>
#include <eel/eel-gdk-extensions.h>
#include <eel/eel-gdk-pixbuf-extensions.h>
#include <eel/eel-glib-extensions.h>
@@ -190,10 +189,6 @@
gpointer callback_data);
-#define BROWSER_BACKGROUND_COLOR "#FFFFFF"
-
-#define THEME_SELECT_COLOR "#FF9999"
-
#define BROWSER_CATEGORIES_FILE_NAME "browser.xml"
#define PROPERTY_BROWSER_WIDTH 540
@@ -273,7 +268,6 @@
gtk_window_set_title (GTK_WINDOW (widget), _("Backgrounds and Emblems"));
gtk_window_set_wmclass (GTK_WINDOW (widget), "property_browser", "Nautilus");
eel_gtk_window_set_up_close_accelerator (GTK_WINDOW (widget));
-
/* create the main vbox. */
vbox = gtk_vbox_new (FALSE, 0);
@@ -1961,7 +1955,6 @@
{
xmlNodePtr cur_node;
xmlDocPtr document;
- EelBackground *background;
GtkWidget *viewport;
GtkRadioButton *group;
gboolean got_categories;
@@ -1985,8 +1978,6 @@
viewport = gtk_viewport_new (NULL, NULL);
gtk_widget_show(viewport);
gtk_viewport_set_shadow_type(GTK_VIEWPORT(viewport), GTK_SHADOW_IN);
- background = eel_get_widget_background (viewport);
- eel_background_set_color (background, BROWSER_BACKGROUND_COLOR);
gtk_container_add (GTK_CONTAINER (property_browser->details->content_container), property_browser->details->content_frame);
gtk_widget_show (property_browser->details->content_frame);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (property_browser->details->content_frame),
Index: src/nautilus-sidebar.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-sidebar.c,v
retrieving revision 1.212
diff -u -r1.212 nautilus-sidebar.c
--- src/nautilus-sidebar.c 10 Jul 2002 16:23:34 -0000 1.212
+++ src/nautilus-sidebar.c 18 Jul 2002 21:06:51 -0000
@@ -38,6 +38,7 @@
#include <bonobo/bonobo-exception.h>
#include <eel/eel-background.h>
+#include <eel/eel-background-style.h>
#include <eel/eel-glib-extensions.h>
#include <eel/eel-gtk-extensions.h>
#include <eel/eel-gtk-macros.h>
@@ -122,6 +123,8 @@
static void nautilus_sidebar_read_theme (NautilusSidebar *sidebar);
static void nautilus_sidebar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
+static void nautilus_sidebar_style_set (GtkWidget *widget,
+ GtkStyle *previous_style);
static void nautilus_sidebar_theme_changed (gpointer user_data);
static void nautilus_sidebar_confirm_trash_changed (gpointer user_data);
static void nautilus_sidebar_update_appearance (NautilusSidebar *sidebar);
@@ -200,6 +203,7 @@
widget_class->button_press_event = nautilus_sidebar_press_event;
widget_class->button_release_event = nautilus_sidebar_release_event;
widget_class->size_allocate = nautilus_sidebar_size_allocate;
+ widget_class->style_set = nautilus_sidebar_style_set;
/* add the "location changed" signal */
signals[LOCATION_CHANGED] = g_signal_new
@@ -1704,6 +1708,22 @@
eel_preferences_set_integer (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH,
widget->allocation.width);
}
+}
+
+/* ::style_set handler for the sidebar */
+static void
+nautilus_sidebar_style_set (GtkWidget *widget, GtkStyle *previous_style)
+{
+ NautilusSidebar *sidebar;
+ GtkStyle *style;
+
+ sidebar = NAUTILUS_SIDEBAR (widget);
+
+ style = gtk_widget_get_style (widget);
+
+ /* This is slightly hackish */
+ if (!EEL_IS_BACKGROUND_STYLE (style))
+ nautilus_sidebar_theme_changed (sidebar);
}
void
<?xml version="1.0"?>
<theme _name="Federico" _description="A theme designed to fit well with the classic GNOME environment.">
<sidebar tab_piece_images="sidebar_tab_pieces" combine="true"
left_offset="0" shadow_offset="1" text_h_offset="-4"/>
<desktop background_tile_image="patterns/dark-gnome.jpg"
background_color="#:F400/F200/e800"/>
<thumbnails frame_offsets="3,3,6,6"/>
<toolbar icon_theme="standard"/>
<throbber frame_count="6" url="http://www.gnome.org"/>
<zoom_control number_v_offset="0" number_v_2_offset="-1" number_h_offset="-2"/>
</theme>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]