aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@it.gnome.org>2003-02-06 22:58:30 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-02-06 22:58:30 +0800
commit27bdb80c00c3648be780bb53f47e7885749613e7 (patch)
tree3b955c3f154e6935bebced2b53755d5cdde38836
parenteb7eaf060f2a2b08d80b50a103919ea3c1012a00 (diff)
downloadgsoc2013-epiphany-27bdb80c00c3648be780bb53f47e7885749613e7.tar
gsoc2013-epiphany-27bdb80c00c3648be780bb53f47e7885749613e7.tar.gz
gsoc2013-epiphany-27bdb80c00c3648be780bb53f47e7885749613e7.tar.bz2
gsoc2013-epiphany-27bdb80c00c3648be780bb53f47e7885749613e7.tar.lz
gsoc2013-epiphany-27bdb80c00c3648be780bb53f47e7885749613e7.tar.xz
gsoc2013-epiphany-27bdb80c00c3648be780bb53f47e7885749613e7.tar.zst
gsoc2013-epiphany-27bdb80c00c3648be780bb53f47e7885749613e7.zip
Do not use a button for spinner. Correctly update spinner size for toolbar
2003-02-06 Marco Pesenti Gritti <marco@it.gnome.org> * lib/widgets/ephy-spinner.c: (ephy_spinner_expose), (ephy_spinner_class_init): * src/ephy-spinner-action.c: (create_tool_item), (toolbar_style_sync), (item_parent_set_cb), (connect_proxy): Do not use a button for spinner. Correctly update spinner size for toolbar style.
-rw-r--r--ChangeLog10
-rw-r--r--lib/widgets/ephy-spinner.c214
-rw-r--r--src/ephy-spinner-action.c47
3 files changed, 50 insertions, 221 deletions
diff --git a/ChangeLog b/ChangeLog
index 547cd6dc0..5b37d0770 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2003-02-06 Marco Pesenti Gritti <marco@it.gnome.org>
+ * lib/widgets/ephy-spinner.c: (ephy_spinner_expose),
+ (ephy_spinner_class_init):
+ * src/ephy-spinner-action.c: (create_tool_item),
+ (toolbar_style_sync), (item_parent_set_cb), (connect_proxy):
+
+ Do not use a button for spinner.
+ Correctly update spinner size for toolbar style.
+
+2003-02-06 Marco Pesenti Gritti <marco@it.gnome.org>
+
* lib/widgets/ephy-location-entry.c:
(ephy_location_entry_clear_history):
* lib/widgets/ephy-location-entry.h:
diff --git a/lib/widgets/ephy-spinner.c b/lib/widgets/ephy-spinner.c
index ba5aee66d..7e3b4f40d 100644
--- a/lib/widgets/ephy-spinner.c
+++ b/lib/widgets/ephy-spinner.c
@@ -57,9 +57,6 @@ struct EphySpinnerDetails {
gboolean ready;
gboolean small_mode;
- gboolean button_in;
- gboolean button_down;
-
gint theme_notif;
};
@@ -238,133 +235,13 @@ select_spinner_image (EphySpinner *spinner)
return g_object_ref (element->data);
}
-static guchar
-lighten_component (guchar cur_value)
-{
- int new_value = cur_value;
- new_value += 24 + (new_value >> 3);
- if (new_value > 255) {
- new_value = 255;
- }
- return (guchar) new_value;
-}
-
-static GdkPixbuf *
-create_new_pixbuf (GdkPixbuf *src)
-{
- g_return_val_if_fail (gdk_pixbuf_get_colorspace (src) == GDK_COLORSPACE_RGB, NULL);
- g_return_val_if_fail ((!gdk_pixbuf_get_has_alpha (src)
- && gdk_pixbuf_get_n_channels (src) == 3)
- || (gdk_pixbuf_get_has_alpha (src)
- && gdk_pixbuf_get_n_channels (src) == 4), NULL);
-
- return gdk_pixbuf_new (gdk_pixbuf_get_colorspace (src),
- gdk_pixbuf_get_has_alpha (src),
- gdk_pixbuf_get_bits_per_sample (src),
- gdk_pixbuf_get_width (src),
- gdk_pixbuf_get_height (src));
-}
-
-static GdkPixbuf *
-eel_create_darkened_pixbuf (GdkPixbuf *src, int saturation, int darken)
-{
- gint i, j;
- gint width, height, src_row_stride, dest_row_stride;
- gboolean has_alpha;
- guchar *target_pixels, *original_pixels;
- guchar *pixsrc, *pixdest;
- guchar intensity;
- guchar alpha;
- guchar negalpha;
- guchar r, g, b;
- GdkPixbuf *dest;
-
- g_return_val_if_fail (gdk_pixbuf_get_colorspace (src) == GDK_COLORSPACE_RGB, NULL);
- g_return_val_if_fail ((!gdk_pixbuf_get_has_alpha (src)
- && gdk_pixbuf_get_n_channels (src) == 3)
- || (gdk_pixbuf_get_has_alpha (src)
- && gdk_pixbuf_get_n_channels (src) == 4), NULL);
- g_return_val_if_fail (gdk_pixbuf_get_bits_per_sample (src) == 8, NULL);
-
- dest = create_new_pixbuf (src);
-
- has_alpha = gdk_pixbuf_get_has_alpha (src);
- width = gdk_pixbuf_get_width (src);
- height = gdk_pixbuf_get_height (src);
- dest_row_stride = gdk_pixbuf_get_rowstride (dest);
- src_row_stride = gdk_pixbuf_get_rowstride (src);
- target_pixels = gdk_pixbuf_get_pixels (dest);
- original_pixels = gdk_pixbuf_get_pixels (src);
-
- for (i = 0; i < height; i++) {
- pixdest = target_pixels + i * dest_row_stride;
- pixsrc = original_pixels + i * src_row_stride;
- for (j = 0; j < width; j++) {
- r = *pixsrc++;
- g = *pixsrc++;
- b = *pixsrc++;
- intensity = (r * 77 + g * 150 + b * 28) >> 8;
- negalpha = ((255 - saturation) * darken) >> 8;
- alpha = (saturation * darken) >> 8;
- *pixdest++ = (negalpha * intensity + alpha * r) >> 8;
- *pixdest++ = (negalpha * intensity + alpha * g) >> 8;
- *pixdest++ = (negalpha * intensity + alpha * b) >> 8;
- if (has_alpha) {
- *pixdest++ = *pixsrc++;
- }
- }
- }
- return dest;
-}
-
-static GdkPixbuf *
-eel_create_spotlight_pixbuf (GdkPixbuf* src)
-{
- GdkPixbuf *dest;
- int i, j;
- int width, height, has_alpha, src_row_stride, dst_row_stride;
- guchar *target_pixels, *original_pixels;
- guchar *pixsrc, *pixdest;
-
- g_return_val_if_fail (gdk_pixbuf_get_colorspace (src) == GDK_COLORSPACE_RGB, NULL);
- g_return_val_if_fail ((!gdk_pixbuf_get_has_alpha (src)
- && gdk_pixbuf_get_n_channels (src) == 3)
- || (gdk_pixbuf_get_has_alpha (src)
- && gdk_pixbuf_get_n_channels (src) == 4), NULL);
- g_return_val_if_fail (gdk_pixbuf_get_bits_per_sample (src) == 8, NULL);
-
- dest = create_new_pixbuf (src);
-
- has_alpha = gdk_pixbuf_get_has_alpha (src);
- width = gdk_pixbuf_get_width (src);
- height = gdk_pixbuf_get_height (src);
- dst_row_stride = gdk_pixbuf_get_rowstride (dest);
- src_row_stride = gdk_pixbuf_get_rowstride (src);
- target_pixels = gdk_pixbuf_get_pixels (dest);
- original_pixels = gdk_pixbuf_get_pixels (src);
-
- for (i = 0; i < height; i++) {
- pixdest = target_pixels + i * dst_row_stride;
- pixsrc = original_pixels + i * src_row_stride;
- for (j = 0; j < width; j++) {
- *pixdest++ = lighten_component (*pixsrc++);
- *pixdest++ = lighten_component (*pixsrc++);
- *pixdest++ = lighten_component (*pixsrc++);
- if (has_alpha) {
- *pixdest++ = *pixsrc++;
- }
- }
- }
- return dest;
-}
-
/* handle expose events */
static int
ephy_spinner_expose (GtkWidget *widget, GdkEventExpose *event)
{
EphySpinner *spinner;
- GdkPixbuf *pixbuf, *massaged_pixbuf;
+ GdkPixbuf *pixbuf;
int x_offset, y_offset, width, height;
GdkRectangle pix_area, dest;
@@ -382,18 +259,6 @@ ephy_spinner_expose (GtkWidget *widget, GdkEventExpose *event)
return FALSE;
}
- /* Get the right tint on the image */
-
- if (spinner->details->button_in) {
- if (spinner->details->button_down) {
- massaged_pixbuf = eel_create_darkened_pixbuf (pixbuf, 0.8 * 255, 0.8 * 255);
- } else {
- massaged_pixbuf = eel_create_spotlight_pixbuf (pixbuf);
- }
- g_object_unref (pixbuf);
- pixbuf = massaged_pixbuf;
- }
-
width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf);
@@ -620,79 +485,6 @@ ephy_spinner_load_images (EphySpinner *spinner)
g_free (image_theme);
}
-static gboolean
-ephy_spinner_enter_notify_event (GtkWidget *widget, GdkEventCrossing *event)
-{
- EphySpinner *spinner;
-
- spinner = EPHY_SPINNER (widget);
-
- if (!spinner->details->button_in) {
- spinner->details->button_in = TRUE;
- gtk_widget_queue_draw (widget);
- }
-
- return FALSE;
-}
-
-static gboolean
-ephy_spinner_leave_notify_event (GtkWidget *widget, GdkEventCrossing *event)
-{
- EphySpinner *spinner;
-
- spinner = EPHY_SPINNER (widget);
-
- if (spinner->details->button_in) {
- spinner->details->button_in = FALSE;
- gtk_widget_queue_draw (widget);
- }
-
- return FALSE;
-}
-
-/* handle button presses by posting a change on the "location" property */
-
-static gboolean
-ephy_spinner_button_press_event (GtkWidget *widget, GdkEventButton *event)
-{
- EphySpinner *spinner;
-
- spinner = EPHY_SPINNER (widget);
-
- if (event->button == 1) {
- spinner->details->button_down = TRUE;
- spinner->details->button_in = TRUE;
- gtk_widget_queue_draw (widget);
- return TRUE;
- }
-
- return FALSE;
-}
-
-static void
-ephy_spinner_set_location (EphySpinner *spinner)
-{
-}
-
-static gboolean
-ephy_spinner_button_release_event (GtkWidget *widget, GdkEventButton *event)
-{
- EphySpinner *spinner;
-
- spinner = EPHY_SPINNER (widget);
-
- if (event->button == 1) {
- if (spinner->details->button_in) {
- ephy_spinner_set_location (spinner);
- }
- spinner->details->button_down = FALSE;
- gtk_widget_queue_draw (widget);
- return TRUE;
- }
-
- return FALSE;
-}
-
/*
* ephy_spinner_set_small_mode:
* @spinner: a #EphySpinner
@@ -755,10 +547,6 @@ ephy_spinner_class_init (EphySpinnerClass *class)
G_OBJECT_CLASS (class)->finalize = ephy_spinner_finalize;
widget_class->expose_event = ephy_spinner_expose;
- widget_class->button_press_event = ephy_spinner_button_press_event;
- widget_class->button_release_event = ephy_spinner_button_release_event;
- widget_class->enter_notify_event = ephy_spinner_enter_notify_event;
- widget_class->leave_notify_event = ephy_spinner_leave_notify_event;
widget_class->size_request = ephy_spinner_size_request;
widget_class->map = ephy_spinner_map;
}
diff --git a/src/ephy-spinner-action.c b/src/ephy-spinner-action.c
index 295e88545..1ad90ec64 100644
--- a/src/ephy-spinner-action.c
+++ b/src/ephy-spinner-action.c
@@ -19,6 +19,7 @@
#include "ephy-spinner-action.h"
#include "ephy-spinner.h"
#include "eggtoolitem.h"
+#include "eggtoolbar.h"
static void ephy_spinner_action_init (EphySpinnerAction *action);
static void ephy_spinner_action_class_init (EphySpinnerActionClass *class);
@@ -86,34 +87,64 @@ create_tool_item (EggAction *action)
{
GtkWidget *item;
GtkWidget *spinner;
- GtkWidget *button;
item = GTK_WIDGET (egg_tool_item_new ());
- button = gtk_button_new ();
- gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
- gtk_widget_show (button);
- gtk_container_add (GTK_CONTAINER (item), button);
spinner = ephy_spinner_new ();
- ephy_spinner_set_small_mode (EPHY_SPINNER (spinner), TRUE);
- gtk_container_add (GTK_CONTAINER (button), spinner);
+ gtk_widget_show (spinner);
+ gtk_container_add (GTK_CONTAINER (item), spinner);
egg_tool_item_set_pack_end (EGG_TOOL_ITEM (item), TRUE);
egg_tool_item_set_homogeneous (EGG_TOOL_ITEM (item), FALSE);
- gtk_widget_show (spinner);
g_object_set_data (G_OBJECT (item), "spinner", spinner);
return item;
}
static void
+toolbar_style_sync (EggToolbar *toolbar,
+ GtkToolbarStyle style,
+ GtkWidget *proxy)
+{
+ gboolean small;
+ EphySpinner *spinner;
+
+ spinner = EPHY_SPINNER (g_object_get_data (G_OBJECT (proxy), "spinner"));
+
+ small = (style == GTK_TOOLBAR_ICONS || style == GTK_TOOLBAR_TEXT);
+ ephy_spinner_set_small_mode (EPHY_SPINNER (spinner), small);
+}
+
+static void
+item_parent_set_cb (GtkWidget *item, GtkWidget *previous_parent)
+{
+ EggToolbar *toolbar;
+ GtkToolbarStyle style;
+
+ if (item->parent == NULL) return;
+
+ toolbar = EGG_TOOLBAR (item->parent);
+
+ g_signal_connect (toolbar, "style_changed",
+ G_CALLBACK (toolbar_style_sync),
+ item);
+
+ style = egg_toolbar_get_style (toolbar);
+ toolbar_style_sync (toolbar, style, item);
+}
+
+static void
connect_proxy (EggAction *action, GtkWidget *proxy)
{
g_signal_connect_object (action, "notify::throbbing",
G_CALLBACK (ephy_spinner_action_sync_throbbing),
proxy, 0);
+ g_signal_connect (proxy, "parent_set",
+ G_CALLBACK (item_parent_set_cb),
+ NULL);
(* EGG_ACTION_CLASS (parent_class)->connect_proxy) (action, proxy);
}
+
static void
ephy_spinner_action_set_property (GObject *object,
guint prop_id,