gimp r27441 - in trunk: . app/actions app/tools
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r27441 - in trunk: . app/actions app/tools
- Date: Mon, 27 Oct 2008 12:23:41 +0000 (UTC)
Author: neo
Date: Mon Oct 27 12:23:40 2008
New Revision: 27441
URL: http://svn.gnome.org/viewvc/gimp?rev=27441&view=rev
Log:
2008-10-27 Sven Neumann <sven gimp org>
* app/tools/gimptexttool.c: removed unused includes.
* app/actions/text-tool-commands.c
(text_tool_load_cmd_callback):
fixed file dialog for opening text files.
Modified:
trunk/ChangeLog
trunk/app/actions/text-tool-commands.c
trunk/app/tools/gimptexttool.c
Modified: trunk/app/actions/text-tool-commands.c
==============================================================================
--- trunk/app/actions/text-tool-commands.c (original)
+++ trunk/app/actions/text-tool-commands.c Mon Oct 27 12:23:40 2008
@@ -25,13 +25,14 @@
#include "actions-types.h"
-#include "core/gimp.h"
+#include "core/gimptoolinfo.h"
-#include "widgets/gimptexteditor.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpuimanager.h"
#include "widgets/gimpwidgets-utils.h"
+#include "display/gimpdisplay.h"
+
#include "tools/gimptexttool.h"
#include "text-tool-commands.h"
@@ -41,9 +42,11 @@
/* local function prototypes */
-static void text_tool_load_response (GtkWidget *dialog,
- gint response_id,
- GimpTextEditor *editor);
+static void text_tool_load_dialog_destroyed (GtkWidget *dialog,
+ GObject *tool);
+static void text_tool_load_dialog_response (GtkWidget *dialog,
+ gint response_id,
+ GimpTextTool *tool);
/* public functions */
@@ -89,44 +92,52 @@
text_tool_load_cmd_callback (GtkAction *action,
gpointer data)
{
- GimpTextEditor *editor = GIMP_TEXT_EDITOR (data);
+ GimpTextTool *text_tool = GIMP_TEXT_TOOL (data);
+ GtkWidget *dialog;
+ GtkWidget *parent = NULL;
GtkFileChooser *chooser;
- if (editor->file_dialog)
+ dialog = g_object_get_data (G_OBJECT (text_tool), "gimp-text-file-dialog");
+
+ if (dialog)
{
- gtk_window_present (GTK_WINDOW (editor->file_dialog));
+ gtk_window_present (GTK_WINDOW (dialog));
return;
}
- editor->file_dialog =
- gtk_file_chooser_dialog_new (_("Open Text File (UTF-8)"),
- GTK_WINDOW (editor),
- GTK_FILE_CHOOSER_ACTION_OPEN,
+ if (GIMP_TOOL (text_tool)->display)
+ parent = GIMP_TOOL (text_tool)->display->shell;
+
+ dialog = gtk_file_chooser_dialog_new (_("Open Text File (UTF-8)"),
+ parent ? GTK_WINDOW (parent) : NULL,
+ GTK_FILE_CHOOSER_ACTION_OPEN,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OPEN, GTK_RESPONSE_OK,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_OK,
- NULL);
+ NULL);
- chooser = GTK_FILE_CHOOSER (editor->file_dialog);
+ chooser = GTK_FILE_CHOOSER (dialog);
- gtk_dialog_set_alternative_button_order (GTK_DIALOG (editor->file_dialog),
+ gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
- g_object_add_weak_pointer (G_OBJECT (chooser),
- (gpointer) &editor->file_dialog);
+ g_object_set_data (G_OBJECT (text_tool), "gimp-text-file-dialog", dialog);
+
+ g_signal_connect (dialog, "destroy",
+ G_CALLBACK (text_tool_load_dialog_destroyed),
+ text_tool);
gtk_window_set_role (GTK_WINDOW (chooser), "gimp-text-load-file");
gtk_window_set_position (GTK_WINDOW (chooser), GTK_WIN_POS_MOUSE);
- gtk_window_set_destroy_with_parent (GTK_WINDOW (chooser), TRUE);
gtk_dialog_set_default_response (GTK_DIALOG (chooser), GTK_RESPONSE_OK);
g_signal_connect (chooser, "response",
- G_CALLBACK (text_tool_load_response),
- editor);
+ G_CALLBACK (text_tool_load_dialog_response),
+ text_tool);
g_signal_connect (chooser, "delete-event",
G_CALLBACK (gtk_true),
NULL);
@@ -160,23 +171,30 @@
GtkAction *current,
gpointer data)
{
- GimpTextEditor *editor = GIMP_TEXT_EDITOR (data);
- gint value;
+ GimpTextTool *text_tool = GIMP_TEXT_TOOL (data);
+ gint value;
value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
- /*
- gimp_text_tool_set_direction (editor, (GimpTextDirection) value);
- */
+ g_object_set (text_tool->proxy,
+ "base-direction", (GimpTextDirection) value,
+ NULL);
}
/* private functions */
static void
-text_tool_load_response (GtkWidget *dialog,
- gint response_id,
- GimpTextEditor *editor)
+text_tool_load_dialog_destroyed (GtkWidget *dialog,
+ GObject *tool)
+{
+ g_object_set_data (tool, "gimp-text-file-dialog", NULL);
+}
+
+static void
+text_tool_load_dialog_response (GtkWidget *dialog,
+ gint response_id,
+ GimpTextTool *tool)
{
if (response_id == GTK_RESPONSE_OK)
{
@@ -184,12 +202,11 @@
gchar *filename;
GError *error = NULL;
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (editor->view));
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
- if (! gimp_text_buffer_load (buffer, filename, &error))
+ if (! gimp_text_buffer_load (tool->text_buffer, filename, &error))
{
- gimp_message (editor->ui_manager->gimp, G_OBJECT (dialog),
+ gimp_message (GIMP_TOOL (tool)->tool_info->gimp, G_OBJECT (dialog),
GIMP_MESSAGE_ERROR,
_("Could not open '%s' for reading: %s"),
gimp_filename_to_utf8 (filename),
@@ -202,5 +219,5 @@
g_free (filename);
}
- gtk_widget_destroy (dialog);
+ gtk_widget_hide (dialog);
}
Modified: trunk/app/tools/gimptexttool.c
==============================================================================
--- trunk/app/tools/gimptexttool.c (original)
+++ trunk/app/tools/gimptexttool.c Mon Oct 27 12:23:40 2008
@@ -21,11 +21,6 @@
#include "config.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
#include <gegl.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]