[gthumb] sharpen: added a preview
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] sharpen: added a preview
- Date: Fri, 8 Apr 2011 17:09:13 +0000 (UTC)
commit 8e34b061d75b296d71d2d1b0fc2607e301891ea2
Author: Paolo Bacchilega <paobac src gnome org>
Date: Fri Apr 8 18:51:10 2011 +0200
sharpen: added a preview
extensions/file_tools/data/ui/sharpen-options.ui | 31 ++++++++-
extensions/file_tools/gth-file-tool-sharpen.c | 77 ++++++++++++++++++----
gthumb/gth-image-viewer.c | 51 +++++++++++++-
gthumb/gth-image-viewer.h | 2 +
4 files changed, 141 insertions(+), 20 deletions(-)
---
diff --git a/extensions/file_tools/data/ui/sharpen-options.ui b/extensions/file_tools/data/ui/sharpen-options.ui
index 8d0aeb9..7b95cd9 100644
--- a/extensions/file_tools/data/ui/sharpen-options.ui
+++ b/extensions/file_tools/data/ui/sharpen-options.ui
@@ -14,11 +14,36 @@
<property name="border_width">12</property>
<property name="spacing">12</property>
<child>
- <object class="GtkHBox" id="preview_hbox">
- <property name="height_request">160</property>
+ <object class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
+ <property name="bottom_padding">12</property>
<child>
- <placeholder/>
+ <object class="GtkVBox" id="vbox3">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkLabel" id="preview_label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Preview:</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="preview_hbox">
+ <property name="height_request">190</property>
+ <property name="visible">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
</child>
</object>
<packing>
diff --git a/extensions/file_tools/gth-file-tool-sharpen.c b/extensions/file_tools/gth-file-tool-sharpen.c
index 1837383..56cb849 100644
--- a/extensions/file_tools/gth-file-tool-sharpen.c
+++ b/extensions/file_tools/gth-file-tool-sharpen.c
@@ -30,7 +30,7 @@
#define APPLY_DELAY 150
#define DEFAULT_RADIUS 2.0
#define DEFAULT_AMOUNT 50.0
-#define DEFAULT_THRESHOLD 1.0
+#define DEFAULT_THRESHOLD 0.0
static gpointer parent_class = NULL;
@@ -43,6 +43,7 @@ struct _GthFileToolSharpenPrivate {
GtkAdjustment *radius_adj;
GtkAdjustment *amount_adj;
GtkAdjustment *threshold_adj;
+ GtkWidget *preview;
GthTask *pixbuf_task;
guint apply_event;
};
@@ -170,6 +171,43 @@ reset_button_clicked_cb (GtkButton *button,
}
+static gboolean
+apply_cb (gpointer user_data)
+{
+ GthFileToolSharpen *self = user_data;
+ GthImageViewer *preview;
+ SharpenData *sharpen_data;
+ GdkPixbuf *preview_subpixbuf;
+ int x, y, w ,h;
+
+ if (self->priv->apply_event != 0) {
+ g_source_remove (self->priv->apply_event);
+ self->priv->apply_event = 0;
+ }
+
+ preview = GTH_IMAGE_VIEWER (self->priv->preview);
+ sharpen_data = sharpen_data_new (self);
+ x = gtk_adjustment_get_value (preview->hadj);
+ y = gtk_adjustment_get_value (preview->vadj);
+ w = gtk_adjustment_get_page_size (preview->hadj);
+ h = gtk_adjustment_get_page_size (preview->vadj);
+
+ _g_object_unref (self->priv->dest_pixbuf);
+ self->priv->dest_pixbuf = gdk_pixbuf_copy (self->priv->src_pixbuf);
+ preview_subpixbuf = gdk_pixbuf_new_subpixbuf (self->priv->dest_pixbuf, x, y, w, h);
+ _gdk_pixbuf_sharpen (preview_subpixbuf,
+ sharpen_data->radius,
+ sharpen_data->amount,
+ sharpen_data->threshold);
+ gth_image_viewer_set_pixbuf (preview, self->priv->dest_pixbuf, -1, -1);
+
+ g_object_unref (preview_subpixbuf);
+ g_free (sharpen_data);
+
+ return FALSE;
+}
+
+
static void
value_changed_cb (GtkAdjustment *adj,
GthFileToolSharpen *self)
@@ -178,9 +216,7 @@ value_changed_cb (GtkAdjustment *adj,
g_source_remove (self->priv->apply_event);
self->priv->apply_event = 0;
}
- /* FIXME
self->priv->apply_event = g_timeout_add (APPLY_DELAY, apply_cb, self);
- */
}
@@ -192,6 +228,7 @@ gth_file_tool_sharpen_get_options (GthFileTool *base)
GtkWidget *viewer_page;
GtkWidget *viewer;
GtkWidget *options;
+ GtkWidget *image_navigator;
self = (GthFileToolSharpen *) base;
@@ -215,21 +252,27 @@ gth_file_tool_sharpen_get_options (GthFileTool *base)
options = _gtk_builder_get_widget (self->priv->builder, "options");
gtk_widget_show (options);
- /* FIXME: add a preview here
- self->priv->histogram_view = gth_histogram_view_new (self->priv->histogram);
- gtk_widget_show (self->priv->histogram_view);
- gtk_box_pack_start (GTK_BOX (GET_WIDGET ("histogram_hbox")), self->priv->histogram_view, TRUE, TRUE, 0);
- */
+ self->priv->preview = gth_image_viewer_new ();
+ gth_image_viewer_set_reset_scrollbars (GTH_IMAGE_VIEWER (self->priv->preview), FALSE);
+ gth_image_viewer_set_fit_mode (GTH_IMAGE_VIEWER (self->priv->preview), GTH_FIT_NONE);
+ gth_image_viewer_set_zoom_change (GTH_IMAGE_VIEWER (self->priv->preview), GTH_ZOOM_CHANGE_KEEP_PREV);
+ gth_image_viewer_set_zoom (GTH_IMAGE_VIEWER (self->priv->preview), 1.0);
+ gth_image_viewer_enable_zoom_with_keys (GTH_IMAGE_VIEWER (self->priv->preview), FALSE);
+ gth_image_viewer_set_pixbuf (GTH_IMAGE_VIEWER (self->priv->preview), self->priv->src_pixbuf, -1, -1);
+ image_navigator = gth_image_navigator_new (GTH_IMAGE_VIEWER (self->priv->preview));
+ gtk_widget_show_all (image_navigator);
+ gtk_box_pack_start (GTK_BOX (GET_WIDGET ("preview_hbox")), image_navigator, TRUE, TRUE, 0);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (GET_WIDGET ("preview_label")), self->priv->preview);
- self->priv->radius_adj = gimp_scale_entry_new (GET_WIDGET ("radius_hbox"),
- GTK_LABEL (GET_WIDGET ("radius_label")),
- DEFAULT_RADIUS, 0.0, 10.0, 0.1, 1.0, 1);
self->priv->amount_adj = gimp_scale_entry_new (GET_WIDGET ("amount_hbox"),
GTK_LABEL (GET_WIDGET ("amount_label")),
- DEFAULT_AMOUNT, 0.0, 200.0, 1.0, 10.0, 0);
+ DEFAULT_AMOUNT, 0.0, 500.0, 1.0, 10.0, 0);
+ self->priv->radius_adj = gimp_scale_entry_new (GET_WIDGET ("radius_hbox"),
+ GTK_LABEL (GET_WIDGET ("radius_label")),
+ DEFAULT_RADIUS, 0.0, 10.0, 1.0, 1.0, 0);
self->priv->threshold_adj = gimp_scale_entry_new (GET_WIDGET ("threshold_hbox"),
GTK_LABEL (GET_WIDGET ("threshold_label")),
- DEFAULT_THRESHOLD, 1.0, 255.0, 1.0, 10.0, 0);
+ DEFAULT_THRESHOLD, 0.0, 255.0, 1.0, 10.0, 0);
g_signal_connect (GET_WIDGET ("ok_button"),
"clicked",
@@ -255,6 +298,14 @@ gth_file_tool_sharpen_get_options (GthFileTool *base)
"value-changed",
G_CALLBACK (value_changed_cb),
self);
+ g_signal_connect (GTH_IMAGE_VIEWER (self->priv->preview)->hadj,
+ "value-changed",
+ G_CALLBACK (value_changed_cb),
+ self);
+ g_signal_connect (GTH_IMAGE_VIEWER (self->priv->preview)->vadj,
+ "value-changed",
+ G_CALLBACK (value_changed_cb),
+ self);
return options;
}
diff --git a/gthumb/gth-image-viewer.c b/gthumb/gth-image-viewer.c
index f83df60..c4717c0 100644
--- a/gthumb/gth-image-viewer.c
+++ b/gthumb/gth-image-viewer.c
@@ -88,6 +88,7 @@ struct _GthImageViewerPrivate {
GdkCursor *cursor;
GdkCursor *cursor_void;
+ gboolean enable_zoom_with_keys;
double zoom_level;
guint zoom_quality : 1; /* A ZoomQualityType value. */
guint zoom_change : 3; /* A ZoomChangeType value. */
@@ -1302,6 +1303,39 @@ set_scroll_adjustments (GtkWidget *widget,
static void
+gth_image_viewer_zoom_in__key_binding (GthImageViewer *self)
+{
+ if (self->priv->enable_zoom_with_keys)
+ gth_image_viewer_zoom_in (self);
+}
+
+
+static void
+gth_image_viewer_zoom_out__key_binding (GthImageViewer *self)
+{
+ if (self->priv->enable_zoom_with_keys)
+ gth_image_viewer_zoom_out (self);
+}
+
+static void
+gth_image_viewer_set_fit_mode__key_binding (GthImageViewer *self,
+ GthFit fit_mode)
+{
+ if (self->priv->enable_zoom_with_keys)
+ gth_image_viewer_set_fit_mode (self, fit_mode);
+}
+
+
+static void
+gth_image_viewer_set_zoom__key_binding (GthImageViewer *self,
+ gdouble zoom_level)
+{
+ if (self->priv->enable_zoom_with_keys)
+ gth_image_viewer_set_zoom (self, zoom_level);
+}
+
+
+static void
gth_image_viewer_class_init (GthImageViewerClass *class)
{
GObjectClass *gobject_class;
@@ -1425,10 +1459,10 @@ gth_image_viewer_class_init (GthImageViewerClass *class)
class->clicked = NULL;
class->zoom_changed = NULL;
class->scroll = scroll_signal;
- class->zoom_in = gth_image_viewer_zoom_in;
- class->zoom_out = gth_image_viewer_zoom_out;
- class->set_zoom = gth_image_viewer_set_zoom;
- class->set_fit_mode = gth_image_viewer_set_fit_mode;
+ class->zoom_in = gth_image_viewer_zoom_in__key_binding;
+ class->zoom_out = gth_image_viewer_zoom_out__key_binding;
+ class->set_zoom = gth_image_viewer_set_zoom__key_binding;
+ class->set_fit_mode = gth_image_viewer_set_fit_mode__key_binding;
/* Add key bindings */
@@ -1571,6 +1605,7 @@ gth_image_viewer_instance_init (GthImageViewer *self)
self->priv->anim_id = 0;
self->priv->iter = NULL;
+ self->priv->enable_zoom_with_keys = TRUE;
self->priv->zoom_level = 1.0;
self->priv->zoom_quality = GTH_ZOOM_QUALITY_HIGH;
self->priv->zoom_change = GTH_ZOOM_CHANGE_KEEP_PREV;
@@ -2119,6 +2154,14 @@ gth_image_viewer_get_fit_mode (GthImageViewer *self)
void
+gth_image_viewer_enable_zoom_with_keys (GthImageViewer *self,
+ gboolean value)
+{
+ self->priv->enable_zoom_with_keys = value;
+}
+
+
+void
gth_image_viewer_set_transp_type (GthImageViewer *self,
GthTranspType transp_type)
{
diff --git a/gthumb/gth-image-viewer.h b/gthumb/gth-image-viewer.h
index e8210e4..253849b 100644
--- a/gthumb/gth-image-viewer.h
+++ b/gthumb/gth-image-viewer.h
@@ -212,6 +212,8 @@ void gth_image_viewer_zoom_out (GthImageViewer *vi
void gth_image_viewer_set_fit_mode (GthImageViewer *viewer,
GthFit fit_mode);
GthFit gth_image_viewer_get_fit_mode (GthImageViewer *viewer);
+void gth_image_viewer_enable_zoom_with_keys (GthImageViewer *viewer,
+ gboolean value);
/* visualization options. */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]