eel r2207 - in trunk: . eel test
- From: tbzatek svn gnome org
- To: svn-commits-list gnome org
- Subject: eel r2207 - in trunk: . eel test
- Date: Mon, 23 Feb 2009 11:27:13 +0000 (UTC)
Author: tbzatek
Date: Mon Feb 23 11:27:13 2009
New Revision: 2207
URL: http://svn.gnome.org/viewvc/eel?rev=2207&view=rev
Log:
2009-02-23 Tomas Bzatek <tbzatek redhat com>
* eel/eel-background.c: (on_bg_changed), (on_bg_transitioned),
(eel_background_init), (free_fade), (eel_background_finalize),
(eel_background_ensure_realized), (set_root_pixmap),
(fade_to_pixmap), (eel_background_set_up_widget),
(on_background_changed), (init_fade),
(eel_widget_queue_background_change), (widget_style_set_cb),
(widget_realized_setup), (on_widget_destroyed),
(eel_get_widget_background):
* eel/eel-debug-drawing.c:
(eel_debug_show_pixbuf_in_external_viewer):
* eel/eel-editable-label.c: (eel_editable_label_move_cursor):
* eel/eel-gtk-extensions.c: (eel_gtk_menu_tool_button_get_button):
* eel/eel-gtk-extensions.h:
* eel/eel.h:
Backport from nautilus/eel
Modified:
trunk/ChangeLog
trunk/eel/eel-background.c
trunk/eel/eel-debug-drawing.c
trunk/eel/eel-editable-label.c
trunk/eel/eel-gtk-extensions.c
trunk/eel/eel-gtk-extensions.h
trunk/eel/eel.h
trunk/test/test-eel-image-table.c
Modified: trunk/eel/eel-background.c
==============================================================================
--- trunk/eel/eel-background.c (original)
+++ trunk/eel/eel-background.c Mon Feb 23 11:27:13 2009
@@ -53,6 +53,9 @@
gboolean *changes_with_size);
static void set_image_properties (EelBackground *background);
+static void init_fade (EelBackground *background, GtkWidget *widget);
+static void free_fade (EelBackground *background);
+
EEL_CLASS_BOILERPLATE (EelBackground, eel_background, GTK_TYPE_OBJECT)
enum {
@@ -73,10 +76,12 @@
char *color;
GnomeBG *bg;
+ GtkWidget *widget;
/* Realized data: */
gboolean background_changes_with_size;
GdkPixmap *background_pixmap;
+ GnomeBGCrossfade *fade;
int background_entire_width;
int background_entire_height;
GdkColor default_color;
@@ -89,6 +94,7 @@
gulong screen_size_handler;
/* Can we use common pixmap for root window and desktop window */
gboolean use_common_pixmap;
+ guint change_idle_id;
};
static void
@@ -137,6 +143,15 @@
static void
on_bg_changed (GnomeBG *bg, EelBackground *background)
{
+ init_fade (background, background->details->widget);
+ g_signal_emit (G_OBJECT (background),
+ signals[APPEARANCE_CHANGED], 0);
+}
+
+static void
+on_bg_transitioned (GnomeBG *bg, EelBackground *background)
+{
+ free_fade (background);
g_signal_emit (G_OBJECT (background),
signals[APPEARANCE_CHANGED], 0);
}
@@ -156,6 +171,8 @@
g_signal_connect (background->details->bg, "changed",
G_CALLBACK (on_bg_changed), background);
+ g_signal_connect (background->details->bg, "transitioned",
+ G_CALLBACK (on_bg_transitioned), background);
}
@@ -174,6 +191,15 @@
}
static void
+free_fade (EelBackground *background)
+{
+ if (background->details->fade != NULL) {
+ g_object_unref (background->details->fade);
+ background->details->fade = NULL;
+ }
+}
+
+static void
eel_background_finalize (GObject *object)
{
EelBackground *background;
@@ -188,6 +214,8 @@
background->details->background_pixmap = NULL;
}
+ free_fade (background);
+
g_free (background->details);
EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
@@ -346,6 +374,10 @@
entire_width, entire_height,
background->details->is_desktop);
+ /* We got the pixmap and everything, so we don't care about a change
+ that is pending (unless things actually change after this time) */
+ g_object_set_data (G_OBJECT (background->details->bg),
+ "ignore-pending-change", GINT_TO_POINTER (TRUE));
changed = TRUE;
@@ -610,11 +642,65 @@
}
static void
+set_root_pixmap (EelBackground *background,
+ GdkWindow *window)
+{
+ GdkPixmap *pixmap, *root_pixmap;
+ GdkScreen *screen;
+ GdkColor color;
+ gboolean changes_with_size;
+
+ pixmap = eel_background_get_pixmap_and_color (background,
+ window,
+ &color,
+ &changes_with_size);
+ screen = gdk_drawable_get_screen (window);
+
+ if (background->details->use_common_pixmap) {
+ root_pixmap = g_object_ref (pixmap);
+ } else {
+ root_pixmap = gnome_bg_create_pixmap (background->details->bg, window,
+ gdk_screen_get_width (screen), gdk_screen_get_height (screen), TRUE);
+ }
+
+ gnome_bg_set_pixmap_as_root (screen, pixmap);
+
+ g_object_unref (pixmap);
+ g_object_unref (root_pixmap);
+}
+
+static gboolean
+fade_to_pixmap (EelBackground *background,
+ GdkWindow *window,
+ GdkPixmap *pixmap)
+{
+ if (background->details->fade == NULL) {
+ return FALSE;
+ }
+
+ if (!gnome_bg_crossfade_set_end_pixmap (background->details->fade,
+ pixmap)) {
+ return FALSE;
+ }
+
+ if (!gnome_bg_crossfade_is_started (background->details->fade)) {
+ gnome_bg_crossfade_start (background->details->fade, window);
+ if (background->details->is_desktop) {
+ g_signal_connect_swapped (background->details->fade,
+ "finished",
+ G_CALLBACK (set_root_pixmap), background);
+ }
+ }
+
+ return gnome_bg_crossfade_is_started (background->details->fade);
+}
+
+
+static void
eel_background_set_up_widget (EelBackground *background, GtkWidget *widget)
{
GtkStyle *style;
GdkPixmap *pixmap;
- GdkPixmap *root_pixmap;
GdkColor color;
int window_width;
@@ -622,6 +708,7 @@
GdkWindow *window;
gboolean changes_with_size;
+ gboolean in_fade;
if (!GTK_WIDGET_REALIZED (widget)) {
return;
@@ -644,30 +731,26 @@
window = widget->window;
}
+ if (background->details->fade != NULL) {
+ in_fade = fade_to_pixmap (background, window, pixmap);
+ } else {
+ in_fade = FALSE;
+ }
+
+ if (!in_fade) {
if (!changes_with_size || background->details->is_desktop) {
gdk_window_set_back_pixmap (window, pixmap, FALSE);
} else {
gdk_window_set_back_pixmap (window, NULL, FALSE);
gdk_window_set_background (window, &color);
}
+ }
-
background->details->background_changes_with_size =
gnome_bg_changes_with_size (background->details->bg);
- if (background->details->is_desktop) {
-
- root_pixmap = NULL;
-
- if (background->details->use_common_pixmap) {
- root_pixmap = g_object_ref (pixmap);
- } else {
- root_pixmap = gnome_bg_create_pixmap (background->details->bg, window,
- window_width, window_height, TRUE);
- }
-
- gnome_bg_set_pixmap_as_root (gdk_drawable_get_screen (window), root_pixmap);
- g_object_unref (root_pixmap);
+ if (background->details->is_desktop && !in_fade) {
+ set_root_pixmap (background, window);
}
if (pixmap) {
@@ -675,13 +758,73 @@
}
}
-static void
-eel_widget_background_changed (GtkWidget *widget, EelBackground *background)
+static gboolean
+on_background_changed (EelBackground *background)
{
+ if (background->details->change_idle_id == 0) {
+ return FALSE;
+ }
+
+ background->details->change_idle_id = 0;
+
eel_background_unrealize (background);
- eel_background_set_up_widget (background, widget);
+ eel_background_set_up_widget (background, background->details->widget);
+
+ gtk_widget_queue_draw (background->details->widget);
- gtk_widget_queue_draw (widget);
+ return FALSE;
+}
+
+static void
+init_fade (EelBackground *background, GtkWidget *widget)
+{
+ if (widget == NULL || !GTK_WIDGET_REALIZED (widget))
+ return;
+
+ if (background->details->fade == NULL) {
+ int old_width, old_height, width, height;
+
+ /* If this was the result of a screen size change,
+ * we don't want to crossfade
+ */
+ gdk_drawable_get_size (widget->window, &old_width, &old_height);
+ drawable_get_adjusted_size (background, widget->window,
+ &width, &height);
+ if (old_width == width && old_height == height) {
+ background->details->fade = gnome_bg_crossfade_new (width, height);
+ g_signal_connect_swapped (background->details->fade,
+ "finished",
+ G_CALLBACK (free_fade),
+ background);
+ }
+ }
+
+ if (background->details->fade != NULL && !gnome_bg_crossfade_is_started (background->details->fade)) {
+ GdkPixmap *start_pixmap;
+
+ if (background->details->background_pixmap == NULL) {
+ start_pixmap = gnome_bg_get_pixmap_from_root (gtk_widget_get_screen (widget));
+ } else {
+ start_pixmap = g_object_ref (background->details->background_pixmap);
+ }
+ gnome_bg_crossfade_set_start_pixmap (background->details->fade,
+ start_pixmap);
+ g_object_unref (start_pixmap);
+ }
+}
+
+static void
+eel_widget_queue_background_change (GtkWidget *widget)
+{
+ EelBackground *background;
+
+ background = eel_get_widget_background (widget);
+
+ if (background->details->change_idle_id > 0) {
+ return;
+ }
+
+ background->details->change_idle_id = g_idle_add ((GSourceFunc) on_background_changed, background);
}
/* Callback used when the style of a widget changes. We have to regenerate its
@@ -694,7 +837,7 @@
background = EEL_BACKGROUND (data);
- eel_widget_background_changed (widget, background);
+ eel_widget_queue_background_change (widget);
}
static void
@@ -733,6 +876,8 @@
} else {
background->details->use_common_pixmap = FALSE;
}
+
+ init_fade (background, widget);
}
}
@@ -780,6 +925,17 @@
return background->details->is_desktop;
}
+static void
+on_widget_destroyed (GtkWidget *widget, EelBackground *background)
+{
+ if (background->details->change_idle_id != 0) {
+ g_source_remove (background->details->change_idle_id);
+ background->details->change_idle_id = 0;
+ }
+
+ background->details->widget = NULL;
+}
+
/* Gets the background attached to a widget.
If the widget doesn't already have a EelBackground object,
@@ -815,11 +971,13 @@
gtk_object_sink (GTK_OBJECT (background));
g_object_set_data_full (G_OBJECT (widget), "eel_background",
background, g_object_unref);
+ background->details->widget = widget;
+ g_signal_connect_object (widget, "destroy", G_CALLBACK (on_widget_destroyed), background, 0);
/* Arrange to get the signal whenever the background changes. */
g_signal_connect_object (background, "appearance_changed",
- G_CALLBACK (eel_widget_background_changed), widget, G_CONNECT_SWAPPED);
- eel_widget_background_changed (widget, background);
+ G_CALLBACK (eel_widget_queue_background_change), widget, G_CONNECT_SWAPPED);
+ eel_widget_queue_background_change (widget);
g_signal_connect_object (widget, "style_set",
G_CALLBACK (widget_style_set_cb),
Modified: trunk/eel/eel-debug-drawing.c
==============================================================================
--- trunk/eel/eel-debug-drawing.c (original)
+++ trunk/eel/eel-debug-drawing.c Mon Feb 23 11:27:13 2009
@@ -285,15 +285,19 @@
char *file_name;
gboolean save_result;
int ignore;
+ int fd;
g_return_if_fail (pixbuf != NULL);
g_return_if_fail (viewer_name != NULL);
file_name = g_strdup ("/tmp/eel-debug-png-file-XXXXXX");
- if (mktemp (file_name) != file_name) {
+ fd = g_mkstemp (file_name);
+ if (fd == -1) {
g_free (file_name);
file_name = g_strdup_printf ("/tmp/isis-debug-png-file-%d", getpid ());
+ } else {
+ close (fd);
}
save_result = eel_gdk_pixbuf_save_to_file (pixbuf, file_name);
Modified: trunk/eel/eel-editable-label.c
==============================================================================
--- trunk/eel/eel-editable-label.c (original)
+++ trunk/eel/eel-editable-label.c Mon Feb 23 11:27:13 2009
@@ -2897,11 +2897,11 @@
}
if (extend_selection)
- eel_editable_label_select_region_index (label,
- label->selection_anchor,
- new_pos);
+ gtk_editable_select_region (GTK_EDITABLE (label),
+ label->selection_anchor,
+ new_pos);
else
- eel_editable_label_select_region_index (label, new_pos, new_pos);
+ gtk_editable_set_position (GTK_EDITABLE (label), new_pos);
}
static void
Modified: trunk/eel/eel-gtk-extensions.c
==============================================================================
--- trunk/eel/eel-gtk-extensions.c (original)
+++ trunk/eel/eel-gtk-extensions.c Mon Feb 23 11:27:13 2009
@@ -436,6 +436,26 @@
g_list_free (children);
}
+GtkWidget *
+eel_gtk_menu_tool_button_get_button (GtkMenuToolButton *tool_button)
+{
+ GtkContainer *container;
+ GList *children;
+ GtkWidget *button;
+
+ g_return_val_if_fail (GTK_IS_MENU_TOOL_BUTTON (tool_button), NULL);
+
+ /* The menu tool button's button is the first child
+ * of the child hbox. */
+ container = GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (tool_button)));
+ children = gtk_container_get_children (container);
+ button = GTK_WIDGET (children->data);
+
+ g_list_free (children);
+
+ return button;
+}
+
gboolean
eel_point_in_allocation (const GtkAllocation *allocation,
int x, int y)
Modified: trunk/eel/eel-gtk-extensions.h
==============================================================================
--- trunk/eel/eel-gtk-extensions.h (original)
+++ trunk/eel/eel-gtk-extensions.h Mon Feb 23 11:27:13 2009
@@ -111,6 +111,9 @@
int index,
gboolean visible);
+/* GtkMenuToolButton */
+GtkWidget * eel_gtk_menu_tool_button_get_button (GtkMenuToolButton *tool_button);
+
/* GtkLabel */
void eel_gtk_label_make_bold (GtkLabel *label);
void eel_gtk_label_set_scale (GtkLabel *label,
Modified: trunk/eel/eel.h
==============================================================================
--- trunk/eel/eel.h (original)
+++ trunk/eel/eel.h Mon Feb 23 11:27:13 2009
@@ -29,7 +29,6 @@
#include <eel/eel-art-gtk-extensions.h>
#include <eel/eel-background.h>
#include <eel/eel-enumeration.h>
-#include <eel/eel-features.h>
#include <eel/eel-gconf-extensions.h>
#include <eel/eel-gdk-extensions.h>
#include <eel/eel-gdk-pixbuf-extensions.h>
Modified: trunk/test/test-eel-image-table.c
==============================================================================
--- trunk/test/test-eel-image-table.c (original)
+++ trunk/test/test-eel-image-table.c Mon Feb 23 11:27:13 2009
@@ -2,8 +2,9 @@
#include <eel/eel-image-table.h>
#include <gtk/gtk.h>
+#include <stdlib.h>
-static const char pixbuf_name[] = "/usr/share/pixmaps/gnome-globe.png";
+static const char pixbuf_name[] = "/usr/share/pixmaps/gnome-about-logo.png";
#define BG_COLOR 0xFFFFFF
#define BG_COLOR_SPEC "white"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]