[gimp] Bug 120563 – Add an easy way to use the default comment
- From: Martin Nordholts <martinn src gnome org>
- To: svn-commits-list gnome org
- Subject: [gimp] Bug 120563 – Add an easy way to use the default comment
- Date: Sat, 18 Jul 2009 07:51:31 +0000 (UTC)
commit 99ce3bd8b27bd0b71f4c95d4eea4a2c69c090b37
Author: Martin Nordholts <martinn src gnome org>
Date: Sat Jul 18 09:37:46 2009 +0200
Bug 120563 â?? Add an easy way to use the default comment
Add a 'Use default comment' button to the Comment tab in Image
Properties that if clicked sets the image comment to the default
comment set in Preferences.
app/widgets/gimpimagecommenteditor.c | 53 +++++++++++++++++++++++++++++++--
1 files changed, 49 insertions(+), 4 deletions(-)
---
diff --git a/app/widgets/gimpimagecommenteditor.c b/app/widgets/gimpimagecommenteditor.c
index 5c3cde2..6cb00a0 100644
--- a/app/widgets/gimpimagecommenteditor.c
+++ b/app/widgets/gimpimagecommenteditor.c
@@ -30,18 +30,25 @@
#include "widgets-types.h"
+#include "config/gimpcoreconfig.h"
+
+#include "core/gimp.h"
#include "core/gimpimage.h"
+#include "core/gimptemplate.h"
#include "gimpimagecommenteditor.h"
+#include "gimp-intl.h"
#define GIMP_IMAGE_COMMENT_PARASITE "gimp-comment"
-static void gimp_image_comment_editor_update (GimpImageParasiteView *view);
+static void gimp_image_comment_editor_update (GimpImageParasiteView *view);
-static void gimp_image_comment_editor_buffer_changed (GtkTextBuffer *buffer,
- GimpImageCommentEditor *editor);
+static void gimp_image_comment_editor_buffer_changed (GtkTextBuffer *buffer,
+ GimpImageCommentEditor *editor);
+static void gimp_image_comment_editor_use_default_comment (GtkWidget *button,
+ GimpImageCommentEditor *editor);
G_DEFINE_TYPE (GimpImageCommentEditor,
@@ -60,20 +67,30 @@ gimp_image_comment_editor_class_init (GimpImageCommentEditorClass *klass)
static void
gimp_image_comment_editor_init (GimpImageCommentEditor *editor)
{
+ GtkWidget *vbox;
GtkWidget *scrolled_window;
GtkWidget *text_view;
+ GtkWidget *button;
+ /* Init */
editor->recoursing = FALSE;
+ /* Vbox */
+ vbox = gtk_vbox_new (FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (editor), vbox);
+ gtk_widget_show (vbox);
+
+ /* Scrolled winow */
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 2);
- gtk_container_add (GTK_CONTAINER (editor), scrolled_window);
+ gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 0);
gtk_widget_show (scrolled_window);
+ /* Text view */
text_view = gtk_text_view_new ();
gtk_text_view_set_editable (GTK_TEXT_VIEW (text_view), TRUE);
@@ -86,6 +103,21 @@ gimp_image_comment_editor_init (GimpImageCommentEditor *editor)
gtk_container_add (GTK_CONTAINER (scrolled_window), text_view);
gtk_widget_show (text_view);
+ /* Button */
+ button = gtk_button_new_with_label (_("Use default comment"));
+ gimp_help_set_help_data (GTK_WIDGET (button),
+ _("Replace the current image comment with the "
+ "default comment set in "
+ "Editâ??Preferencesâ??Default Image."),
+ NULL);
+ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, TRUE, 0);
+ gtk_widget_show (button);
+
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (gimp_image_comment_editor_use_default_comment),
+ editor);
+
+ /* Buffer */
editor->buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
g_signal_connect (editor->buffer, "changed",
@@ -192,3 +224,16 @@ gimp_image_comment_editor_buffer_changed (GtkTextBuffer *buffer,
g_free (text);
}
+
+static void
+gimp_image_comment_editor_use_default_comment (GtkWidget *button,
+ GimpImageCommentEditor *editor)
+{
+ GimpImage *image = gimp_image_parasite_view_get_image (GIMP_IMAGE_PARASITE_VIEW (editor));
+ const gchar *comment = image ? image->gimp->config->default_image->comment : NULL;
+
+ if (comment)
+ gtk_text_buffer_set_text (editor->buffer, comment, -1);
+ else
+ gtk_text_buffer_set_text (editor->buffer, "", -1);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]