anjuta r4648 - in trunk: . libanjuta/interfaces plugins/document-manager plugins/glade plugins/scintilla plugins/sourceview
- From: sgranjoux svn gnome org
- To: svn-commits-list gnome org
- Subject: anjuta r4648 - in trunk: . libanjuta/interfaces plugins/document-manager plugins/glade plugins/scintilla plugins/sourceview
- Date: Fri, 30 Jan 2009 21:49:17 +0000 (UTC)
Author: sgranjoux
Date: Fri Jan 30 21:49:17 2009
New Revision: 4648
URL: http://svn.gnome.org/viewvc/anjuta?rev=4648&view=rev
Log:
* plugins/scintilla/text_editor.c,
plugins/scintilla/text_editor.h,
plugins/scintilla/text_editor_cbs.c,
plugins/sourceview/sourceview-io.c,
plugins/sourceview/sourceview-io.h,
plugins/sourceview/sourceview-private.h,
plugins/sourceview/sourceview.h,
plugins/sourceview/sourceview.c,
plugins/glade/anjuta-design-document.c,
plugins/glade/plugin.c,
plugins/document-manager/plugin.c,
plugins/document-manager/anjuta-docman.c,
plugins/document-manager/action-callbacks.c,
libanjuta/interfaces/libanjuta.idl:
Move message area code from document manager to each editor plugin
Rename save_point signal to update_save_ui and make it more general
Add ianjuta_file_savable_is_conflict function to disable autosave
Fix a crash when having deleted file document
Fix #549958 â user is not notified if a file is removed from
filesystem
Modified:
trunk/ChangeLog
trunk/libanjuta/interfaces/libanjuta.idl
trunk/plugins/document-manager/action-callbacks.c
trunk/plugins/document-manager/anjuta-docman.c
trunk/plugins/document-manager/plugin.c
trunk/plugins/glade/anjuta-design-document.c
trunk/plugins/glade/plugin.c
trunk/plugins/scintilla/text_editor.c
trunk/plugins/scintilla/text_editor.h
trunk/plugins/scintilla/text_editor_cbs.c
trunk/plugins/sourceview/sourceview-io.c
trunk/plugins/sourceview/sourceview-io.h
trunk/plugins/sourceview/sourceview-private.h
trunk/plugins/sourceview/sourceview.c
trunk/plugins/sourceview/sourceview.h
Modified: trunk/libanjuta/interfaces/libanjuta.idl
==============================================================================
--- trunk/libanjuta/interfaces/libanjuta.idl (original)
+++ trunk/libanjuta/interfaces/libanjuta.idl Fri Jan 30 21:49:17 2009
@@ -70,16 +70,16 @@
interface IAnjutaFileSavable
{
/**
- * IAnjutaFileSavable::save_point:
+ * IAnjutaFileSavable::update_save_ui:
* @obj: Self
- * @entered: TRUE if save point is entered, FALSE otherwise.
*
- * This signal is emitted when the editor enters or leave the save
- * point. Save point is the point where the contents were saved to
- * non-volatile memory (e.g. disk). For example, performing undo/redo
- * will enter or leave the save point in an editor.
+ * This signal is emitted when the state of the file has
+ * changed. It could be that the user writes in it
+ * and the file becomes dirty or the opposite: after using
+ * undo, the file is back to its saved content. It is triggered
+ * if the file becomes read-only or give a conflict too.
*/
- void ::save_point (gboolean entered);
+ void ::update_save_ui ();
/**
* IAnjutaFileSavable::saved:
@@ -143,6 +143,18 @@
*/
gboolean is_read_only ();
+ /**
+ * ianjuta_file_savable_is_conflict:
+ * @obj: Self
+ * @err: Error propagation and reporting
+ *
+ * Return is the file is in conflict. It means the file
+ * has been modified externally and the user needs to
+ * tell which version he wants to use.
+ *
+ * Return value: TRUE if conflict, FALSE otherwise.
+ */
+ gboolean is_conflict ();
}
}
@@ -2482,17 +2494,6 @@
*/
void set_current_document (IAnjutaDocument *document);
- /**
- * ianjuta_document_manager_set_message_area:
- * @obj: Self
- * @document: the document we change the message area.
- * @message_area: the widget to use as the message area.
- * @err: Error propagation and reporting.
- *
- * Sets the message area for the given document.
- */
- void set_message_area (IAnjutaDocument *document, GtkWidget *message_area);
-
/**
* ianjuta_document_manager_get_doc_widgets:
* @obj: Self
Modified: trunk/plugins/document-manager/action-callbacks.c
==============================================================================
--- trunk/plugins/document-manager/action-callbacks.c (original)
+++ trunk/plugins/document-manager/action-callbacks.c Fri Jan 30 21:49:17 2009
@@ -263,28 +263,36 @@
gchar *msg;
GtkWidget *dialog;
GtkWidget *parent;
+ gint reply = GTK_RESPONSE_YES;
doc = get_current_document (user_data);
if (doc == NULL)
return;
parent = gtk_widget_get_toplevel (GTK_WIDGET (doc));
- msg = g_strdup_printf (
- _("Are you sure you want to reload '%s'?\nAny unsaved changes will be lost."),
- ianjuta_document_get_filename (doc, NULL));
-
- dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_NONE, "%s", msg);
- gtk_dialog_add_button (GTK_DIALOG (dialog),
- GTK_STOCK_CANCEL, GTK_RESPONSE_NO);
- anjuta_util_dialog_add_button (GTK_DIALOG (dialog), _("_Reload"),
- GTK_STOCK_REVERT_TO_SAVED,
- GTK_RESPONSE_YES);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog),
- GTK_RESPONSE_NO);
- if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES)
+ if (IANJUTA_IS_FILE_SAVABLE (doc) && ianjuta_file_savable_is_dirty (IANJUTA_FILE_SAVABLE (doc), NULL))
+ {
+ msg = g_strdup_printf (
+ _("Are you sure you want to reload '%s'?\nAny unsaved changes will be lost."),
+ ianjuta_document_get_filename (doc, NULL));
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE, "%s", msg);
+ gtk_dialog_add_button (GTK_DIALOG (dialog),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_NO);
+ anjuta_util_dialog_add_button (GTK_DIALOG (dialog), _("_Reload"),
+ GTK_STOCK_REVERT_TO_SAVED,
+ GTK_RESPONSE_YES);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog),
+ GTK_RESPONSE_NO);
+ reply = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ g_free (msg);
+ }
+
+ if (reply == GTK_RESPONSE_YES)
{
GFile* file;
file = ianjuta_file_get_file (IANJUTA_FILE (doc), NULL);
@@ -294,8 +302,6 @@
g_object_unref(file);
}
}
- gtk_widget_destroy (dialog);
- g_free (msg);
}
void
Modified: trunk/plugins/document-manager/anjuta-docman.c
==============================================================================
--- trunk/plugins/document-manager/anjuta-docman.c (original)
+++ trunk/plugins/document-manager/anjuta-docman.c Fri Jan 30 21:49:17 2009
@@ -74,7 +74,6 @@
struct _AnjutaDocmanPage {
IAnjutaDocument *doc; /* a IAnjutaDocument */
GtkWidget *widget; /* notebook-page widget */
- GtkWidget *message_area; /* page message area */
GtkWidget *box; /* notebook-tab-label parent widget */
GtkWidget *menu_box; /* notebook-tab-menu parent widget */
GtkWidget *close_image;
@@ -373,7 +372,7 @@
GtkWidget *close_button;
GtkWidget *close_pixmap;
GtkWidget *label, *menu_label;
- GtkWidget *vbox, *box, *menu_box;
+ GtkWidget *box, *menu_box;
GtkWidget *event_hbox;
GtkWidget *event_box;
gint h, w;
@@ -471,9 +470,6 @@
gtk_widget_show_all (menu_box);
/* main box */
- vbox = gtk_vbox_new (FALSE, 0);
- gtk_box_pack_end (GTK_BOX (vbox), GTK_WIDGET (doc), TRUE, TRUE, 0);
-
g_signal_connect (G_OBJECT (close_button), "clicked",
G_CALLBACK (on_notebook_page_close_button_click),
docman);
@@ -490,9 +486,8 @@
G_CALLBACK (on_notebook_tab_btnrelease),
docman);
- page->widget = GTK_WIDGET (vbox); /* this is the notebook-page child widget */
+ page->widget = GTK_WIDGET (doc); /* this is the notebook-page child widget */
page->doc = doc;
- page->message_area = NULL;
page->box = box;
page->close_image = close_pixmap;
page->close_button = close_button;
@@ -918,7 +913,7 @@
}
static void
-on_document_save_point (IAnjutaDocument *doc, gboolean entering,
+on_document_update_save_ui (IAnjutaDocument *doc,
AnjutaDocman *docman)
{
anjuta_docman_update_page_label (docman, doc);
@@ -931,7 +926,7 @@
gint page_num;
g_signal_handlers_disconnect_by_func (G_OBJECT (doc),
- G_CALLBACK (on_document_save_point),
+ G_CALLBACK (on_document_update_save_ui),
docman);
g_signal_handlers_disconnect_by_func (G_OBJECT (doc),
G_CALLBACK (on_document_destroy),
@@ -1003,8 +998,8 @@
gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (docman), page->widget,
TRUE);
- g_signal_connect (G_OBJECT (doc), "save_point",
- G_CALLBACK (on_document_save_point), docman);
+ g_signal_connect (G_OBJECT (doc), "update-save-ui",
+ G_CALLBACK (on_document_update_save_ui), docman);
g_signal_connect (G_OBJECT (doc), "destroy",
G_CALLBACK (on_document_destroy), docman);
@@ -1200,63 +1195,6 @@
}
}
-static void
-on_destroy_message_area (gpointer data, GObject *finalized_object)
-{
- AnjutaDocmanPage *page = (AnjutaDocmanPage *)data;
- GFile *file;
-
- file = ianjuta_file_get_file (IANJUTA_FILE (page->doc), NULL);
- if (file)
- {
- GdkPixbuf* pixbuf = anjuta_docman_get_pixbuf_for_file (file);
-
- if (pixbuf)
- {
- gtk_image_set_from_pixbuf (GTK_IMAGE(page->menu_icon), pixbuf);
- gtk_image_set_from_pixbuf (GTK_IMAGE(page->mime_icon), pixbuf);
- g_object_unref (pixbuf);
- }
-
- g_object_unref (file);
- }
- page->message_area = NULL;
-}
-
-void
-anjuta_docman_set_message_area (AnjutaDocman *docman, IAnjutaDocument* doc,
- GtkWidget *message_area)
-{
- AnjutaDocmanPage *page;
-
- if (doc != NULL)
- {
- page = anjuta_docman_get_page_for_document (docman, doc);
- if (page->message_area != message_area)
- {
- if (page->message_area != NULL)
- gtk_widget_destroy (page->message_area);
-
- page->message_area = message_area;
-
- if (message_area == NULL)
- return;
-
- gtk_widget_show (message_area);
- gtk_box_pack_start (GTK_BOX (page->widget),
- message_area,
- FALSE,
- FALSE,
- 0);
-
- gtk_image_set_from_stock (GTK_IMAGE (page->menu_icon), GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_MENU);
- gtk_image_set_from_stock (GTK_IMAGE (page->mime_icon), GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_MENU);
- g_object_weak_ref (G_OBJECT (page->message_area),
- on_destroy_message_area, page);
- }
- }
-}
-
IAnjutaEditor *
anjuta_docman_goto_file_line (AnjutaDocman *docman, GFile* file, gint lineno)
{
@@ -1467,6 +1405,23 @@
gtk_label_set_text (GTK_LABEL (page->menu_label), label);
g_free (label);
g_free (basename);
+
+ if (ianjuta_file_savable_is_conflict (IANJUTA_FILE_SAVABLE (doc), NULL))
+ {
+ gtk_image_set_from_stock (GTK_IMAGE (page->menu_icon), GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_MENU);
+ gtk_image_set_from_stock (GTK_IMAGE (page->mime_icon), GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_MENU);
+ }
+ else
+ {
+ GdkPixbuf* pixbuf = anjuta_docman_get_pixbuf_for_file (file);
+
+ if (pixbuf)
+ {
+ gtk_image_set_from_pixbuf (GTK_IMAGE(page->menu_icon), pixbuf);
+ gtk_image_set_from_pixbuf (GTK_IMAGE(page->mime_icon), pixbuf);
+ g_object_unref (pixbuf);
+ }
+ }
g_object_unref (file);
}
else if ((doc_filename = ianjuta_document_get_filename (doc, NULL)) != NULL)
@@ -1631,7 +1586,18 @@
if (path)
{
local_real_path = anjuta_util_get_real_path (path);
- g_free (path);
+ if (local_real_path)
+ {
+ g_free (path);
+ }
+ else
+ {
+ local_real_path = path;
+ }
+ }
+ else
+ {
+ return NULL;
}
for (node = docman->priv->pages; node != NULL; node = g_list_next (node))
@@ -1665,7 +1631,14 @@
if (path)
{
gchar *doc_real_path = anjuta_util_get_real_path (path);
- g_free (path);
+ if (doc_real_path)
+ {
+ g_free (path);
+ }
+ else
+ {
+ doc_real_path = path;
+ }
if ((strcmp (doc_real_path, local_real_path) == 0))
{
file_doc = doc;
Modified: trunk/plugins/document-manager/plugin.c
==============================================================================
--- trunk/plugins/document-manager/plugin.c (original)
+++ trunk/plugins/document-manager/plugin.c Fri Jan 30 21:49:17 2009
@@ -860,7 +860,7 @@
}
static void
-on_document_update_save_ui (IAnjutaDocument *doc, gboolean entered,
+on_document_update_save_ui (IAnjutaDocument *doc,
AnjutaPlugin *plugin)
{
update_document_ui_save_items (plugin, doc);
@@ -1086,7 +1086,7 @@
g_signal_connect (G_OBJECT (doc), "update_ui",
G_CALLBACK (on_document_update_ui),
docman_plugin);
- g_signal_connect (G_OBJECT (doc), "save_point",
+ g_signal_connect (G_OBJECT (doc), "update-save-ui",
G_CALLBACK (on_document_update_save_ui),
plugin);
/* Present the vbox as this is the widget that was added to the shell */
@@ -1552,7 +1552,8 @@
for (node = buffers; node != NULL; node = g_list_next (node))
{
doc = IANJUTA_DOCUMENT (node->data);
- if (ianjuta_file_savable_is_dirty (IANJUTA_FILE_SAVABLE (doc), NULL))
+ if (ianjuta_file_savable_is_dirty (IANJUTA_FILE_SAVABLE (doc), NULL) &&
+ !ianjuta_file_savable_is_conflict (IANJUTA_FILE_SAVABLE (doc), NULL))
{
GFile* file = ianjuta_file_get_file (IANJUTA_FILE (doc), NULL);
if (file)
@@ -1923,17 +1924,6 @@
anjuta_docman_set_current_document (docman, doc);
}
-static void
-ianjuta_docman_set_message_area (IAnjutaDocumentManager *plugin,
- IAnjutaDocument *doc,
- GtkWidget *message_area,
- GError **e)
-{
- AnjutaDocman *docman;
- docman = ANJUTA_DOCMAN ((ANJUTA_PLUGIN_DOCMAN (plugin)->docman));
- anjuta_docman_set_message_area (docman, doc, message_area);
-}
-
static GList*
ianjuta_docman_get_doc_widgets (IAnjutaDocumentManager *plugin, GError **e)
{
@@ -2046,7 +2036,6 @@
iface->goto_file_line_mark = ianjuta_docman_goto_file_line_mark;
iface->remove_document = ianjuta_docman_remove_document;
iface->set_current_document = ianjuta_docman_set_current_document;
- iface->set_message_area = ianjuta_docman_set_message_area;
iface->add_bookmark = ianjuta_docman_add_bookmark;
}
Modified: trunk/plugins/glade/anjuta-design-document.c
==============================================================================
--- trunk/plugins/glade/anjuta-design-document.c (original)
+++ trunk/plugins/glade/anjuta-design-document.c Fri Jan 30 21:49:17 2009
@@ -391,7 +391,7 @@
anjuta_status_set (status, _("Glade project '%s' saved"),
project->name);
#endif
- g_signal_emit_by_name(G_OBJECT(self), "save_point", TRUE);
+ g_signal_emit_by_name(G_OBJECT(self), "update-save-ui");
g_signal_emit_by_name(G_OBJECT(self), "saved", file);
}
else
@@ -426,7 +426,7 @@
anjuta_status_set (status, _("Glade project '%s' saved"),
project->name);
#endif
- g_signal_emit_by_name(G_OBJECT(self), "save_point", TRUE);
+ g_signal_emit_by_name(G_OBJECT(self), "update-save-ui");
}
else
{
@@ -474,6 +474,13 @@
return FALSE;
}
+static gboolean
+ifile_savable_is_conflict (IAnjutaFileSavable* savable, GError** e)
+{
+ // FIXME
+ return FALSE;
+}
+
static void
ifile_savable_iface_init(IAnjutaFileSavableIface *iface)
{
@@ -482,6 +489,7 @@
iface->set_dirty = ifile_savable_set_dirty;
iface->is_dirty = ifile_savable_is_dirty;
iface->is_read_only = ifile_savable_is_read_only;
+ iface->is_conflict = ifile_savable_is_conflict;
}
/* Return true if editor can redo */
Modified: trunk/plugins/glade/plugin.c
==============================================================================
--- trunk/plugins/glade/plugin.c (original)
+++ trunk/plugins/glade/plugin.c Fri Jan 30 21:49:17 2009
@@ -363,7 +363,7 @@
{
gboolean dirty = ianjuta_file_savable_is_dirty(IANJUTA_FILE_SAVABLE(doc), NULL);
g_signal_emit_by_name (G_OBJECT(doc), "update_ui");
- g_signal_emit_by_name (G_OBJECT(doc), "save_point", !dirty);
+ g_signal_emit_by_name (G_OBJECT(doc), "update-save-ui");
}
}
@@ -3752,7 +3752,7 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static void
-on_designer_doc_save_point (AnjutaDesignDocument *doc, gboolean arg1,
+on_designer_doc_update_save_ui (AnjutaDesignDocument *doc,
GladePlugin *plugin)
{
g_return_if_fail (ANJUTA_IS_DESIGN_DOCUMENT (doc));
@@ -3818,8 +3818,8 @@
ianjuta_document_manager_add_document(docman, IANJUTA_DOCUMENT(doc), NULL);
- g_signal_connect (G_OBJECT (doc), "save_point",
- G_CALLBACK (on_designer_doc_save_point), glade_plugin);
+ g_signal_connect (G_OBJECT (doc), "update-save-ui",
+ G_CALLBACK (on_designer_doc_update_save_ui), glade_plugin);
#ifdef GLADE_LAYOUT_WIDGET_EVENTS
layout = glade_design_view_get_layout (GLADE_DESIGN_VIEW (view));
Modified: trunk/plugins/scintilla/text_editor.c
==============================================================================
--- trunk/plugins/scintilla/text_editor.c (original)
+++ trunk/plugins/scintilla/text_editor.c Fri Jan 30 21:49:17 2009
@@ -238,9 +238,8 @@
gtk_widget_set_usize (scintilla, 50, 50);
gtk_widget_show (scintilla);
- gtk_box_set_homogeneous (GTK_BOX (te), TRUE);
- gtk_box_set_spacing (GTK_BOX (te), 3);
- gtk_box_pack_start (GTK_BOX (te), scintilla, TRUE, TRUE, 0);
+ gtk_box_set_spacing (GTK_BOX (te->vbox), 3);
+ gtk_box_pack_start (GTK_BOX (te->vbox), scintilla, TRUE, TRUE, 0);
gtk_widget_grab_focus (scintilla);
g_signal_connect (G_OBJECT (scintilla), "event",
@@ -290,7 +289,7 @@
G_CALLBACK (on_text_editor_scintilla_focus_in), te);
te->views = g_list_remove (te->views, GINT_TO_POINTER(te->editor_id));
- gtk_container_remove (GTK_CONTAINER (te), te->scintilla);
+ gtk_container_remove (GTK_CONTAINER (te->vbox), te->scintilla);
aneditor_destroy(te->editor_id);
/* Set current view */
@@ -302,7 +301,7 @@
}
else
{
- gtk_box_set_spacing (GTK_BOX (te), 0);
+ gtk_box_set_spacing (GTK_BOX (te->vbox), 0);
te->editor_id = 0;
te->scintilla = NULL;
}
@@ -317,12 +316,21 @@
}
else
{
+ text_editor_set_saved (te, FALSE);
gtk_widget_destroy (message_area);
- te->message_area = NULL;
}
}
static void
+on_destroy_message_area (gpointer data, GObject *finalized_object)
+{
+ TextEditor *te = (TextEditor *)data;
+
+ te->message_area = NULL;
+ g_signal_emit_by_name (G_OBJECT (te), "update-save-ui");
+}
+
+static void
on_close_dialog_response (GtkWidget *message_area, gint res, TextEditor *te)
{
if (res == GTK_RESPONSE_YES)
@@ -338,11 +346,32 @@
{
text_editor_set_saved (te, FALSE);
gtk_widget_destroy (message_area);
- te->message_area = NULL;
}
}
static void
+text_editor_set_message_area (TextEditor *te, GtkWidget *message_area)
+{
+ if (te->message_area != NULL)
+ gtk_widget_destroy (te->message_area);
+ te->message_area = message_area;
+
+ if (te->message_area == NULL)
+ return;
+
+ gtk_widget_show (message_area);
+ gtk_box_pack_start (GTK_BOX (te),
+ message_area,
+ FALSE,
+ FALSE,
+ 0);
+ g_object_weak_ref (G_OBJECT (te->message_area),
+ on_destroy_message_area, te);
+
+ g_signal_emit_by_name (G_OBJECT (te), "update-save-ui");
+}
+
+static void
on_text_editor_uri_changed (GFileMonitor *monitor,
GFile *file,
GFile *other_file,
@@ -351,14 +380,12 @@
{
TextEditor *te = TEXT_EDITOR (user_data);
GtkWidget *message_area;
- IAnjutaDocumentManager *docman;
gchar *buff;
/* DEBUG_PRINT ("%s", "File changed!!!"); */
switch (event_type)
{
- case G_FILE_MONITOR_EVENT_CREATED:
case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
if (!anjuta_util_diff (te->uri, te->last_saved_content))
@@ -369,7 +396,9 @@
te->message_area = NULL;
return;
}
-
+ /* No break here */
+
+ case G_FILE_MONITOR_EVENT_CREATED:
if (text_editor_is_saved (te))
{
buff = g_strdup_printf (_("The file '%s' has been changed.\n"
@@ -431,21 +460,7 @@
return;
}
- if (te->message_area != NULL)
- {
- gtk_widget_destroy (te->message_area);
- te->message_area = NULL;
- }
-
- docman = anjuta_shell_get_interface (te->shell, IAnjutaDocumentManager, NULL);
- if (!docman)
- {
- gtk_widget_destroy (message_area);
- return;
- }
-
- ianjuta_document_manager_set_message_area (docman, IANJUTA_DOCUMENT (te), message_area, NULL);
- te->message_area = message_area;
+ text_editor_set_message_area (te, message_area);
}
static void
@@ -521,6 +536,8 @@
text_editor_prefs_init (te);
/* Create primary view */
+ te->vbox = gtk_vbox_new (TRUE, 3);
+ gtk_box_pack_end (GTK_BOX (te), te->vbox, TRUE, TRUE, 0);
text_editor_add_view (te);
if (te->uri)
@@ -1578,9 +1595,9 @@
0, 0);
// check_tm_file(te);
text_editor_thaw (te);
+ te->force_not_saved = FALSE;
scintilla_send_message (SCINTILLA (te->scintilla),
SCI_SETSAVEPOINT, 0, 0);
- te->force_not_saved = FALSE;
scintilla_send_message (SCINTILLA (te->scintilla),
SCI_EMPTYUNDOBUFFER, 0, 0);
text_editor_set_hilite_type (te, NULL);
@@ -1629,9 +1646,9 @@
GFile* file = g_file_new_for_uri (te->uri);
/* we need to update UI with the call to scintilla */
text_editor_thaw (te);
+ te->force_not_saved = FALSE;
scintilla_send_message (SCINTILLA (te->scintilla),
SCI_SETSAVEPOINT, 0, 0);
- te->force_not_saved = FALSE;
g_signal_emit_by_name (G_OBJECT (te), "saved", file);
g_object_unref (file);
anjuta_status (te->status, _("File saved successfully"), 5);
@@ -1650,7 +1667,7 @@
scintilla_send_message (SCINTILLA (te->scintilla), SCI_SETSAVEPOINT, 0, 0);
}
te->force_not_saved = !saved;
- g_signal_emit_by_name(G_OBJECT (te), "save_point", saved);
+ g_signal_emit_by_name(G_OBJECT (te), "update-save-ui");
}
gboolean
@@ -2802,6 +2819,13 @@
return FALSE;
}
+static gboolean
+isavable_is_conflict (IAnjutaFileSavable* savable, GError** e)
+{
+ TextEditor *te = TEXT_EDITOR(savable);
+ return te->message_area != NULL;
+}
+
static void
isavable_iface_init (IAnjutaFileSavableIface *iface)
{
@@ -2810,6 +2834,7 @@
iface->set_dirty = isavable_set_dirty;
iface->is_dirty = isavable_is_dirty;
iface->is_read_only = isavable_is_read_only;
+ iface->is_conflict = isavable_is_conflict;
}
static void
Modified: trunk/plugins/scintilla/text_editor.h
==============================================================================
--- trunk/plugins/scintilla/text_editor.h (original)
+++ trunk/plugins/scintilla/text_editor.h Fri Jan 30 21:49:17 2009
@@ -57,7 +57,7 @@
struct _TextEditor
{
- GtkVBox vbox;
+ GtkVBox parent;
gchar *filename;
gchar *uri;
@@ -77,6 +77,7 @@
AnEditorID editor_id;
AnEditorID editor_id_split;
GtkWidget *scintilla;
+ GtkWidget *vbox;
GList *views;
/* Properties set ID in the preferences */
Modified: trunk/plugins/scintilla/text_editor_cbs.c
==============================================================================
--- trunk/plugins/scintilla/text_editor_cbs.c (original)
+++ trunk/plugins/scintilla/text_editor_cbs.c Fri Jan 30 21:49:17 2009
@@ -152,10 +152,10 @@
scintilla_uri_dropped(te, nt->text);
break;
case SCN_SAVEPOINTREACHED:
- g_signal_emit_by_name(G_OBJECT (te), "save_point", TRUE);
+ g_signal_emit_by_name(G_OBJECT (te), "update_save_ui");
break;
case SCN_SAVEPOINTLEFT:
- g_signal_emit_by_name(G_OBJECT (te), "save_point", FALSE);
+ g_signal_emit_by_name(G_OBJECT (te), "update_save_ui");
//FIXME:
// anjuta_update_title ();
// update_main_menubar ();
Modified: trunk/plugins/sourceview/sourceview-io.c
==============================================================================
--- trunk/plugins/sourceview/sourceview-io.c (original)
+++ trunk/plugins/sourceview/sourceview-io.c Fri Jan 30 21:49:17 2009
@@ -35,6 +35,7 @@
OPEN_FINISHED,
OPEN_FAILED,
SAVE_FAILED,
+ FILE_DELETED,
LAST_SIGNAL
};
@@ -85,6 +86,7 @@
object_class->finalize = sourceview_io_finalize;
klass->changed = NULL;
+ klass->deleted = NULL;
klass->save_finished = NULL;
klass->open_finished = NULL;
klass->open_failed = NULL;
@@ -139,6 +141,16 @@
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
+
+ io_signals[FILE_DELETED] =
+ g_signal_new ("deleted",
+ G_OBJECT_CLASS_TYPE (klass),
+ 0,
+ G_STRUCT_OFFSET (SourceviewIOClass, deleted),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0,
+ NULL);
}
static void on_file_changed (GFileMonitor* monitor,
@@ -149,7 +161,18 @@
{
SourceviewIO* sio = SOURCEVIEW_IO(data);
- g_signal_emit_by_name (sio, "changed");
+ switch (event_type)
+ {
+ case G_FILE_MONITOR_EVENT_CREATED:
+ case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
+ g_signal_emit_by_name (sio, "changed");
+ break;
+ case G_FILE_MONITOR_EVENT_DELETED:
+ g_signal_emit_by_name (sio, "deleted");
+ break;
+ default:
+ break;
+ }
}
static gboolean
Modified: trunk/plugins/sourceview/sourceview-io.h
==============================================================================
--- trunk/plugins/sourceview/sourceview-io.h (original)
+++ trunk/plugins/sourceview/sourceview-io.h Fri Jan 30 21:49:17 2009
@@ -47,6 +47,7 @@
void(* open_finished) (SourceviewIO *self);
void(* open_failed) (SourceviewIO *self, GError* error);
void(* save_failed) (SourceviewIO *self, GError* error);
+ void(* deleted) (SourceviewIO *self);
};
struct _SourceviewIO
Modified: trunk/plugins/sourceview/sourceview-private.h
==============================================================================
--- trunk/plugins/sourceview/sourceview-private.h (original)
+++ trunk/plugins/sourceview/sourceview-private.h Fri Jan 30 21:49:17 2009
@@ -50,6 +50,12 @@
/* Popup menu */
GtkWidget* menu;
+ /* Message area */
+ GtkWidget* message_area;
+
+ /* Editor window */
+ GtkWidget* window;
+
/* Bookmarks */
GList* bookmarks;
GList* cur_bmark;
Modified: trunk/plugins/sourceview/sourceview.c
==============================================================================
--- trunk/plugins/sourceview/sourceview.c (original)
+++ trunk/plugins/sourceview/sourceview.c Fri Jan 30 21:49:17 2009
@@ -190,6 +190,35 @@
gtk_text_buffer_select_range (buffer, &iter, &iter);
}
+static void
+on_destroy_message_area (Sourceview* sv, GObject *finalized_object)
+{
+ sv->priv->message_area = NULL;
+ g_signal_emit_by_name (G_OBJECT (sv), "update-save-ui");
+}
+
+static void
+sourceview_set_message_area (Sourceview* sv, GtkWidget *message_area)
+{
+ if (sv->priv->message_area != NULL)
+ gtk_widget_destroy (sv->priv->message_area);
+ sv->priv->message_area = message_area;
+
+ if (sv->priv->message_area == NULL)
+ return;
+
+ gtk_widget_show (message_area);
+ gtk_box_pack_start (GTK_BOX (sv),
+ message_area,
+ FALSE,
+ FALSE,
+ 0);
+ g_object_weak_ref (G_OBJECT (sv->priv->message_area),
+ (GWeakNotify)on_destroy_message_area, sv);
+
+ g_signal_emit_by_name (G_OBJECT (sv), "update-save-ui");
+}
+
/* Callbacks */
static void
@@ -249,7 +278,7 @@
static void on_document_modified_changed(GtkTextBuffer* buffer, Sourceview* sv)
{
/* Emit IAnjutaFileSavable signals */
- g_signal_emit_by_name(G_OBJECT(sv), "save_point",
+ g_signal_emit_by_name(G_OBJECT(sv), "update-save-ui",
!gtk_text_buffer_get_modified(buffer));
}
@@ -299,13 +328,31 @@
gtk_widget_destroy (message_area);
}
+static void
+on_close_dialog_response (GtkWidget *message_area, gint res, Sourceview *sv)
+{
+ if (res == GTK_RESPONSE_YES)
+ {
+ IAnjutaDocumentManager *docman;
+
+ docman = anjuta_shell_get_interface (sv->priv->plugin->shell, IAnjutaDocumentManager, NULL);
+ if (docman == NULL) return;
+
+ ianjuta_document_manager_remove_document (docman, IANJUTA_DOCUMENT (sv), FALSE, NULL);
+ }
+ else
+ {
+ /* Set dirty */
+ gtk_text_buffer_set_modified(GTK_TEXT_BUFFER(sv->priv->document), TRUE);
+ }
+ gtk_widget_destroy (message_area);
+}
+
static gboolean
on_file_changed (SourceviewIO* sio, Sourceview* sv)
{
GtkWidget *message_area;
- IAnjutaDocumentManager *docman;
IAnjutaDocument *doc;
- AnjutaShell *shell;
gchar *buff;
gchar* filename = sourceview_io_get_filename (sio);
@@ -318,10 +365,6 @@
g_free (filename);
- shell = ANJUTA_PLUGIN (sv->priv->plugin)->shell;
- docman = anjuta_shell_get_interface (shell, IAnjutaDocumentManager, NULL);
- if (!docman)
- return TRUE;
doc = IANJUTA_DOCUMENT (sv);
message_area = anjuta_message_area_new (buff, GTK_STOCK_DIALOG_WARNING);
@@ -335,8 +378,46 @@
g_signal_connect (G_OBJECT(message_area), "response",
G_CALLBACK (on_reload_dialog_response),
- sv);
- ianjuta_document_manager_set_message_area (docman, doc, message_area, NULL);
+ sv);
+
+ sourceview_set_message_area (sv, message_area);
+
+ return FALSE;
+}
+
+static gboolean
+on_file_deleted (SourceviewIO* sio, Sourceview* sv)
+{
+ GtkWidget *message_area;
+ IAnjutaDocument *doc;
+ gchar *buff;
+
+ gchar* filename = sourceview_io_get_filename (sio);
+
+ buff =
+ g_strdup_printf (_
+ ("The file '%s' has been deleted on the disk.\n"
+ "Do you want to close it?"),
+ filename);
+
+ g_free (filename);
+
+ doc = IANJUTA_DOCUMENT (sv);
+
+ message_area = anjuta_message_area_new (buff, GTK_STOCK_DIALOG_WARNING);
+ anjuta_message_area_add_button (ANJUTA_MESSAGE_AREA (message_area),
+ GTK_STOCK_DELETE,
+ GTK_RESPONSE_YES);
+ anjuta_message_area_add_button (ANJUTA_MESSAGE_AREA (message_area),
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_NO);
+ g_free (buff);
+
+ g_signal_connect (G_OBJECT(message_area), "response",
+ G_CALLBACK (on_close_dialog_response),
+ sv);
+
+ sourceview_set_message_area (sv, message_area);
return FALSE;
}
@@ -364,8 +445,7 @@
GTK_RESPONSE_OK);
g_signal_connect (message_area, "response", G_CALLBACK(gtk_widget_destroy), NULL);
- ianjuta_document_manager_set_message_area (docman, IANJUTA_DOCUMENT(sv),
- message_area, NULL);
+ sourceview_set_message_area (sv, message_area);
}
else
{
@@ -392,7 +472,6 @@
gtk_text_view_set_editable (GTK_TEXT_VIEW (sv->priv->view),
TRUE);
sv->priv->read_only = FALSE;
- g_signal_emit_by_name (sv, "save-point", TRUE);
}
gtk_widget_destroy (message_area);
}
@@ -407,11 +486,6 @@
if (sourceview_io_get_read_only (io))
{
- AnjutaShell* shell = ANJUTA_PLUGIN (sv->priv->plugin)->shell;
- IAnjutaDocumentManager* docman =
- anjuta_shell_get_interface (shell, IAnjutaDocumentManager, NULL);
- g_return_if_fail (docman != NULL);
- IAnjutaDocument* doc = IANJUTA_DOCUMENT (sv);
gchar* filename = sourceview_io_get_filename (io);
gchar* buff = g_strdup_printf ("The file '%s' is read-only! Edit anyway?",
filename);
@@ -433,13 +507,12 @@
sv->priv->read_only = TRUE;
- ianjuta_document_manager_set_message_area (docman, doc, message_area, NULL);
+ sourceview_set_message_area (sv, message_area);
}
else
gtk_text_view_set_editable (GTK_TEXT_VIEW (sv->priv->view), TRUE);
- g_signal_emit_by_name(G_OBJECT(sv), "save_point",
- TRUE);
+ g_signal_emit_by_name(G_OBJECT(sv), "update-save-ui");
if (sv->priv->goto_line > 0)
{
@@ -485,8 +558,7 @@
GTK_RESPONSE_OK);
g_signal_connect (message_area, "response", G_CALLBACK(gtk_widget_destroy), NULL);
- ianjuta_document_manager_set_message_area (docman, IANJUTA_DOCUMENT(sv),
- message_area, NULL);
+ sourceview_set_message_area (sv, message_area);
}
else
{
@@ -510,7 +582,7 @@
gtk_text_buffer_set_modified(GTK_TEXT_BUFFER(sv->priv->document), FALSE);
sv->priv->read_only = FALSE;
g_signal_emit_by_name(G_OBJECT(sv), "saved", file);
- g_signal_emit_by_name(G_OBJECT(sv), "save_point", TRUE);
+ g_signal_emit_by_name(G_OBJECT(sv), "update-save-ui");
g_object_unref (file);
/* Autodetect language */
ianjuta_editor_language_set_language(IANJUTA_EDITOR_LANGUAGE(sv), NULL, NULL);
@@ -539,6 +611,7 @@
sv->priv = g_slice_new0 (SourceviewPrivate);
sv->priv->io = sourceview_io_new (sv);
g_signal_connect (sv->priv->io, "changed", G_CALLBACK (on_file_changed), sv);
+ g_signal_connect (sv->priv->io, "deleted", G_CALLBACK (on_file_deleted), sv);
g_signal_connect (sv->priv->io, "open-finished", G_CALLBACK (on_open_finish),
sv);
g_signal_connect (sv->priv->io, "open-failed", G_CALLBACK (on_open_failed),
@@ -642,12 +715,15 @@
sv->priv->plugin = plugin;
/* Add View */
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sv),
+ sv->priv->window = gtk_scrolled_window_new (NULL, NULL);
+ gtk_box_pack_end (GTK_BOX (sv), sv->priv->window, TRUE, TRUE, 0);
+
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sv->priv->window),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
- gtk_container_add(GTK_CONTAINER(sv), GTK_WIDGET(sv->priv->view));
+ gtk_container_add(GTK_CONTAINER(sv->priv->window), GTK_WIDGET(sv->priv->view));
gtk_widget_show_all(GTK_WIDGET(sv));
- v_adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (sv));
+ v_adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (sv->priv->window));
g_signal_connect (v_adj, "value-changed", G_CALLBACK (sourceview_adjustment_changed), sv);
if (file != NULL)
@@ -735,6 +811,13 @@
return sv->priv->read_only;
}
+static gboolean
+ifile_savable_is_conflict (IAnjutaFileSavable* file, GError** e)
+{
+ Sourceview* sv = ANJUTA_SOURCEVIEW (file);
+ return sv->priv->message_area != NULL;
+}
+
static void
isavable_iface_init (IAnjutaFileSavableIface *iface)
{
@@ -743,6 +826,7 @@
iface->set_dirty = ifile_savable_set_dirty;
iface->is_dirty = ifile_savable_is_dirty;
iface->is_read_only = ifile_savable_is_read_only;
+ iface->is_conflict = ifile_savable_is_conflict;
}
static void
@@ -2216,7 +2300,7 @@
iface->display = ihover_display;
}
-ANJUTA_TYPE_BEGIN(Sourceview, sourceview, GTK_TYPE_SCROLLED_WINDOW);
+ANJUTA_TYPE_BEGIN(Sourceview, sourceview, GTK_TYPE_VBOX);
ANJUTA_TYPE_ADD_INTERFACE(idocument, IANJUTA_TYPE_DOCUMENT);
ANJUTA_TYPE_ADD_INTERFACE(ifile, IANJUTA_TYPE_FILE);
ANJUTA_TYPE_ADD_INTERFACE(isavable, IANJUTA_TYPE_FILE_SAVABLE);
Modified: trunk/plugins/sourceview/sourceview.h
==============================================================================
--- trunk/plugins/sourceview/sourceview.h (original)
+++ trunk/plugins/sourceview/sourceview.h Fri Jan 30 21:49:17 2009
@@ -43,12 +43,12 @@
typedef struct SourceviewPrivate SourceviewPrivate;
typedef struct {
- GtkScrolledWindow parent;
+ GtkVBox parent;
SourceviewPrivate *priv;
} Sourceview;
typedef struct {
- GtkScrolledWindowClass parent_class;
+ GtkVBoxClass parent_class;
void (*update_ui);
} SourceviewClass;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]