gimp r25013 - in branches/weskaggs: . app/display app/file app/gui data/images
- From: weskaggs svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r25013 - in branches/weskaggs: . app/display app/file app/gui data/images
- Date: Mon, 3 Mar 2008 22:40:37 +0000 (GMT)
Author: weskaggs
Date: Mon Mar 3 22:40:37 2008
New Revision: 25013
URL: http://svn.gnome.org/viewvc/gimp?rev=25013&view=rev
Log:
Bill Skaggs <weskaggs primate ucdavis edu>
* data/images/gimp-scratch.png
* data/images/Makefile.am
* app/file/file-open.c
* app/gui/gui.c
* app/display/gimpdisplay.c: use a special scratch image for
no-image-open window, and use the window to show tips.
Added:
branches/weskaggs/data/images/gimp-scratch.png (contents, props changed)
Modified:
branches/weskaggs/ChangeLog
branches/weskaggs/app/display/gimpdisplay.c
branches/weskaggs/app/file/file-open.c
branches/weskaggs/app/gui/gui.c
branches/weskaggs/data/images/Makefile.am
Modified: branches/weskaggs/app/display/gimpdisplay.c
==============================================================================
--- branches/weskaggs/app/display/gimpdisplay.c (original)
+++ branches/weskaggs/app/display/gimpdisplay.c Mon Mar 3 22:40:37 2008
@@ -20,6 +20,7 @@
#include <gtk/gtk.h>
+#include "libgimpbase/gimpbase.h"
#include "libgimpmath/gimpmath.h"
#include "display-types.h"
@@ -27,12 +28,23 @@
#include "file/file-open.h"
+#include "config/gimpguiconfig.h"
+
#include "core/gimp.h"
#include "core/gimparea.h"
+#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimplist.h"
#include "core/gimpprogress.h"
+#include "dialogs/tips-parser.h"
+
+/* FIXME */
+#include "text/gimpfont-utils.h"
+#include "text/gimptext.h"
+#include "text/gimptext-compat.h"
+#include "text/gimptextlayer.h"
+
#include "tools/gimptool.h"
#include "tools/tool_manager.h"
@@ -97,6 +109,9 @@
gint w,
gint h);
+static void text_show_tip (GimpImage *image,
+ GimpContext *context);
+
G_DEFINE_TYPE_WITH_CODE (GimpDisplay, gimp_display, GIMP_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GIMP_TYPE_PROGRESS,
@@ -436,8 +451,8 @@
gimp_display_shell_set_show_scrollbars (shell, FALSE);
gimp_display_shell_set_show_statusbar (shell, FALSE);
- width = SCALEX (shell, gimp_image_get_width (shell->display->image));
- height = SCALEY (shell, gimp_image_get_height (shell->display->image));
+ width = SCALEX (shell, gimp_image_get_width (image));
+ height = SCALEY (shell, gimp_image_get_height (image));
gtk_widget_set_size_request (display->shell, width, height);
gtk_widget_show (display->shell);
@@ -449,9 +464,103 @@
/* add the display to the list */
gimp_container_add (gimp->displays, GIMP_OBJECT (display));
+ /*FIXME: hack alert */
+ if (GIMP_GUI_CONFIG (gimp->config)->show_tips)
+ text_show_tip (image, gimp_get_user_context (gimp));
+
return display;
}
+/*
+ * this is a hack, this function should be replaced by something
+ * better and go somewhere else
+ */
+static void
+text_show_tip (GimpImage *image,
+ GimpContext *context)
+{
+ gchar *filename;
+ GList *tips;
+ GError *error = NULL;
+ Gimp *gimp = image->gimp;
+
+ filename = g_build_filename (gimp_data_directory (), "tips",
+ "gimp-tips.xml", NULL);
+
+ tips = gimp_tips_from_file (filename, &error);
+ g_free (filename);
+
+ if (tips)
+ {
+ PangoFontDescription *desc;
+
+ gint tips_count = g_list_length (tips);
+ GimpGuiConfig *config = GIMP_GUI_CONFIG (gimp->config);
+ GList *current_tip;
+ GimpText *text;
+ GimpTip *tip;
+ gchar *tip_text;
+ GimpLayer *layer;
+ gdouble size;
+ GimpRGB color = {0, 0.2, 0.4, 1.0};
+ gchar *font;
+ gint margin = 30;
+ gdouble box_height = 200;
+ gdouble box_width;
+ gint layer_height;
+
+ if (config->last_tip >= tips_count || config->last_tip < 0)
+ config->last_tip = 0;
+
+ current_tip = g_list_nth (tips, config->last_tip);
+
+ tip = current_tip->data;
+ tip_text = g_strconcat ("<span size=\"x-large\"><b>", _("TIP:"), "</b></span> ",
+ tip->thetip, NULL);
+
+ /* the last-shown-tip is saved in sessionrc */
+ config->last_tip = g_list_position (tips, current_tip);
+
+ desc = pango_font_description_from_string ("sans 12");
+ size = PANGO_PIXELS (pango_font_description_get_size (desc));
+
+ pango_font_description_unset_fields (desc, PANGO_FONT_MASK_SIZE);
+ font = gimp_font_util_pango_font_description_to_string (desc);
+
+ pango_font_description_free (desc);
+
+ box_width = gimp_image_get_width (image) - 2 * margin;
+
+ /* FIXME: should calculate appropriate box height */
+ text = g_object_new (GIMP_TYPE_TEXT,
+ "text", tip_text,
+ "font", font,
+ "font-size", size,
+ "color", &color,
+ "box-mode", GIMP_TEXT_BOX_FIXED,
+ "box-width", box_width,
+ "box-height", box_height,
+ NULL);
+
+ g_free (font);
+ g_free (tip_text);
+
+ layer = gimp_text_layer_new (image, text);
+
+ g_object_unref (text);
+
+ layer_height = GIMP_ITEM (layer)->height;
+
+ GIMP_ITEM (layer)->offset_x = margin;
+ GIMP_ITEM (layer)->offset_y = margin;
+/* GIMP_ITEM (layer)->offset_y = (gimp_image_get_height (image) - layer_height) / 2; */
+
+ gimp_image_add_layer (image, layer, -1);
+ gimp_image_flatten (image, context);
+ }
+}
+
+
void
gimp_display_delete (GimpDisplay *display)
{
@@ -549,6 +658,9 @@
gimp_display_disconnect (display);
gimp_display_connect (display, image);
+ if (image->gimp->scratch_image == old_image)
+ gimp_display_shell_reconfigure_from_scratch (GIMP_DISPLAY_SHELL (display->shell));
+
g_object_unref (old_image);
gimp_display_shell_reconnect (GIMP_DISPLAY_SHELL (display->shell));
Modified: branches/weskaggs/app/file/file-open.c
==============================================================================
--- branches/weskaggs/app/file/file-open.c (original)
+++ branches/weskaggs/app/file/file-open.c Mon Mar 3 22:40:37 2008
@@ -344,6 +344,18 @@
if (image)
{
+ /*
+ * if we are showing a scratch image, we want to use the display
+ * from the scratch image for our new image.
+ */
+ if (context->gimp->scratch_image)
+ {
+ gimp_reconnect_displays (context->gimp,
+ context->gimp->scratch_image,
+ image);
+ context->gimp->scratch_image = NULL;
+ }
+ else
gimp_create_display (image->gimp, image, GIMP_UNIT_PIXEL, 1.0);
if (! as_new)
@@ -543,7 +555,7 @@
uri = file_utils_any_to_uri (gimp,
g_build_filename (gimp_data_directory (),
"images",
- "gimp-splash.png",
+ "gimp-scratch.png",
NULL),
&error);
@@ -555,7 +567,7 @@
gimp_get_user_context (gimp),
NULL,
uri,
- "gimp-splash.png",
+ "gimp-scratch.png",
TRUE,
NULL,
GIMP_RUN_NONINTERACTIVE,
Modified: branches/weskaggs/app/gui/gui.c
==============================================================================
--- branches/weskaggs/app/gui/gui.c (original)
+++ branches/weskaggs/app/gui/gui.c Mon Mar 3 22:40:37 2008
@@ -255,11 +255,6 @@
gui_post_init (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
-
- if (GIMP_GUI_CONFIG (gimp->config)->show_tips)
- gimp_dialog_factory_dialog_new (global_dialog_factory,
- gdk_screen_get_default (),
- "gimp-tips-dialog", -1, TRUE);
}
Modified: branches/weskaggs/data/images/Makefile.am
==============================================================================
--- branches/weskaggs/data/images/Makefile.am (original)
+++ branches/weskaggs/data/images/Makefile.am Mon Mar 3 22:40:37 2008
@@ -4,6 +4,7 @@
imagedata_DATA = \
gimp-logo.png \
- gimp-splash.png
+ gimp-splash.png \
+ gimp-scratch.png
EXTRA_DIST = $(imagedata_DATA)
Added: branches/weskaggs/data/images/gimp-scratch.png
==============================================================================
Binary file. No diff available.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]