Commit c53bbcab authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

Made the document index a bit more like the rest of the dialogs:

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

	Made the document index a bit more like the rest of the dialogs:

	* app/commands.[ch]
	* app/menus.c: added a cmd_callback instead of calling a function
	in docindex.c directly.

	* app/gimprc.c
	* app/session.[ch]: added proper session management.

	* app/app_procs.c
	* app/docindex.[ch]
	* app/docindexif.[ch]: removed another bunch of useless variables
	and functions. Removed the status bar because it was not telling
	very useful stuff. Removed the window position/size from the
	"ideas" file.

	Note: you have to either remove your ~/.gimp-1.1/ideas file or
	remove it's first line or experience a nice endless loop :)
parent 53238ebc
2000-05-05 Michael Natterer <mitch@gimp.org>
Made the document index a bit more like the rest of the dialogs:
* app/commands.[ch]
* app/menus.c: added a cmd_callback instead of calling a function
in docindex.c directly.
* app/gimprc.c
* app/session.[ch]: added proper session management.
* app/app_procs.c
* app/docindex.[ch]
* app/docindexif.[ch]: removed another bunch of useless variables
and functions. Removed the status bar because it was not telling
very useful stuff. Removed the window position/size from the
"ideas" file.
Note: you have to either remove your ~/.gimp-1.1/ideas file or
remove it's first line or experience a nice endless loop :)
2000-05-05 Michael Natterer <mitch@gimp.org>
 
* app/docindex.[ch]
......
......@@ -27,6 +27,7 @@
#include "convert.h"
#include "desaturate.h"
#include "devices.h"
#include "docindex.h"
#include "channel_ops.h"
#include "drawable.h"
#include "equalize.h"
......@@ -1198,6 +1199,13 @@ dialogs_device_status_cmd_callback (GtkWidget *widget,
device_status_create ();
}
void
dialogs_document_index_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
document_index_create ();
}
void
dialogs_error_console_cmd_callback (GtkWidget *widget,
gpointer client_data)
......
......@@ -122,6 +122,7 @@ void dialogs_palette_cmd_callback (GtkWidget *, gpointer);
void dialogs_indexed_palette_cmd_callback (GtkWidget *, gpointer);
void dialogs_input_devices_cmd_callback (GtkWidget *, gpointer);
void dialogs_device_status_cmd_callback (GtkWidget *, gpointer);
void dialogs_document_index_cmd_callback (GtkWidget *, gpointer);
void dialogs_error_console_cmd_callback (GtkWidget *, gpointer);
void dialogs_display_filters_cmd_callback (GtkWidget *, gpointer);
void dialogs_undo_history_cmd_callback (GtkWidget *, gpointer);
......
......@@ -593,11 +593,11 @@ app_init (void)
* elements of the docindex
*/
{
FILE *fp;
FILE *fp;
gchar **filenames = g_new (gchar *, last_opened_size);
gint dummy, i;
gint i;
if ((fp = idea_manager_parse_init (&dummy, &dummy, &dummy, &dummy)))
if ((fp = idea_manager_parse_init ()))
{
/* read the filenames... */
for (i = 0; i < last_opened_size; i++)
......
......@@ -27,6 +27,7 @@
#include "convert.h"
#include "desaturate.h"
#include "devices.h"
#include "docindex.h"
#include "channel_ops.h"
#include "drawable.h"
#include "equalize.h"
......@@ -1198,6 +1199,13 @@ dialogs_device_status_cmd_callback (GtkWidget *widget,
device_status_create ();
}
void
dialogs_document_index_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
document_index_create ();
}
void
dialogs_error_console_cmd_callback (GtkWidget *widget,
gpointer client_data)
......
......@@ -122,6 +122,7 @@ void dialogs_palette_cmd_callback (GtkWidget *, gpointer);
void dialogs_indexed_palette_cmd_callback (GtkWidget *, gpointer);
void dialogs_input_devices_cmd_callback (GtkWidget *, gpointer);
void dialogs_device_status_cmd_callback (GtkWidget *, gpointer);
void dialogs_document_index_cmd_callback (GtkWidget *, gpointer);
void dialogs_error_console_cmd_callback (GtkWidget *, gpointer);
void dialogs_display_filters_cmd_callback (GtkWidget *, gpointer);
void dialogs_undo_history_cmd_callback (GtkWidget *, gpointer);
......
......@@ -12,6 +12,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "config.h"
#include <string.h>
#include <stdlib.h>
......@@ -22,14 +24,16 @@
#include "docindex.h"
#include "gimpdnd.h"
#include "gimprc.h"
#include "session.h"
#include "config.h"
#include "libgimp/gimpenv.h"
#include "libgimp/gimpintl.h"
idea_manager *ideas = NULL;
IdeaManager *ideas = NULL;
static GList *idea_list = NULL; /* of gchar *. */
static gint x = 0, y = 0, width = 0, height = 0;
static GtkTargetEntry drag_types[] =
{
......@@ -38,8 +42,7 @@ static GtkTargetEntry drag_types[] =
static gint n_drag_types = sizeof (drag_types) / sizeof (drag_types[0]);
static void create_idea_list (void);
void docindex_configure_drop_on_widget (GtkWidget * widget);
void docindex_cell_configure_drop_on_widget (GtkWidget * widget);
static void docindex_cell_configure_drop_on_widget (GtkWidget * widget);
static void
......@@ -180,7 +183,7 @@ void
idea_hide_callback (GtkWidget *widget,
gpointer data)
{
if (ideas || idea_list || width || height)
if (ideas || idea_list)
save_idea_manager (ideas);
/* False if exitting */
......@@ -188,18 +191,13 @@ idea_hide_callback (GtkWidget *widget,
{
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;
}
}
void
open_idea_window (void)
{
make_idea_window (-1, -1);
}
static void
load_from_list (gpointer data,
gpointer data_null)
......@@ -208,27 +206,14 @@ load_from_list (gpointer data,
}
FILE *
idea_manager_parse_init (/* RETURNS: */
gint *window_x,
gint *window_y,
gint *window_width,
gint *window_height)
idea_manager_parse_init (void)
{
FILE *fp = NULL;
FILE *fp = NULL;
gchar *desktopfile;
desktopfile = gimp_personal_rc_file ("ideas");
fp = fopen (desktopfile, "r");
g_free (desktopfile);
/* Read in persistant desktop information. */
if (fp)
{
*window_x = getinteger (fp);
*window_y = getinteger (fp);
*window_width = getinteger (fp);
*window_height = getinteger (fp);
}
return fp;
}
......@@ -253,24 +238,23 @@ idea_manager_parse_line (FILE * fp)
}
void
load_idea_manager (idea_manager *ideas)
load_idea_manager (IdeaManager *ideas)
{
FILE *fp = NULL;
if ( ! idea_list )
fp = idea_manager_parse_init (&x, &y, &width, &height);
if (! idea_list)
fp = idea_manager_parse_init ();
if (idea_list || fp)
{
gtk_widget_set_usize (ideas->window, width, height);
gtk_widget_show (ideas->window);
gtk_widget_set_uposition (ideas->window, x, y);
gtk_idle_add (reset_usize, ideas->window);
if (fp)
{
gchar *title;
clear_white (fp);
while ((title = idea_manager_parse_line (fp)))
{
idea_add_in_position (title, -1);
......@@ -309,7 +293,7 @@ save_list_to_ideas (gpointer data,
}
void
save_idea_manager (idea_manager *ideas)
save_idea_manager (IdeaManager *ideas)
{
FILE *fp;
gchar *desktopfile;
......@@ -323,22 +307,12 @@ save_idea_manager (idea_manager *ideas)
{
if (ideas)
{
gint x, y, width, height;
gdk_window_get_geometry (ideas->window->window,
&x, &y, &width, &height, NULL);
gdk_window_get_origin (ideas->window->window, &x, &y);
fprintf (fp, "%d %d %d %d\n", x, y, width, height);
g_list_foreach (GTK_TREE (ideas->tree)->children, save_to_ideas, fp);
}
else
{
if (idea_list)
{
fprintf (fp, "%d %d %d %d\n", x, y, width, height);
g_list_foreach (idea_list, save_list_to_ideas, fp);
}
}
......@@ -358,10 +332,6 @@ save_to_list (gpointer data,
static void
create_idea_list (void)
{
gdk_window_get_geometry (ideas->window->window,
&x, &y, &width, &height, NULL);
gdk_window_get_origin (ideas->window->window, &x, &y);
if (idea_list)
{
g_list_foreach (idea_list, (GFunc) g_free, NULL);
......@@ -387,8 +357,7 @@ open_or_raise_callback (GtkWidget *widget,
}
void
raise_idea_callback (GtkWidget *widget,
gpointer data)
document_index_create (void)
{
if (ideas)
gdk_window_raise (ideas->window->window);
......@@ -476,11 +445,6 @@ idea_add_in_position_with_select (gchar *title,
gchar *title;
gint length;
x = getinteger (fp);
y = getinteger (fp);
width = getinteger (fp);
height = getinteger (fp);
clear_white (fp);
while (!feof (fp) && !ferror (fp))
......@@ -569,13 +533,8 @@ idea_up_callback (GtkWidget *widget,
if (GTK_TREE (ideas->tree)->selection)
{
selected = GTK_TREE (ideas->tree)->selection->data;
if (idea_move (selected, -1, TRUE) != -1)
gtk_statusbar_push (GTK_STATUSBAR (ideas->status), ideas->contextid,
_("This file cannot be moved up."));
idea_move (selected, -1, TRUE);
}
else
gtk_statusbar_push (GTK_STATUSBAR (ideas->status), ideas->contextid,
_("There's no selection to move up."));
}
void
......@@ -587,13 +546,8 @@ idea_down_callback (GtkWidget *widget,
if (GTK_TREE (ideas->tree)->selection)
{
selected = GTK_TREE (ideas->tree)->selection->data;
if (idea_move (selected, 1, TRUE) != 1)
gtk_statusbar_push (GTK_STATUSBAR (ideas->status), ideas->contextid,
_("This file cannot be moved down."));
idea_move (selected, 1, TRUE);
}
else
gtk_statusbar_push (GTK_STATUSBAR (ideas->status), ideas->contextid,
_("There's no selection to move down."));
}
void
......@@ -607,9 +561,6 @@ idea_remove_callback (GtkWidget *widget,
selected = GTK_TREE (ideas->tree)->selection->data;
idea_remove (selected);
}
else
gtk_statusbar_push (GTK_STATUSBAR (ideas->status), ideas->contextid,
_("There's no selection to remove."));
}
void
......
......@@ -19,33 +19,18 @@
#include <gtk/gtk.h>
typedef struct idea_manager
typedef struct
{
/* The scrollbar */
GtkWidget *vscrollbar;
/* The GTK window */
GtkWidget *window;
GtkWidget *tree;
/* The window menu widget */
GtkWidget *window_menu;
/* The status bar widget */
GtkWidget *status;
/* The main status context id */
guint contextid;
gboolean changed;
gboolean named;
gint auto_save;
gint long_term_auto_save;
gint count;
} idea_manager;
} IdeaManager;
void raise_idea_callback (GtkWidget *widget,
gpointer data);
extern IdeaManager *ideas;
void document_index_create (void);
void make_idea_window (gint x,
gint y);
void open_idea_window (void);
void close_idea_window (void);
void idea_add (gchar *label);
void idea_add_in_position (gchar *label,
gint position);
......@@ -60,15 +45,10 @@ gboolean idea_window_delete_event_callback (GtkWidget *widget,
gpointer data);
void docindex_configure_drop_on_widget (GtkWidget *widget);
FILE * idea_manager_parse_init (gint *window_x,
gint *window_y,
gint *window_width,
gint *window_height);
FILE * idea_manager_parse_init (void);
gchar * idea_manager_parse_line (FILE *fp);
void load_idea_manager (idea_manager *);
void save_idea_manager (idea_manager *);
extern idea_manager *ideas;
void load_idea_manager (IdeaManager *);
void save_idea_manager (IdeaManager *);
#endif /* __DOCINDEX_H__ */
......@@ -12,6 +12,8 @@
* 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>
......@@ -23,11 +25,12 @@
#include "fileops.h"
#include "gimage.h"
#include "gimphelp.h"
#include "session.h"
#include "config.h"
#include "libgimp/gimpintl.h"
void
static void
raise_if_match (gpointer data,
gpointer user_data)
{
......@@ -59,25 +62,20 @@ open_or_raise (gchar *file_name)
}
}
void open_file_in_position (gchar *filename,
gint position)
void
open_file_in_position (gchar *filename,
gint position)
{
file_open (filename, filename);
}
GtkMenuFactory *create_idea_menu ()
{
return NULL;
}
GtkWidget *
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_widget_show (toolbar);
gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
_("Open"), _("Open a file"), "Toolbar/Open",
......@@ -103,22 +101,8 @@ create_idea_toolbar (void)
_("Close"), _("Close the Document Index"), "Toolbar/Hide",
NULL,
(GtkSignalFunc) idea_hide_callback, NULL );
return toolbar;
}
gchar *append2 (gchar *string1,
gboolean del1,
gchar *string2,
gboolean del2)
{
gchar *newstring = g_strconcat (string1, string2, NULL);
if (del1)
g_free (string1);
if (del2)
g_free (string2);
return newstring;
return toolbar;
}
gint
......@@ -163,87 +147,59 @@ clear_white (FILE *fp)
ungetc (nextchar, fp);
}
/* reset_usize
* A callback so that the window can be resized smaller. */
gint
reset_usize (gpointer data)
{
gtk_widget_set_usize (GTK_WIDGET (data), 0, 0);
return FALSE;
}
void
make_idea_window (gint x,
gint y)
open_idea_window (void)
{
GtkWidget *main_vbox;
GtkWidget *scrolled_win;
GtkWidget *toolbar;
/* malloc idea_manager */
ideas = g_new0 (idea_manager, 1);
/* alloc idea_manager */
ideas = g_new0 (IdeaManager, 1);
/* Setup tree */
ideas->tree = gtk_tree_new ();
gtk_tree_set_selection_mode (GTK_TREE (ideas->tree), GTK_SELECTION_BROWSE);
/* Setup 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_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_win),
ideas->tree);
gtk_widget_show (ideas->tree);
/* allocate the window and attach the menu */
ideas->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
/* Setup the status bar */
ideas->status = gtk_statusbar_new ();
ideas->contextid =
gtk_statusbar_get_context_id (GTK_STATUSBAR (ideas->status),
"main context");
/* Setup the toolbar */
toolbar = create_idea_toolbar ();
/* Setup a vbox to contain the menu */
main_vbox = gtk_vbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (main_vbox), toolbar, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (main_vbox), scrolled_win, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (main_vbox), ideas->status, FALSE, FALSE, 0);
gtk_widget_show (scrolled_win);
gtk_widget_show (ideas->status);
/* Set the GtkWindow title */
gtk_container_set_border_width (GTK_CONTAINER (ideas->window), 0);
gtk_window_set_title (GTK_WINDOW (ideas->window), _("Document Index"));
/* Set the initial status message */
gtk_statusbar_push (GTK_STATUSBAR (ideas->status), ideas->contextid, "");
/* Connect the signals */
gtk_signal_connect (GTK_OBJECT (ideas->window), "delete_event",
GTK_SIGNAL_FUNC (idea_window_delete_event_callback),
NULL);
/* Add the main vbox to the window */
gtk_container_set_border_width (GTK_CONTAINER (ideas->window), 0);
main_vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (ideas->window), main_vbox);
gtk_widget_show (main_vbox);
docindex_configure_drop_on_widget (ideas->tree);
/* Toolbar */
toolbar = create_idea_toolbar ();
gtk_box_pack_start (GTK_BOX (main_vbox), toolbar, FALSE, FALSE, 0);
gtk_widget_show (toolbar);
/* Load and Show window */
load_idea_manager (ideas);
/* 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);
/* Set the position of the window if it was requested */
if (x >= 0 && y >= 0)
gtk_widget_set_uposition (ideas->window, x, y);
/* 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");
dialog_register (ideas->window);
/* Load and Show window */
load_idea_manager (ideas);
}
......@@ -23,18 +23,11 @@ struct bool_char_pair
gchar *string;
};
void open_or_raise (gchar *file_name);
void raise_if_match (gpointer data,
gpointer user_data);
void open_file_in_position (gchar *filename,
gint position);
GtkWidget * create_idea_toolbar (void);
void clear_white (FILE *fp);
int getinteger (FILE *fp);
gchar * append2 (gchar *string1,
gboolean del1,
gchar *string2,
gboolean del2);
gint reset_usize (gpointer data);
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__ */
......@@ -346,7 +346,8 @@ static SessionInfo *session_infos[] =
&pattern_select_session_info,
&gradient_select_session_info,
&device_status_session_info,
&error_console_session_info
&error_console_session_info,
&document_index_session_info
};
static int nsession_infos = sizeof (session_infos) / sizeof (session_infos[0]);
......
......@@ -27,6 +27,7 @@
#include "convert.h"
#include "desaturate.h"
#include "devices.h"
#include "docindex.h"
#include "channel_ops.h"
#include "drawable.h"
#include "equalize.h"
......@@ -1198,6 +1199,13 @@ dialogs_device_status_cmd_callback (GtkWidget *widget,
device_status_create ();
}
void
dialogs_document_index_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
document_index_create ();
}