Commit 4e7ee15f authored by Naba Kumar's avatar Naba Kumar

Load project seperately from session, so that project session is also

	* src/anjuta.c: Load project seperately from session,
	so that project session is also loaded.
	
	* plugins/profile-default/plugin.c: Load project in new
	anjuta if there already is one loaded currently (disabled
	code for now).
	
	* plugins/editor/aneditor.cxx: Disconnect focus in/out
	signals when editor is destroyed. Fixes a crash bug.
	
	* plugins/editor/text_editor.c: Do not mark line in
	ianjuta_editor_goto_line() implementation.
	
	* plugins/search/search-replace.c: Always check for markable
	interface availablility because its optional for an editor.
	
	* plugins/document-manager/goto_line.c,
	plugins/document-manager/action-callbacks.c: Mark lines for
	goto line commands (from dialog and from menu entry box).
	
	* plugins/file-manager/plugin.c, plugins/file-manager/plugin.h,
	plugins/file-manager/an_file_view.c: Expand file manager
	nodes in idle loop, one at a time. Did as a possible work
	around for bug #361763, but it didn't make any difference.
	However, it could still be useful in situations where there
	are lots to expand.
	
	* libanjuta/anjuta-serializer.c: Avoid an unnecessary warning.


svn path=/trunk/; revision=2736
parent 0a1c7c83
2007-01-11 Naba Kumar <naba@gnome.org>
* src/anjuta.c: Load project seperately from session,
so that project session is also loaded.
* plugins/profile-default/plugin.c: Load project in new
anjuta if there already is one loaded currently (disabled
code for now).
* plugins/editor/aneditor.cxx: Disconnect focus in/out
signals when editor is destroyed. Fixes a crash bug.
* plugins/editor/text_editor.c: Do not mark line in
ianjuta_editor_goto_line() implementation.
* plugins/search/search-replace.c: Always check for markable
interface availablility because its optional for an editor.
* plugins/document-manager/goto_line.c,
plugins/document-manager/action-callbacks.c: Mark lines for
goto line commands (from dialog and from menu entry box).
* plugins/file-manager/plugin.c, plugins/file-manager/plugin.h,
plugins/file-manager/an_file_view.c: Expand file manager
nodes in idle loop, one at a time. Did as a possible work
around for bug #361763, but it didn't make any difference.
However, it could still be useful in situations where there
are lots to expand.
* libanjuta/anjuta-serializer.c: Avoid an unnecessary warning.
2007-01-11 Naba Kumar <naba@gnome.org>
* plugins/editor/scintilla/LineMarker.h,
......
......@@ -90,8 +90,10 @@ anjuta_serializer_set_property (GObject * object,
self->priv->stream = fopen (self->priv->filepath, "w");
if (self->priv->stream == NULL)
{
/*
g_warning ("Could not open %s for serialization: %s",
self->priv->filepath, g_strerror (errno));
*/
}
break;
default:
......
......@@ -22,6 +22,7 @@
#include <libanjuta/anjuta-ui.h>
#include <libanjuta/anjuta-utils.h>
#include <libanjuta/interfaces/ianjuta-markable.h>
#include <libanjuta/interfaces/ianjuta-editor.h>
#include <libanjuta/interfaces/ianjuta-editor-selection.h>
#include <libanjuta/interfaces/ianjuta-editor-convert.h>
......@@ -674,15 +675,14 @@ on_toolbar_goto_clicked (GtkAction *action, gpointer user_data)
{
line = atoi (line_ascii);
ianjuta_editor_goto_line(te, line, NULL);
/* FIXME
if (text_editor_goto_line (te, line, TRUE, TRUE) == FALSE)
if (IANJUTA_IS_MARKABLE (te))
{
GtkWidget *parent;
parent = gtk_widget_get_toplevel (GTK_WIDGET (te));
anjuta_util_dialog_error (GTK_WINDOW (parent),
_("There is no line number %d in \"%s\"."),
line, te->filename);
}*/
ianjuta_markable_delete_all_markers (IANJUTA_MARKABLE (te),
IANJUTA_MARKABLE_BASIC,
NULL);
ianjuta_markable_mark (IANJUTA_MARKABLE (te),
line, IANJUTA_MARKABLE_BASIC, NULL);
}
}
}
......
......@@ -24,6 +24,7 @@
#include <gnome.h>
#include <libanjuta/resources.h>
#include <libanjuta/interfaces/ianjuta-markable.h>
#include "goto_line.h"
......@@ -173,6 +174,14 @@ on_go_to_line_response (GtkDialog* dialog, gint response, gpointer user_data)
num = atoi (gtk_entry_get_text (ne));
if (te)
ianjuta_editor_goto_line (te, num, NULL);
if (IANJUTA_IS_MARKABLE (te))
{
ianjuta_markable_delete_all_markers (IANJUTA_MARKABLE (te),
IANJUTA_MARKABLE_BASIC,
NULL);
ianjuta_markable_mark (IANJUTA_MARKABLE (te),
num, IANJUTA_MARKABLE_BASIC, NULL);
}
}
gtk_widget_hide (GTK_WIDGET(dialog));
}
......@@ -3150,6 +3150,13 @@ aneditor_destroy(AnEditorID id)
/* We'll simply make it NULL to indicate that the */
/* editor is destroyed */
g_list_nth(editors, id)->data = NULL;
/* Disconnect the focus in/out signals */
g_signal_handlers_disconnect_by_func (ed->GetID(),
(void*)G_CALLBACK(on_aneditor_focus_in), ed);
g_signal_handlers_disconnect_by_func (ed->GetID(),
(void*)G_CALLBACK(on_aneditor_focus_out), ed);
delete ed;
}
......@@ -3190,13 +3197,15 @@ aneditor_set_parent(AnEditorID id, AnEditorID parent_id)
editor->SetParent(parent);
}
gint on_aneditor_focus_in(GtkWidget* widget, gpointer* unused, AnEditor* ed)
gint
on_aneditor_focus_in (GtkWidget* widget, gpointer* unused, AnEditor* ed)
{
ed->FocusInEvent(widget);
return FALSE;
}
gint on_aneditor_focus_out(GtkWidget* widget, gpointer * unused, AnEditor* ed)
gint
on_aneditor_focus_out (GtkWidget* widget, gpointer * unused, AnEditor* ed)
{
ed->EndDebugEval();
ed->FocusOutEvent(widget);
......
......@@ -2075,7 +2075,7 @@ itext_editor_set_use_spaces (IAnjutaEditor *editor, gboolean use_spaces, GError
static void
itext_editor_goto_line (IAnjutaEditor *editor, gint lineno, GError **e)
{
text_editor_goto_line (TEXT_EDITOR (editor), lineno, TRUE, TRUE);
text_editor_goto_line (TEXT_EDITOR (editor), lineno, FALSE, TRUE);
}
static void
......
......@@ -572,7 +572,7 @@ fv_add_tree_entry (FileManagerPlugin *fv, const gchar *path, GtkTreeIter *root)
{
ignore_files = g_list_prepend (ignore_files,
g_strdup (*ptrv));
DEBUG_PRINT ("Ignoring: %s", *ptrv);
/* DEBUG_PRINT ("Ignoring: %s", *ptrv); */
ptrv++;
}
g_strfreev (strv);
......@@ -627,6 +627,7 @@ fv_add_tree_entry (FileManagerPlugin *fv, const gchar *path, GtkTreeIter *root)
REV_COLUMN, "",
-1);
} else {
/* DEBUG_PRINT ("Rendering file: %s", file); */
files = g_slist_prepend (files, g_strdup (file));
}
}
......@@ -948,6 +949,7 @@ fv_finalize (FileManagerPlugin *fv)
/* Object will be destroyed when removed from container */
/* gtk_widget_destroy (fv->scrolledwindow); */
fv_cancel_node_expansion (fv);
fv->top_dir = NULL;
fv->tree = NULL;
fv->scrolledwindow = NULL;
......@@ -987,28 +989,73 @@ fv_get_node_expansion_states (FileManagerPlugin *fv)
return map;
}
static gboolean
on_fv_node_expansion_on_idle (gpointer user_data)
{
GtkTreePath *path;
GtkTreeModel *model;
FileManagerPlugin *fv = ANJUTA_PLUGIN_FILE_MANAGER (user_data);
gchar *node_path = (gchar*)fv->nodes_to_expand->data;
fv->nodes_to_expand = g_list_remove (fv->nodes_to_expand,
node_path);
/* Expand node_path */
model = gtk_tree_view_get_model (GTK_TREE_VIEW (fv->tree));
path = gtk_tree_path_new_from_string (node_path);
DEBUG_PRINT ("Expanding node: %s", node_path);
gtk_tree_view_expand_row (GTK_TREE_VIEW (fv->tree), path, FALSE);
/* Clean up */
gtk_tree_path_free (path);
g_free (node_path);
/* End of this cycle */
if (fv->nodes_to_expand == NULL)
return FALSE; /* End */
else
return TRUE; /* Continue */
}
static void
fv_queue_node_expansion (FileManagerPlugin *fv, const gchar *node_path)
{
fv->nodes_to_expand = g_list_append (fv->nodes_to_expand,
g_strdup (node_path));
if (fv->idle_id <= 0)
fv->idle_id = g_idle_add (on_fv_node_expansion_on_idle, fv);
}
void
fv_set_node_expansion_states (FileManagerPlugin *fv, GList *expansion_states)
{
/* Restore expanded nodes */
/* Queue expanded nodes */
if (expansion_states)
{
GtkTreePath *path;
GtkTreeModel *model;
GList *node;
node = expansion_states;
model = gtk_tree_view_get_model (GTK_TREE_VIEW (fv->tree));
while (node)
{
path = gtk_tree_path_new_from_string (node->data);
gtk_tree_view_expand_row (GTK_TREE_VIEW (fv->tree), path, FALSE);
gtk_tree_path_free (path);
fv_queue_node_expansion (fv, (gchar *)node->data);
node = g_list_next (node);
}
}
}
void
fv_cancel_node_expansion (FileManagerPlugin *fv)
{
if (fv->idle_id)
g_source_remove (fv->idle_id);
fv->idle_id = 0;
if (fv->nodes_to_expand)
{
g_list_foreach (fv->nodes_to_expand, (GFunc)g_free, NULL);
g_list_free (fv->nodes_to_expand);
fv->nodes_to_expand = NULL;
}
}
void
fv_set_root (FileManagerPlugin *fv, const gchar *root_dir)
{
......@@ -1034,12 +1081,16 @@ fv_refresh (FileManagerPlugin *fv, gboolean save_states)
GtkTreeStore *store;
GdkPixbuf *pixbuf;
gchar *project_dir;
gchar *root_node_path;
if (busy)
return;
else
busy = TRUE;
/* Make sure node expansion is stoped */
fv_cancel_node_expansion (fv);
if (icon_set == NULL)
icon_set = gdl_icons_new (16);
if (ff != NULL)
......@@ -1048,7 +1099,7 @@ fv_refresh (FileManagerPlugin *fv, gboolean save_states)
fv_disconnect (fv);
if (save_states)
selected_items = fv_get_node_expansion_states (fv);
selected_items = fv_get_node_expansion_states (fv);
fv_clear (fv);
project_dir = g_path_get_basename (fv->top_dir);
......@@ -1073,14 +1124,21 @@ fv_refresh (FileManagerPlugin *fv, gboolean save_states)
REV_COLUMN, "",
-1);
/* Expand first node */
gtk_tree_model_get_iter_first (model, &iter);
path = gtk_tree_model_get_path (model, &iter);
gtk_tree_view_expand_row (GTK_TREE_VIEW (fv->tree), path, FALSE);
gtk_tree_path_free (path);
if (save_states)
fv_set_node_expansion_states (fv, selected_items);
{
fv_set_node_expansion_states (fv, selected_items);
}
else
{
/* Expand first node */
gtk_tree_model_get_iter_first (model, &iter);
path = gtk_tree_model_get_path (model, &iter);
root_node_path = gtk_tree_path_to_string (path);
fv_queue_node_expansion (fv, root_node_path);
gtk_tree_path_free (path);
g_free (root_node_path);
}
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model),
GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
GTK_SORT_ASCENDING);
......
......@@ -158,6 +158,9 @@ activate_plugin (AnjutaPlugin *plugin)
fm_plugin->prefs = anjuta_shell_get_preferences (plugin->shell, NULL);
fv_init (fm_plugin);
fm_plugin->idle_id = 0;
fm_plugin->nodes_to_expand = NULL;
/* Add action group */
fm_plugin->action_group =
anjuta_ui_add_action_group_entries (fm_plugin->ui,
......
......@@ -34,6 +34,10 @@ struct _FileManagerPlugin{
GtkWidget *tooltip_window;
gulong tooltip_timeout;
PangoLayout *tooltip_layout;
/* Idle node expansion context */
GList *nodes_to_expand;
gint idle_id;
};
struct _FileManagerPluginClass{
......@@ -43,18 +47,14 @@ struct _FileManagerPluginClass{
void fv_init (FileManagerPlugin *fv);
void fv_finalize (FileManagerPlugin *fv);
void fv_set_root (FileManagerPlugin *fv, const gchar *root_dir);
void fv_clear (FileManagerPlugin *fv);
GList* fv_get_node_expansion_states (FileManagerPlugin *fv);
void fv_set_node_expansion_states (FileManagerPlugin *fv,
GList *expansion_states);
gchar* fv_get_selected_file_path (FileManagerPlugin *fv);
void fv_refresh (FileManagerPlugin *fv, gboolean save_states);
void fv_set_root (FileManagerPlugin *fv, const gchar *root_dir);
void fv_clear (FileManagerPlugin *fv);
GList* fv_get_node_expansion_states (FileManagerPlugin *fv);
void fv_set_node_expansion_states (FileManagerPlugin *fv,
GList *expansion_states);
gchar* fv_get_selected_file_path (FileManagerPlugin *fv);
// void fv_customize(gboolean really_show);
// gboolean fv_open_file (const char *path, gboolean use_anjuta);
// void fv_session_save (ProjectDBase *p);
// void fv_session_load (ProjectDBase *p);
void fv_refresh (FileManagerPlugin *fv, gboolean save_states);
void fv_cancel_node_expansion (FileManagerPlugin *fv);
#endif
......@@ -972,7 +972,16 @@ ifile_open (IAnjutaFile *ifile, const gchar* uri,
GSList *selected_plugins, *temp_plugins;
plugin = ANJUTA_PLUGIN_DEFAULT_PROFILE (ifile);
#if 1 /* Enable it now */
/* If there is already a project loaded, load in separate anjuta window */
if (plugin->project_uri)
{
gchar *cmd = g_strconcat ("anjuta --no-splash --no-client ", uri, NULL);
anjuta_util_execute_shell (NULL, cmd);
g_free (cmd);
return;
}
#endif
/* Load system default plugins */
selected_plugins = default_profile_plugin_read (plugin,
plugin->default_profile);
......
......@@ -329,7 +329,7 @@ search_and_replace (void)
fb->pos = se->start_pos;
offset = 0;
if (s->action == SA_BOOKMARK)
if (s->action == SA_BOOKMARK && IANJUTA_IS_MARKABLE (fb->te))
ianjuta_markable_delete_all_markers(IANJUTA_MARKABLE(fb->te),
IANJUTA_MARKABLE_ATTENTIVE, NULL);
if (s->action == SA_HIGHLIGHT)
......@@ -373,10 +373,13 @@ search_and_replace (void)
if (found_line != mi->line + 1)
{
ianjuta_markable_mark (IANJUTA_MARKABLE(fb->te),
mi->line + 1,
IANJUTA_MARKABLE_ATTENTIVE,
NULL);
if (IANJUTA_IS_MARKABLE (fb->te))
{
ianjuta_markable_mark (IANJUTA_MARKABLE(fb->te),
mi->line + 1,
IANJUTA_MARKABLE_ATTENTIVE,
NULL);
}
found_line = mi->line + 1;
}
break;
......
......@@ -18,12 +18,14 @@
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <string.h>
#include <libanjuta/anjuta-shell.h>
#include <libanjuta/anjuta-debug.h>
#include <libanjuta/anjuta-utils.h>
#include <libanjuta/anjuta-save-prompt.h>
#include <libanjuta/plugins.h>
#include <libanjuta/interfaces/ianjuta-profile.h>
#include <libanjuta/interfaces/ianjuta-file.h>
#include "anjuta.h"
......@@ -133,6 +135,7 @@ anjuta_new (gchar *prog_name, GList *prog_args, gboolean no_splash,
GnomeClient *client;
GnomeClientFlags flags;
IAnjutaProfile *profile;
const gchar *project_file = NULL;
/* Initialize application */
app = ANJUTA_APP (anjuta_app_new ());
......@@ -183,6 +186,7 @@ anjuta_new (gchar *prog_name, GList *prog_args, gboolean no_splash,
else if (prog_args || geometry)
{
AnjutaSession *session;
GList *node, *files_load = NULL;
/* Reset default session */
session_dir = g_build_filename (g_get_home_dir (), ".anjuta",
......@@ -192,9 +196,35 @@ anjuta_new (gchar *prog_name, GList *prog_args, gboolean no_splash,
if (geometry)
anjuta_session_set_string (session, "Anjuta", "Geometry",
geometry);
if (prog_args)
/* Identify non-project files and set them for loading in session */
node = prog_args;
while (node)
{
const gchar *ext;
const gchar *filename = node->data;
ext = strrchr (filename, '.');
if (!ext ||
(strcmp (ext, ".anjuta") != 0 &&
strcmp (ext, ".prj") != 0))
{
files_load = g_list_prepend (files_load, node->data);
}
else if (project_file == NULL)
{
/* Pick up the first project file for loading later */
project_file = filename;
}
node = g_list_next (node);
}
if (files_load)
{
anjuta_session_set_string_list (session, "File Loader", "Files",
prog_args);
files_load);
g_list_free (files_load);
}
}
else
{
......@@ -218,6 +248,11 @@ anjuta_new (gchar *prog_name, GList *prog_args, gboolean no_splash,
/* Restore session */
anjuta_shell_session_load (ANJUTA_SHELL (app), session_dir, NULL);
g_free (session_dir);
/* Load project file */
if (project_file)
ianjuta_file_open (IANJUTA_FILE(profile), project_file, NULL);
anjuta_status_progress_tick (status, NULL, _("Loaded Session..."));
return app;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment