po/POTFILES.in app/Makefile.am removed because it was not doing core/ui

2000-05-06  Michael Natterer  <mitch@gimp.org>

	* po/POTFILES.in
	* app/Makefile.am
	* app/docindexif.[ch]: removed because it was not doing core/ui
	separation at all. UI functions were randomly scattered across
	both files.

	* app/app_procs.c
	* app/docindex.[ch]: swallow all functions from docindex.c,
	removed functions which were called just once, replaced the
	tree by a list. Actually raise displays of already open images.
	When opening a file which is already in the list, move it's entry
	to the top; this way the toolbox' last_opened list finally works
	as expected.
This commit is contained in:
Michael Natterer 2000-05-06 16:35:21 +00:00 committed by Michael Natterer
parent d9c6f88141
commit 000090ee2f
7 changed files with 456 additions and 525 deletions

View File

@ -123,8 +123,6 @@ gimp_SOURCES = \
disp_callbacks.h \
docindex.c \
docindex.h \
docindexif.c \
docindexif.h \
dodgeburn.c \
dodgeburn.h \
draw_core.c \

View File

@ -698,7 +698,7 @@ app_exit_finish (void)
if (!no_interface)
{
toolbox_free ();
close_idea_window ();
document_index_free ();
gximage_free ();
render_free ();
tool_options_dialog_free ();

View File

@ -14,16 +14,16 @@
*/
#include "config.h"
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include "dialog_handler.h"
#include "docindexif.h"
#include "docindex.h"
#include "fileops.h"
#include "gimpdnd.h"
#include "gimprc.h"
#include "session.h"
#include "libgimp/gimpenv.h"
@ -31,9 +31,25 @@
#include "libgimp/gimpintl.h"
IdeaManager *ideas = NULL;
typedef struct
{
GtkWidget *window;
GtkWidget *list;
} IdeaManager;
static GList *idea_list = NULL; /* of gchar *. */
typedef struct
{
gboolean boole;
gchar *string;
gpointer data;
} BoolCharPair;
static IdeaManager *ideas = NULL;
static GList *idea_list = NULL;
/* dnd stuff */
static GtkTargetEntry drag_types[] =
{
@ -41,171 +57,63 @@ static GtkTargetEntry drag_types[] =
};
static gint n_drag_types = sizeof (drag_types) / sizeof (drag_types[0]);
static void create_idea_list (void);
static void docindex_cell_configure_drop_on_widget (GtkWidget * widget);
/* forward declarations */
static void create_idea_list (void);
static void idea_add_in_position (gchar *label,
gint position);
static void open_idea_window (void);
static void open_or_raise (gchar *file_name);
static void idea_up_callback (GtkWidget *widget,
gpointer data);
static void idea_down_callback (GtkWidget *widget,
gpointer data);
static void idea_remove_callback (GtkWidget *widget,
gpointer data);
static void idea_hide_callback (GtkWidget *widget,
gpointer data);
static gboolean idea_window_delete_event_callback (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static void load_idea_manager (IdeaManager *ideas);
static void save_idea_manager (IdeaManager *ideas);
static void clear_white (FILE *fp);
static gint getinteger (FILE *fp);
static void
docindex_dnd_filenames_dropped (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time)
/* public functions */
void
document_index_create (void)
{
gint len;
gchar *data;
gchar *end;
switch (info)
{
case GIMP_DND_TYPE_URI_LIST:
data = (gchar *) selection_data->data;
len = selection_data->length;
while (len > 0)
{
end = strstr (data, "\x0D\x0A");
if (end != NULL)
*end = 0;
if (*data != '#')
{
gchar *filename = strchr (data, ':');
if (filename != NULL)
filename ++;
else
filename = data;
open_file_in_position (filename, -1);
}
if (end)
{
len -= end - data + 2;
data = end + 2;
}
else
len = 0;
}
break;
}
return;
if (ideas)
gdk_window_raise (ideas->window->window);
else
open_idea_window ();
}
void
docindex_configure_drop_on_widget (GtkWidget * widget)
{
gtk_drag_dest_set (widget,
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_DROP,
drag_types, n_drag_types,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (widget), "drag_data_received",
GTK_SIGNAL_FUNC (docindex_dnd_filenames_dropped),
NULL);
}
static void
docindex_cell_dnd_filenames_dropped (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time)
{
gint len;
gchar *data;
gchar *end;
gint position = g_list_index (GTK_TREE (ideas->tree)->children, widget);
switch (info)
{
case GIMP_DND_TYPE_URI_LIST:
data = (gchar *) selection_data->data;
len = selection_data->length;
while (len > 0)
{
end = strstr (data, "\x0D\x0A");
if (end != NULL)
*end = 0;
if (*data != '#')
{
gchar *filename = strchr (data, ':');
if (filename != NULL)
filename ++;
else
filename = data;
open_file_in_position (filename, position);
}
if (end)
{
len -= end - data + 2;
data = end + 2;
}
else
len = 0;
}
break;
}
return;
}
void
docindex_cell_configure_drop_on_widget (GtkWidget *widget)
{
gtk_drag_dest_set (widget,
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_DROP,
drag_types, n_drag_types,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (widget), "drag_data_received",
GTK_SIGNAL_FUNC (docindex_cell_dnd_filenames_dropped),
NULL);
}
gboolean
idea_window_delete_event_callback (GtkWidget *widget,
GdkEvent *event,
gpointer data)
document_index_free (void)
{
idea_hide_callback (NULL, NULL);
return TRUE;
}
void
idea_hide_callback (GtkWidget *widget,
gpointer data)
idea_add (gchar *title)
{
if (ideas || idea_list)
save_idea_manager (ideas);
/* False if exitting */
if (ideas)
{
create_idea_list ();
dialog_unregister (ideas->window);
session_get_window_info (ideas->window, &document_index_session_info);
gtk_widget_destroy (ideas->window);
g_free (ideas);
ideas = 0;
}
}
static void
load_from_list (gpointer data,
gpointer data_null)
{
idea_add_in_position ((gchar *) data, -1);
idea_add_in_position (title, 0);
}
FILE *
idea_manager_parse_init (void)
{
FILE *fp = NULL;
FILE *fp;
gchar *desktopfile;
desktopfile = gimp_personal_rc_file ("ideas");
@ -218,7 +126,7 @@ idea_manager_parse_init (void)
gchar *
idea_manager_parse_line (FILE * fp)
{
gint length;
gint length;
gchar *filename;
length = getinteger (fp);
@ -234,7 +142,63 @@ idea_manager_parse_line (FILE * fp)
return NULL;
}
void
/* local functions */
static void
docindex_dnd_filenames_dropped (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time)
{
gint len;
gchar *data;
gchar *end;
switch (info)
{
case GIMP_DND_TYPE_URI_LIST:
data = (gchar *) selection_data->data;
len = selection_data->length;
while (len > 0)
{
end = strstr (data, "\x0D\x0A");
if (end != NULL)
*end = 0;
if (*data != '#')
{
gchar *filename = strchr (data, ':');
if (filename != NULL)
filename ++;
else
filename = data;
file_open (filename, filename);
}
if (end)
{
len -= end - data + 2;
data = end + 2;
}
else
len = 0;
}
break;
}
return;
}
static void
load_from_list (gpointer data,
gpointer data_null)
{
idea_add_in_position ((gchar *) data, -1);
}
static void
load_idea_manager (IdeaManager *ideas)
{
FILE *fp = NULL;
@ -268,14 +232,18 @@ load_idea_manager (IdeaManager *ideas)
}
}
else
gtk_widget_show (ideas->window);
{
gtk_widget_show (ideas->window);
}
}
static void
save_to_ideas (gpointer data,
gpointer user_data)
{
gchar *title = GTK_LABEL (GTK_BIN ((GtkWidget *) data)->child)->label;
gchar *title;
title = GTK_LABEL (GTK_BIN (data)->child)->label;
fprintf ((FILE *) user_data, "%d %s\n", strlen (title), title);
}
@ -284,15 +252,17 @@ static void
save_list_to_ideas (gpointer data,
gpointer user_data)
{
gchar *title = (gchar *) data;
gchar *title;
title = (gchar *) data;
fprintf ((FILE *) user_data, "%d %s\n", strlen (title), title);
}
void
static void
save_idea_manager (IdeaManager *ideas)
{
FILE *fp;
FILE *fp;
gchar *desktopfile;
/* open persistant desktop file. */
@ -304,14 +274,11 @@ save_idea_manager (IdeaManager *ideas)
{
if (ideas)
{
g_list_foreach (GTK_TREE (ideas->tree)->children, save_to_ideas, fp);
g_list_foreach (GTK_LIST (ideas->list)->children, save_to_ideas, fp);
}
else
else if (idea_list)
{
if (idea_list)
{
g_list_foreach (idea_list, save_list_to_ideas, fp);
}
g_list_foreach (idea_list, save_list_to_ideas, fp);
}
fclose (fp);
@ -322,7 +289,10 @@ static void
save_to_list (gpointer data,
gpointer null_data)
{
gchar *title = g_strdup (GTK_LABEL (GTK_BIN ((GtkWidget *) data)->child)->label);
gchar *title;
title = g_strdup (GTK_LABEL (GTK_BIN (data)->child)->label);
idea_list = g_list_append (idea_list, title);
}
@ -336,42 +306,35 @@ create_idea_list (void)
idea_list = 0;
}
g_list_foreach (GTK_TREE (ideas->tree)->children, save_to_list, NULL);
g_list_foreach (GTK_LIST (ideas->list)->children, save_to_list, NULL);
}
static gint
open_or_raise_callback (GtkWidget *widget,
GdkEventButton *event,
gpointer func_data )
gpointer func_data)
{
if (GTK_IS_TREE_ITEM (widget) &&
if (GTK_IS_LIST_ITEM (widget) &&
event->type == GDK_2BUTTON_PRESS)
{
open_or_raise (GTK_LABEL (GTK_BIN (widget)->child )->label);
open_or_raise (GTK_LABEL (GTK_BIN (widget)->child)->label);
}
return FALSE;
}
void
document_index_create (void)
{
if (ideas)
gdk_window_raise (ideas->window->window);
else
open_idea_window ();
}
static void
check_needed (gpointer data,
gpointer user_data)
{
GtkWidget *widget = (GtkWidget *) data;
struct bool_char_pair *pair = (struct bool_char_pair *) user_data;
BoolCharPair *pair;
if (strcmp (pair->string, GTK_LABEL (GTK_BIN (widget)->child )->label) == 0)
pair = (BoolCharPair *) user_data;
if (strcmp (pair->string, GTK_LABEL (GTK_BIN (data)->child)->label) == 0)
{
pair->boole = TRUE;
pair->data = data;
}
}
@ -379,80 +342,83 @@ static void
check_needed_list (gpointer data,
gpointer user_data)
{
struct bool_char_pair *pair = (struct bool_char_pair *) user_data;
BoolCharPair *pair;
if (strcmp (pair->string, (gchar *) data ) == 0)
pair = (BoolCharPair *) user_data;
if (strcmp (pair->string, (gchar *) data) == 0)
{
pair->boole = TRUE;
pair->data = data;
}
}
static void
idea_add_in_position_with_select (gchar *title,
gint position,
gboolean select )
gboolean select)
{
GtkWidget *treeitem;
struct bool_char_pair pair;
BoolCharPair pair;
pair.boole = FALSE;
pair.boole = FALSE;
pair.string = title;
pair.data = NULL;
if (ideas)
{
g_list_foreach (GTK_TREE (ideas->tree)->children, check_needed, &pair);
g_list_foreach (GTK_LIST (ideas->list)->children, check_needed, &pair);
if (! pair.boole)
{
treeitem = gtk_tree_item_new_with_label (title);
if (position < 0)
gtk_tree_append (GTK_TREE (ideas->tree), treeitem);
else
gtk_tree_insert (GTK_TREE (ideas->tree), treeitem, position);
GtkWidget *listitem;
GList *list = NULL;
gtk_signal_connect (GTK_OBJECT (treeitem),
"button_press_event",
listitem = gtk_list_item_new_with_label (title);
list = g_list_append (list, listitem);
if (position < 0)
gtk_list_append_items (GTK_LIST (ideas->list), list);
else
gtk_list_insert_items (GTK_LIST (ideas->list), list, position);
gtk_signal_connect (GTK_OBJECT (listitem), "button_press_event",
GTK_SIGNAL_FUNC (open_or_raise_callback),
NULL);
docindex_cell_configure_drop_on_widget (treeitem);
gtk_widget_show (treeitem);
gtk_widget_show (listitem);
if (select)
gtk_tree_select_item (GTK_TREE (ideas->tree),
gtk_tree_child_position (GTK_TREE (ideas->tree ), treeitem));
gtk_list_item_select (GTK_LIST_ITEM (listitem));
}
else /* move entry to top */
{
gchar *title;
title = g_strdup (GTK_LABEL (GTK_BIN (pair.data)->child)->label);
gtk_container_remove (GTK_CONTAINER (ideas->list),
GTK_WIDGET (pair.data));
idea_add_in_position_with_select (title, 0, TRUE);
g_free (title);
}
}
else
{
if (! idea_list)
{
FILE *fp = NULL;
gchar *desktopfile;
FILE *fp;
/* open persistant desktop file. */
desktopfile = gimp_personal_rc_file ("ideas");
fp = fopen (desktopfile, "r");
g_free (desktopfile);
fp = idea_manager_parse_init ();
/* Read in persistant desktop information. */
if (fp)
{
gchar *title;
gint length;
gchar *filename;
clear_white (fp);
while (!feof (fp) && !ferror (fp))
while ((filename = idea_manager_parse_line (fp)))
{
length = getinteger (fp);
title = g_malloc0 (length + 1);
title[fread (title, 1, length, fp)] = 0;
idea_list = g_list_append (idea_list, g_strdup (title));
g_free (title);
clear_white (fp);
idea_list = g_list_append (idea_list, g_strdup (filename));
g_free (filename);
}
fclose (fp);
}
}
@ -462,45 +428,133 @@ idea_add_in_position_with_select (gchar *title,
if (! pair.boole)
{
if (position < 0)
idea_list = g_list_append (idea_list, g_strdup (title));
idea_list = g_list_prepend (idea_list, g_strdup (title));
else
idea_list = g_list_insert (idea_list, g_strdup (title), position);
}
else /* move entry to top */
{
idea_list = g_list_remove (idea_list, pair.data);
g_free (pair.data);
idea_list = g_list_prepend (idea_list, g_strdup (title));
}
}
}
void
idea_add (gchar *title)
{
idea_add_in_position (title, 0);
}
void
static void
idea_add_in_position (gchar *title,
gint position)
{
idea_add_in_position_with_select (title, position, TRUE);
}
static void
raise_if_match (gpointer data,
gpointer user_data)
{
GDisplay *gdisp;
BoolCharPair *pair;
gdisp = (GDisplay *) data;
pair = (BoolCharPair *) user_data;
if (gdisp->gimage->has_filename &&
strcmp (pair->string, gdisp->gimage->filename) == 0)
{
pair->boole = TRUE;
gdk_window_raise (gdisp->shell->window);
}
}
static void
open_or_raise (gchar *file_name)
{
BoolCharPair pair;
pair.boole = FALSE;
pair.string = file_name;
pair.data = NULL;
gdisplays_foreach (raise_if_match, &pair);
if (! pair.boole)
{
file_open (file_name, file_name);
}
}
/* file parsing functions */
static gint
getinteger (FILE *fp)
{
gchar nextchar;
gint response = 0;
gboolean negative = FALSE;
while (isspace (nextchar = fgetc (fp)))
/* empty statement */ ;
if (nextchar == '-')
{
negative = TRUE;
while (isspace (nextchar = fgetc (fp)))
/* empty statement */ ;
}
for (; '0' <= nextchar && '9' >= nextchar; nextchar = fgetc (fp))
{
response *= 10;
response += nextchar - '0';
}
for (; isspace (nextchar); nextchar = fgetc (fp))
/* empty statement */ ;
ungetc (nextchar, fp);
if (negative)
response = -response;
return response;
}
static void
clear_white (FILE *fp)
{
gint nextchar;
while (isspace (nextchar = fgetc (fp)))
/* empty statement */ ;
if (nextchar != EOF)
ungetc (nextchar, fp);
}
/* toolbar / dialog callbacks */
static gint
idea_move (GtkWidget *widget,
gint distance,
gboolean select)
{
gint orig_position = g_list_index (GTK_TREE (ideas->tree)->children, widget);
gint position = orig_position + distance;
gint orig_position;
gint position;
gchar *title;
orig_position = g_list_index (GTK_LIST (ideas->list)->children, widget);
position = orig_position + distance;
if (position < 0)
position = 0;
if (position >= g_list_length (GTK_TREE (ideas->tree)->children))
position = g_list_length (GTK_TREE (ideas->tree)->children) - 1;
if (position >= g_list_length (GTK_LIST (ideas->list)->children))
position = g_list_length (GTK_LIST (ideas->list)->children) - 1;
if (position != orig_position)
{
title = g_strdup (GTK_LABEL (GTK_BIN (widget)->child )->label);
gtk_container_remove (GTK_CONTAINER (ideas->tree), widget);
title = g_strdup (GTK_LABEL (GTK_BIN (widget)->child)->label);
gtk_container_remove (GTK_CONTAINER (ideas->list), widget);
idea_add_in_position_with_select (title, position, select);
g_free (title);
}
@ -509,59 +563,201 @@ idea_move (GtkWidget *widget,
}
static void
idea_remove (GtkWidget *widget)
{
gint position = g_list_index (GTK_TREE (ideas->tree )->children, widget);
gtk_container_remove (GTK_CONTAINER (ideas->tree), widget);
if (g_list_length (GTK_TREE (ideas->tree)->children) - 1 < position)
position = g_list_length (GTK_TREE (ideas->tree)->children) - 1;
gtk_tree_select_item (GTK_TREE (ideas->tree), position);
}
void
idea_up_callback (GtkWidget *widget,
gpointer data)
{
GtkWidget *selected;
if (GTK_TREE (ideas->tree)->selection)
if (GTK_LIST (ideas->list)->selection)
{
selected = GTK_TREE (ideas->tree)->selection->data;
selected = GTK_LIST (ideas->list)->selection->data;
idea_move (selected, -1, TRUE);
}
}
void
static void
idea_down_callback (GtkWidget *widget,
gpointer data)
{
GtkWidget *selected;
if (GTK_TREE (ideas->tree)->selection)
if (GTK_LIST (ideas->list)->selection)
{
selected = GTK_TREE (ideas->tree)->selection->data;
selected = GTK_LIST (ideas->list)->selection->data;
idea_move (selected, 1, TRUE);
}
}
void
static void
idea_remove (GtkWidget *widget)
{
gint position;
position = g_list_index (GTK_LIST (ideas->list)->children, widget);
gtk_container_remove (GTK_CONTAINER (ideas->list), widget);
if (g_list_length (GTK_LIST (ideas->list)->children) - 1 < position)
position = g_list_length (GTK_LIST (ideas->list)->children) - 1;
gtk_list_select_item (GTK_LIST (ideas->list), position);
}
static void
idea_remove_callback (GtkWidget *widget,
gpointer data)
{
GtkWidget *selected;
if (GTK_TREE (ideas->tree)->selection)
if (GTK_LIST (ideas->list)->selection)
{
selected = GTK_TREE (ideas->tree)->selection->data;
selected = GTK_LIST (ideas->list)->selection->data;
idea_remove (selected);
}
}
void
close_idea_window (void)
static void
idea_hide_callback (GtkWidget *widget,
gpointer data)
{
if (ideas || idea_list)
save_idea_manager (ideas);
/* False if exitting */
if (ideas)
{
create_idea_list ();
dialog_unregister (ideas->window);
session_get_window_info (ideas->window, &document_index_session_info);
gtk_widget_destroy (ideas->window);
g_free (ideas);
ideas = 0;
}
}
static gboolean
idea_window_delete_event_callback (GtkWidget *widget,
GdkEvent *event,
gpointer data)
{
idea_hide_callback (NULL, NULL);
return TRUE;
}
static GtkWidget *
create_idea_toolbar (void)
{
GtkWidget *toolbar;
toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH);
gtk_toolbar_set_button_relief (GTK_TOOLBAR (toolbar), GTK_RELIEF_NONE);
gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
_("Open"),
_("Open a file"),
"Toolbar/Open",
NULL,
GTK_SIGNAL_FUNC (file_open_callback),
NULL);
gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
_("Up"),
_("Move the selected entry up in the index"),
"Toolbar/Up",
NULL,
GTK_SIGNAL_FUNC (idea_up_callback),
NULL);
gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
_("Down"),
_("Move the selected entry down in the index"),
"Toolbar/Down",
NULL,
GTK_SIGNAL_FUNC (idea_down_callback),
NULL);
gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
_("Remove"),
_("Remove the selected entry from the index"),
"Toolbar/Remove",
NULL,
GTK_SIGNAL_FUNC (idea_remove_callback),
NULL);
gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
_("Close"),
_("Close the Document Index"),
"Toolbar/Hide",
NULL,
GTK_SIGNAL_FUNC (idea_hide_callback),
NULL);
return toolbar;
}
static void
open_idea_window (void)
{
GtkWidget *main_vbox;
GtkWidget *scrolled_win;
GtkWidget *toolbar;
/* alloc idea_manager */
ideas = g_new0 (IdeaManager, 1);
ideas->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width (GTK_CONTAINER (ideas->window), 0);
gtk_window_set_title (GTK_WINDOW (ideas->window), _("Document Index"));
/* Connect the signals */
gtk_signal_connect (GTK_OBJECT (ideas->window), "delete_event",
GTK_SIGNAL_FUNC (idea_window_delete_event_callback),
NULL);
main_vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (ideas->window), main_vbox);
gtk_widget_show (main_vbox);
/* Toolbar */
toolbar = create_idea_toolbar ();
gtk_box_pack_start (GTK_BOX (main_vbox), toolbar, FALSE, FALSE, 0);
gtk_widget_show (toolbar);
/* Scrolled window */
scrolled_win = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS );
gtk_box_pack_start (GTK_BOX (main_vbox), scrolled_win, TRUE, TRUE, 0);
gtk_widget_show (scrolled_win);
/* Setup list */
ideas->list = gtk_list_new ();
gtk_list_set_selection_mode (GTK_LIST (ideas->list), GTK_SELECTION_BROWSE);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_win),
ideas->list);
gtk_widget_show (ideas->list);
gtk_drag_dest_set (ideas->window,
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_DROP,
drag_types, n_drag_types,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (ideas->window), "drag_data_received",
GTK_SIGNAL_FUNC (docindex_dnd_filenames_dropped),
NULL);
dialog_register (ideas->window);
session_set_window_geometry (ideas->window, &document_index_session_info,
TRUE);
/* Connect the "F1" help key */
gimp_help_connect_help_accel (ideas->window,
gimp_standard_help_func,
"dialogs/document_index.html");
/* Load and Show window */
load_idea_manager (ideas);
}

View File

@ -19,36 +19,12 @@
#include <gtk/gtk.h>
typedef struct
{
GtkWidget *window;
GtkWidget *tree;
} IdeaManager;
void document_index_create (void);
void document_index_free (void);
extern IdeaManager *ideas;
void document_index_create (void);
void close_idea_window (void);
void idea_add (gchar *label);
void idea_add_in_position (gchar *label,
gint position);
void idea_hide_callback (GtkWidget *widget, gpointer data);
void idea_up_callback (GtkWidget *widget, gpointer data);
void idea_down_callback (GtkWidget *widget, gpointer data);
void idea_remove_callback (GtkWidget *widget, gpointer data);
gboolean idea_window_delete_event_callback (GtkWidget *widget,
GdkEvent *event,
gpointer data);
void docindex_configure_drop_on_widget (GtkWidget *widget);
void idea_add (gchar *label);
FILE * idea_manager_parse_init (void);
gchar * idea_manager_parse_line (FILE *fp);
void load_idea_manager (IdeaManager *);
void save_idea_manager (IdeaManager *);
#endif /* __DOCINDEX_H__ */

View File

@ -1,205 +0,0 @@
/* docindexif.c - Interface file for the docindex for gimp.
*
* Copyright (C) 1998 Chris Lahey.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "config.h"
#include <ctype.h>
#include <string.h>
#include <gtk/gtk.h>
#include "dialog_handler.h"
#include "docindex.h"
#include "docindexif.h"
#include "fileops.h"
#include "gimage.h"
#include "gimphelp.h"
#include "session.h"
#include "libgimp/gimpintl.h"
static void
raise_if_match (gpointer data,
gpointer user_data)
{
GimpImage *gimage = GIMP_IMAGE (data);
struct bool_char_pair *pair = (struct bool_char_pair *) user_data;
if ((! pair->boole) && gimage->has_filename)
if (strcmp (pair->string, gimage->filename) == 0)
{
pair->boole = TRUE;
/* gdk_raise_window( NULL, gimage-> ); */ /* FIXME */
}
}
void
open_or_raise (gchar *file_name)
{
struct bool_char_pair pair;
pair.boole = FALSE;
pair.string = file_name;
gimage_foreach (raise_if_match, &pair);
if (! pair.boole)
{
file_open (file_name, file_name);
}
}
void
open_file_in_position (gchar *filename,
gint position)
{
file_open (filename, filename);
}
static GtkWidget *
create_idea_toolbar (void)
{
GtkWidget *toolbar;
toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH);
gtk_toolbar_set_button_relief (GTK_TOOLBAR (toolbar), GTK_RELIEF_NONE);
gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
_("Open"), _("Open a file"), "Toolbar/Open",
NULL,
(GtkSignalFunc) file_open_callback, NULL);
gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
_("Up"), _("Move the selected entry up in the index"), "Toolbar/Up",
NULL,
(GtkSignalFunc) idea_up_callback, NULL);
gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
_("Down"), _("Move the selected entry down in the index"), "Toolbar/Down",
NULL,
(GtkSignalFunc) idea_down_callback, NULL );
gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
_("Remove"), _("Remove the selected entry from the index"), "Toolbar/Remove",
NULL,
(GtkSignalFunc) idea_remove_callback, NULL );
gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
_("Close"), _("Close the Document Index"), "Toolbar/Hide",
NULL,
(GtkSignalFunc) idea_hide_callback, NULL );
return toolbar;
}
gint
getinteger (FILE *fp)
{
gchar nextchar;
gint response = 0;
gboolean negative = FALSE;
while (isspace (nextchar = fgetc (fp)))
/* empty statement */ ;
if (nextchar == '-')
{
negative = TRUE;
while (isspace (nextchar = fgetc (fp)))
/* empty statement */ ;
}
for (; '0' <= nextchar && '9' >= nextchar; nextchar = fgetc (fp))
{
response *= 10;
response += nextchar - '0';
}
for (; isspace (nextchar); nextchar = fgetc (fp))
/* empty statement */ ;
ungetc (nextchar, fp);
if (negative)
response = -response;
return response;
}
void
clear_white (FILE *fp)
{
gint nextchar;
while (isspace (nextchar = fgetc (fp)))
/* empty statement */ ;
if (nextchar != EOF)
ungetc (nextchar, fp);
}
void
open_idea_window (void)
{
GtkWidget *main_vbox;
GtkWidget *scrolled_win;
GtkWidget *toolbar;
/* alloc idea_manager */
ideas = g_new0 (IdeaManager, 1);
ideas->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width (GTK_CONTAINER (ideas->window), 0);
gtk_window_set_title (GTK_WINDOW (ideas->window), _("Document Index"));
/* Connect the signals */
gtk_signal_connect (GTK_OBJECT (ideas->window), "delete_event",
GTK_SIGNAL_FUNC (idea_window_delete_event_callback),
NULL);
main_vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (ideas->window), main_vbox);
gtk_widget_show (main_vbox);
/* Toolbar */
toolbar = create_idea_toolbar ();
gtk_box_pack_start (GTK_BOX (main_vbox), toolbar, FALSE, FALSE, 0);
gtk_widget_show (toolbar);
/* Scrolled window */
scrolled_win = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS );
gtk_box_pack_start (GTK_BOX (main_vbox), scrolled_win, TRUE, TRUE, 0);
gtk_widget_show (scrolled_win);
/* Setup tree */
ideas->tree = gtk_tree_new ();
gtk_tree_set_selection_mode (GTK_TREE (ideas->tree), GTK_SELECTION_BROWSE);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_win),
ideas->tree);
gtk_widget_show (ideas->tree);
docindex_configure_drop_on_widget (ideas->tree);
dialog_register (ideas->window);
session_set_window_geometry (ideas->window, &document_index_session_info,
TRUE);
/* Connect the "F1" help key */
gimp_help_connect_help_accel (ideas->window,
gimp_standard_help_func,
"dialogs/document_index.html");
/* Load and Show window */
load_idea_manager (ideas);
}

View File

@ -1,33 +0,0 @@
/* docindexif.h - Interface file for the docindex for gimp.
*
* Copyright (C) 1998 Chris Lahey.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef __DOCINDEXIF_H__
#define __DOCINDEXIF_H__
#include <stdio.h>
struct bool_char_pair
{
gboolean boole;
gchar *string;
};
void open_idea_window (void);
void open_or_raise (gchar *file_name);
void open_file_in_position (gchar *filename,
gint position);
void clear_white (FILE *fp);
gint getinteger (FILE *fp);
#endif /* __DOCINDEXIF_H__ */

View File

@ -29,7 +29,6 @@ app/desaturate.c
app/devices.c
app/disp_callbacks.c
app/docindex.c
app/docindexif.c
app/dodgeburn.c
app/edit_selection.c
app/equalize.c