[PATCH] pinboard change speedup.
Neil Graham <[email protected]> Tue, 3 Nov 2009 20:50:06 +0000 (UTC)
| Newsgroups | gmane.comp.desktop.rox.devel |
|---|---|
| Message-ID | <[email protected]> |
Changed the checkbox option for fast scaling to Fastest, Fast, Best
Fastest does Nearest Neighbour.
Fast does Bilinear
Best does Hyper
Setting a new pinboard reuses the current window rather than
destroying it and creating a new one.
---
ROX-Filer/Options.xml | 12 ++++++-
ROX-Filer/src/pinboard.c | 79 ++++++++++++++++++++++++++++
+-----------------
2 files changed, 61 insertions(+), 30 deletions(-)
diff --git a/ROX-Filer/Options.xml b/ROX-Filer/Options.xml
index e72df1b..8ab6fda 100644
--- a/ROX-Filer/Options.xml
+++ b/ROX-Filer/Options.xml
@@ -142,7 +142,17 @@ indicator'>If this is on then files which have one
or more extended attributes s
<spacer/>
<font override='1' label='Use custom font:' name='label_font'>The
font used for the text displayed under the icons</font>
<spacer/>
- <toggle name='pinboard_image_scaling' label='Fast scaling of
images'>Choose between the fast or slow method of scaling backdrop
images. The slow method can give better results.</toggle>
+
+ <label>Choose the quality setting for scaling of images.</label>
+
+ <hbox label='scaling mode:'>
+
+ <radio-group name='pinboard_image_scaling' >
+ <radio label='Fastest' value='0'/>
+ <radio label='Fast' value='1'/>
+ <radio label='Best' value='2'/>
+ </radio-group>
+ </hbox>
</frame>
<frame label='Pinboard behaviour'>
<toggle name='bind_single_pinboard' label='Single-click to
open'>Clicking on an item opens it with this on. Hold down Control to
select the item instead. If off, clicking once selects an item; double
click to open things.</toggle>
diff --git a/ROX-Filer/src/pinboard.c b/ROX-Filer/src/pinboard.c
index de66086..91cb5e4 100644
--- a/ROX-Filer/src/pinboard.c
+++ b/ROX-Filer/src/pinboard.c
@@ -113,6 +113,11 @@ struct _PinIcon {
#define CORNER_BOTTOM_LEFT 2
#define CORNER_BOTTOM_RIGHT 3
+/* pinboard scaling */
+#define PINBOARD_SCALE_FASTEST 0
+#define PINBOARD_SCALE_FAST 1
+#define PINBOARD_SCALE_BEST 2
+
#define DIR_HORZ 0
#define DIR_VERT 1
@@ -205,6 +210,7 @@ static void drag_end(GtkWidget *widget,
static void reshape_all(void);
static void pinboard_check_options(void);
static void pinboard_load_from_xml(xmlDocPtr doc);
+static void pinboard_wipe(void);
static void pinboard_clear(void);
static void pinboard_save(void);
static PinIcon *pin_icon_new(const char *pathname, const char *name);
@@ -263,7 +269,7 @@ void pinboard_init(void)
option_add_int(&o_left_margin, "pinboard_left_margin", 0);
option_add_int(&o_right_margin, "pinboard_right_margin", 0);
- option_add_int(&o_pinboard_image_scaling,
"pinboard_image_scaling", 0);
+ option_add_int(&o_pinboard_image_scaling,
"pinboard_image_scaling", PINBOARD_SCALE_FAST);
option_add_notify(pinboard_check_options);
@@ -290,11 +296,11 @@ void pinboard_activate(const gchar *name)
if (name && !*name)
name = NULL;
- if (old_board)
- pinboard_clear();
if (!name)
{
+ if (old_board) pinboard_clear();
+
if (number_of_windows < 1 && gtk_main_level() > 0)
gtk_main_quit();
@@ -303,8 +309,6 @@ void pinboard_activate(const gchar *name)
return;
}
- number_of_windows++;
-
slash = strchr(name, '/');
if (slash)
{
@@ -322,18 +326,26 @@ void pinboard_activate(const gchar *name)
g_free(leaf);
}
- current_pinboard = g_new(Pinboard, 1);
- current_pinboard->name = g_strdup(name);
- current_pinboard->icons = NULL;
- current_pinboard->window = NULL;
- current_pinboard->backdrop = NULL;
- current_pinboard->backdrop_style = BACKDROP_NONE;
- current_pinboard->to_backdrop_app = -1;
- current_pinboard->from_backdrop_app = -1;
- current_pinboard->input_tag = -1;
- current_pinboard->input_buffer = NULL;
-
- create_pinboard_window(current_pinboard);
+ if (old_board) {
+ pinboard_wipe();
+
+ g_free(current_pinboard->name);
+ current_pinboard->name = g_strdup(name);
+
+ } else {
+ number_of_windows++;
+ current_pinboard = g_new(Pinboard, 1);
+ current_pinboard->name = g_strdup(name);
+ current_pinboard->icons = NULL;
+ current_pinboard->window = NULL;
+ current_pinboard->backdrop = NULL;
+ current_pinboard->backdrop_style = BACKDROP_NONE;
+ current_pinboard->to_backdrop_app = -1;
+ current_pinboard->from_backdrop_app = -1;
+ current_pinboard->input_tag = -1;
+ current_pinboard->input_buffer = NULL;
+ create_pinboard_window(current_pinboard);
+ }
loading_pinboard++;
if (path)
@@ -2056,15 +2068,10 @@ static void reshape_all(void)
}
}
-/* Turns off the pinboard. Does not call gtk_main_quit. */
-static void pinboard_clear(void)
-{
+/* removes all content from the pinboard. Does not remove the window */
+static void pinboard_wipe(void) {
GList *next;
- g_return_if_fail(current_pinboard != NULL);
-
- tasklist_set_active(FALSE);
-
next = current_pinboard->icons;
while (next)
{
@@ -2072,8 +2079,20 @@ static void pinboard_clear(void)
next = next->next;
+ gtk_widget_hide(pi->win); /* Stops flicker - stupid
GtkFixed! */
gtk_widget_destroy(pi->win);
}
+ current_pinboard->icons=NULL;
+}
+
+/* Turns off the pinboard. Does not call gtk_main_quit. */
+static void pinboard_clear(void)
+{
+ g_return_if_fail(current_pinboard != NULL);
+
+ tasklist_set_active(FALSE);
+
+ pinboard_wipe();
gtk_widget_destroy(current_pinboard->window);
@@ -2346,13 +2365,17 @@ static GdkPixmap *load_backdrop(const gchar
*path, BackdropStyle style)
return NULL;
}
+ GdkInterpType scale_kind = GDK_INTERP_BILINEAR;
+ if (o_pinboard_image_scaling.int_value == PINBOARD_SCALE_FASTEST)
scale_kind = GDK_INTERP_NEAREST;
+ if (o_pinboard_image_scaling.int_value == PINBOARD_SCALE_BEST)
scale_kind = GDK_INTERP_HYPER;
+
if (style == BACKDROP_STRETCH)
{
GdkPixbuf *old = pixbuf;
pixbuf = gdk_pixbuf_scale_simple(old,
screen_width, screen_height,
- GDK_INTERP_HYPER);
+ scale_kind);
g_object_unref(old);
}
@@ -2393,14 +2416,12 @@ static GdkPixmap *load_backdrop(const gchar
*path, BackdropStyle style)
y = (screen_height - height * scale) / 2;
x = MAX(x, 0);
y = MAX(y, 0);
-
+
gdk_pixbuf_composite(old, pixbuf,
x, y,
MIN(screen_width, width * scale),
MIN(screen_height, height * scale),
- x, y, scale, scale,
- o_pinboard_image_scaling.int_value?
- GDK_INTERP_BILINEAR:
GDK_INTERP_HYPER,
+ x, y, scale, scale, scale_kind,
255);
g_object_unref(old);
}
--
1.6.3.3
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference