anjuta r4352 - in branches/gnome-2-24: . libanjuta/interfaces plugins/document-manager plugins/file-loader plugins/file-wizard plugins/project-manager plugins/sourceview
- From: sgranjoux svn gnome org
- To: svn-commits-list gnome org
- Subject: anjuta r4352 - in branches/gnome-2-24: . libanjuta/interfaces plugins/document-manager plugins/file-loader plugins/file-wizard plugins/project-manager plugins/sourceview
- Date: Sun, 19 Oct 2008 08:10:09 +0000 (UTC)
Author: sgranjoux
Date: Sun Oct 19 08:10:09 2008
New Revision: 4352
URL: http://svn.gnome.org/viewvc/anjuta?rev=4352&view=rev
Log:
* plugins/project-manager/plugin.c,
plugins/file-wizard/file.c,
libanjuta/interfaces/libanjuta.idl:
Fix #545668 - new file are not added correctly to the project
* plugins/document-manager/anjuta-docman.c
(anjuta_docman_get_pixbuf_for_file), (anjuta_docman_page_init),
(anjuta_docman_save_document_as):
Fixed #545668 â file's icon not correctly updated on tabs-right-click
#556053 â closing file tabs disable 'save button'
* plugins/file-loader/plugin.c (on_session_load):
Do not show status ticks for async file loading
* plugins/sourceview/sourceview.c (on_insert_text), (on_backspace),
(sourceview_instance_init):
#554684 â Cursor column number is not updated when typing text
Modified:
branches/gnome-2-24/ChangeLog
branches/gnome-2-24/libanjuta/interfaces/libanjuta.idl
branches/gnome-2-24/plugins/document-manager/anjuta-docman.c
branches/gnome-2-24/plugins/file-loader/plugin.c
branches/gnome-2-24/plugins/file-wizard/file.c
branches/gnome-2-24/plugins/project-manager/plugin.c
branches/gnome-2-24/plugins/sourceview/sourceview.c
Modified: branches/gnome-2-24/libanjuta/interfaces/libanjuta.idl
==============================================================================
--- branches/gnome-2-24/libanjuta/interfaces/libanjuta.idl (original)
+++ branches/gnome-2-24/libanjuta/interfaces/libanjuta.idl Sun Oct 19 08:10:09 2008
@@ -2978,8 +2978,8 @@
/**
* ianjuta_project_manager_add_source:
* @obj: Self
- * @source_uri_to_add: fixme
- * @default_location_uri: fixme
+ * @source_uri_to_add: Target name or uri
+ * @default_location_uri: Default source location or NULL if don't care
* @err: Error propagation and reporting.
*
* Prompt the user to add a file to the project. If the user selects
Modified: branches/gnome-2-24/plugins/document-manager/anjuta-docman.c
==============================================================================
--- branches/gnome-2-24/plugins/document-manager/anjuta-docman.c (original)
+++ branches/gnome-2-24/plugins/document-manager/anjuta-docman.c Sun Oct 19 08:10:09 2008
@@ -59,8 +59,6 @@
DocmanPlugin *plugin;
AnjutaPreferences *preferences;
GList *pages; /* list of AnjutaDocmanPage's */
- AnjutaDocmanPage *cur_page;
- IAnjutaDocument *current_document; /* normally == IANJUTA_DOCUMENT (cur_page->doc) */
GtkWidget *fileselection;
@@ -82,6 +80,7 @@
GtkWidget *close_image;
GtkWidget *close_button;
GtkWidget *mime_icon;
+ GtkWidget *menu_icon;
GtkWidget *label;
GtkWidget *menu_label; /* notebook page-switch menu-label */
gboolean is_current;
@@ -102,6 +101,9 @@
static AnjutaDocmanPage *
anjuta_docman_get_nth_page (AnjutaDocman *docman, gint page_num);
+static AnjutaDocmanPage *
+anjuta_docman_get_current_page (AnjutaDocman *docman);
+
static void
on_document_toggled (GtkAction* action,
AnjutaDocman* docman)
@@ -133,7 +135,7 @@
"/MenuMain/PlaceHolderDocumentsMenus/Documents/NextDocument");
g_object_set (action, "sensitive", (current_page + 1) < n_pages, NULL);
action_name = g_strdup_printf ("Tab_%d", current_page);
- action = gtk_action_group_get_action (docman->priv->documents_action_group, action_name);
+ action = gtk_action_group_get_action (docman->priv->documents_action_group, action_name);
g_free (action_name);
if (action)
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
@@ -240,7 +242,7 @@
{
AnjutaDocmanPage *page;
- page = docman->priv->cur_page;
+ page = anjuta_docman_get_current_page (docman);
if (page == NULL || page->close_button != GTK_WIDGET (button))
{
/* the close function works only on the current document */
@@ -323,6 +325,47 @@
anjuta_docman_update_documents_menu(docman);
}
+static GdkPixbuf*
+anjuta_docman_get_pixbuf_for_file (GFile* file)
+{
+ /* add a nice mime-type icon if we can */
+ const gchar** icon_names;
+ GtkIconInfo* icon_info;
+ GIcon* icon;
+ GdkPixbuf* pixbuf;
+ GFileInfo* file_info;
+ GError* err = NULL;
+
+ g_return_val_if_fail (file != NULL, NULL);
+
+ file_info = g_file_query_info (file,
+ "standard::*",
+ G_FILE_QUERY_INFO_NONE,
+ NULL,
+ &err);
+ if (err)
+ DEBUG_PRINT ("GFile-Error %s", err->message);
+
+ if (file_info != NULL)
+ {
+ icon = g_file_info_get_icon (file_info);
+ g_object_get (icon, "names", &icon_names, NULL);
+ icon_info = gtk_icon_theme_choose_icon (gtk_icon_theme_get_default(),
+ icon_names,
+ GTK_ICON_SIZE_MENU,
+ GTK_ICON_LOOKUP_GENERIC_FALLBACK);
+ pixbuf = gtk_icon_info_load_icon (icon_info, NULL);
+ gtk_icon_info_free(icon_info);
+ g_object_unref (icon);
+
+ if (pixbuf != NULL)
+ {
+ return pixbuf;
+ }
+ }
+ return NULL;
+}
+
static void
anjuta_docman_page_init (AnjutaDocman *docman, IAnjutaDocument *doc,
GFile* file, AnjutaDocmanPage *page)
@@ -384,46 +427,18 @@
event_hbox = gtk_hbox_new (FALSE, 2);
+ page->menu_icon = gtk_image_new();
+ page->mime_icon = gtk_image_new();
+ gtk_box_pack_start (GTK_BOX (event_hbox), page->mime_icon, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (menu_box), page->menu_icon, FALSE, FALSE, 0);
if (file != NULL)
{
- /* add a nice mime-type icon if we can */
- const gchar** icon_names;
- GtkIconInfo* icon_info;
- GIcon* icon;
- GdkPixbuf* pixbuf;
- GFileInfo* file_info;
- GError* err = NULL;
-
- file_info = g_file_query_info (file,
- "standard::*",
- G_FILE_QUERY_INFO_NONE,
- NULL,
- &err);
- if (err)
- DEBUG_PRINT ("GFile-Error %s", err->message);
-
- if (file_info != NULL)
+ GdkPixbuf* pixbuf = anjuta_docman_get_pixbuf_for_file (file);
+ if (pixbuf != NULL)
{
- icon = g_file_info_get_icon (file_info);
- g_object_get (icon, "names", &icon_names, NULL);
- icon_info = gtk_icon_theme_choose_icon (gtk_icon_theme_get_default(),
- icon_names,
- GTK_ICON_SIZE_MENU,
- GTK_ICON_LOOKUP_GENERIC_FALLBACK);
- pixbuf = gtk_icon_info_load_icon (icon_info, NULL);
- gtk_icon_info_free(icon_info);
- g_object_unref (icon);
-
- if (pixbuf != NULL)
- {
- GtkWidget *image, *menu_image;
- image = gtk_image_new_from_pixbuf (pixbuf);
- menu_image = gtk_image_new_from_pixbuf (pixbuf);
- gtk_box_pack_start (GTK_BOX (event_hbox), image, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (menu_box), menu_image, FALSE, FALSE, 0);
- page->mime_icon = image;
- g_object_unref (G_OBJECT (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);
}
ruri = g_file_get_parse_name (file);
if (ruri != NULL)
@@ -681,7 +696,21 @@
gtk_widget_destroy (dialog);
g_free (uri);
+
+ if (file_saved)
+ {
+ /* Update mime icons */
+ AnjutaDocmanPage* page = anjuta_docman_get_page_for_document (docman, doc);
+ 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);
+
return file_saved;
}
@@ -865,8 +894,13 @@
AnjutaDocmanPage *page;
page = anjuta_docman_get_nth_page (docman, page_num);
+ g_signal_handlers_block_by_func (G_OBJECT (docman),
+ (gpointer) on_notebook_switch_page,
+ (gpointer) docman);
anjuta_docman_set_current_document (docman, page->doc);
-
+ g_signal_handlers_unblock_by_func (G_OBJECT (docman),
+ (gpointer) on_notebook_switch_page,
+ (gpointer) docman);
/* TTimo: reorder so that the most recently used files are
* at the beginning of the tab list
*/
@@ -879,6 +913,7 @@
}
/* activate the right item in the documents menu */
anjuta_docman_update_documents_menu_status (docman);
+ g_signal_emit_by_name (G_OBJECT (docman), "document-changed", page->doc);
}
}
@@ -907,8 +942,6 @@
if (!docman->priv->shutingdown)
{
- if (page == docman->priv->cur_page)
- docman->priv->cur_page = NULL;
if (GTK_NOTEBOOK (docman)->children == NULL)
anjuta_docman_set_current_document (docman, NULL);
else
@@ -977,10 +1010,10 @@
g_object_ref (doc);
- g_signal_emit (G_OBJECT (docman), docman_signals[DOC_ADDED], 0, doc);
anjuta_docman_set_current_document (docman, doc);
anjuta_shell_present_widget (docman->shell, GTK_WIDGET (docman->priv->plugin->vbox), NULL);
anjuta_docman_update_documents_menu (docman);
+ g_signal_emit_by_name (docman, "document-added", doc);
}
void
@@ -993,20 +1026,12 @@
if (!doc)
return;
-
+
page = anjuta_docman_get_page_for_document (docman, doc);
if (page)
{
gtk_container_remove (GTK_CONTAINER (page->widget), GTK_WIDGET(doc));
- g_signal_handlers_block_by_func (G_OBJECT (docman),
- (gpointer) on_notebook_switch_page,
- (gpointer) docman);
gtk_container_remove (GTK_CONTAINER (docman), page->widget);
- g_signal_handlers_unblock_by_func (G_OBJECT (docman),
- (gpointer) on_notebook_switch_page,
- (gpointer) docman);
- if (page == docman->priv->cur_page)
- docman->priv->cur_page = NULL;
docman->priv->pages = g_list_remove (docman->priv->pages, (gpointer)page);
if (!g_list_length (docman->priv->pages))
g_signal_emit (G_OBJECT (docman), docman_signals[DOC_CHANGED], 0, NULL);
@@ -1086,10 +1111,22 @@
return NULL;
}
+static AnjutaDocmanPage*
+anjuta_docman_get_current_page (AnjutaDocman* docman)
+{
+ AnjutaDocmanPage* page = anjuta_docman_get_nth_page (docman,
+ gtk_notebook_get_current_page(GTK_NOTEBOOK(docman)));
+ return page;
+}
+
IAnjutaDocument *
anjuta_docman_get_current_document (AnjutaDocman *docman)
{
- return docman->priv->current_document;
+ AnjutaDocmanPage* page = anjuta_docman_get_current_page (docman);
+ if (page)
+ return page->doc;
+ else
+ return NULL;
}
void
@@ -1098,9 +1135,7 @@
AnjutaDocmanPage *page;
IAnjutaDocument *defdoc;
- defdoc = docman->priv->current_document;
- if (defdoc == doc)
- return;
+ defdoc = anjuta_docman_get_current_document(docman);
if (doc != NULL)
{
@@ -1113,7 +1148,7 @@
if (defdoc != NULL)
{
AnjutaDocmanPage *oldpage;
- oldpage = docman->priv->cur_page;
+ oldpage = anjuta_docman_get_page_for_document (docman, defdoc);
if (oldpage)
{
oldpage->is_current = FALSE;
@@ -1126,9 +1161,6 @@
}
}
- docman->priv->current_document = doc;
- docman->priv->cur_page = page;
-
page->is_current = TRUE;
if (page->close_button != NULL)
{
@@ -1138,13 +1170,7 @@
}
page_num = gtk_notebook_page_num (GTK_NOTEBOOK (docman),
page->widget);
- g_signal_handlers_block_by_func (G_OBJECT (docman),
- (gpointer) on_notebook_switch_page,
- (gpointer) docman);
gtk_notebook_set_current_page (GTK_NOTEBOOK (docman), page_num);
- g_signal_handlers_unblock_by_func (G_OBJECT (docman),
- (gpointer) on_notebook_switch_page,
- (gpointer) docman);
if (anjuta_preferences_get_int (ANJUTA_PREFERENCES (docman->priv->preferences),
EDITOR_TABS_ORDERING))
@@ -1159,7 +1185,7 @@
{
if (defdoc != NULL)
{
- page = docman->priv->cur_page;
+ page = anjuta_docman_get_current_page (docman);
if (page)
{
page->is_current = FALSE;
@@ -1171,10 +1197,7 @@
}
}
}
- docman->priv->current_document = NULL;
- docman->priv->cur_page = NULL;
}
- g_signal_emit (G_OBJECT (docman), docman_signals[DOC_CHANGED], 0, doc);
}
void
Modified: branches/gnome-2-24/plugins/file-loader/plugin.c
==============================================================================
--- branches/gnome-2-24/plugins/file-loader/plugin.c (original)
+++ branches/gnome-2-24/plugins/file-loader/plugin.c Sun Oct 19 08:10:09 2008
@@ -1082,10 +1082,7 @@
files = anjuta_session_get_string_list (session, "File Loader", "Files");
if (!files)
return;
-
- status = anjuta_shell_get_status (shell, NULL);
- anjuta_status_progress_add_ticks (status, g_list_length(files));
-
+
/* Open project files first and then regular files */
for (i = 0; i < 2; i++)
{
@@ -1114,7 +1111,6 @@
ianjuta_file_loader_load (IANJUTA_FILE_LOADER (plugin),
uri, FALSE, NULL);
*/
- anjuta_status_progress_tick (status, NULL, label);
}
else if (i != 0 &&
(!mime_type ||
@@ -1124,7 +1120,6 @@
GFile* file = g_file_new_for_uri (uri);
ianjuta_file_loader_load (IANJUTA_FILE_LOADER (plugin),
file, FALSE, NULL);
- anjuta_status_progress_tick (status, NULL, label);
g_object_unref (file);
}
g_free (filename);
Modified: branches/gnome-2-24/plugins/file-wizard/file.c
==============================================================================
--- branches/gnome-2-24/plugins/file-wizard/file.c (original)
+++ branches/gnome-2-24/plugins/file-wizard/file.c Sun Oct 19 08:10:09 2008
@@ -31,10 +31,8 @@
#include <string.h>
#include <time.h>
-#include <gnome.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs.h>
#include <libanjuta/interfaces/ianjuta-file.h>
+#include <libanjuta/interfaces/ianjuta-file-savable.h>
#include <libanjuta/interfaces/ianjuta-document-manager.h>
#include <libanjuta/interfaces/ianjuta-macro.h>
#include <libanjuta/interfaces/ianjuta-file.h>
@@ -222,41 +220,6 @@
return TRUE;
}
-static gboolean
-confirm_file_overwrite (AnjutaPlugin* plugin, const gchar *uri)
-{
- GnomeVFSURI *vfs_uri;
- gboolean ret = TRUE;
-
- vfs_uri = gnome_vfs_uri_new (uri);
- if (gnome_vfs_uri_exists (vfs_uri))
- {
- GtkWidget *dialog;
- gint res;
- dialog = gtk_message_dialog_new (GTK_WINDOW (ANJUTA_PLUGIN (plugin)->shell),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_NONE,
- _("The file '%s' already exists.\n"
- "Do you want to replace it with the "
- "one you are saving?"),
- uri);
- gtk_dialog_add_button (GTK_DIALOG(dialog),
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_CANCEL);
- anjuta_util_dialog_add_button (GTK_DIALOG (dialog),
- _("_Replace"),
- GTK_STOCK_REFRESH,
- GTK_RESPONSE_YES);
- res = gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- if (res != GTK_RESPONSE_YES)
- ret = FALSE;
- }
- gnome_vfs_uri_unref (vfs_uri);
- return ret;
-}
-
gboolean
on_new_file_okbutton_clicked(GtkWidget *window, GdkEvent *event,
gboolean user_data)
@@ -281,12 +244,18 @@
IAnjutaMacro, NULL);
entry = glade_xml_get_widget(nfg->xml, NEW_FILE_ENTRY);
name = gtk_entry_get_text(GTK_ENTRY(entry));
+
+ if (name && strlen (name) > 0)
+ te = ianjuta_document_manager_add_buffer (docman, name, NULL, NULL);
+ else
+ te = ianjuta_document_manager_add_buffer (docman, "", NULL, NULL);
+ if (te == NULL)
+ return FALSE;
if (nfg->plugin->top_dir &&
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (nfg->add_to_project)))
{
IAnjutaProjectManager *pm;
- GnomeVFSHandle *vfs_write;
gchar* file_uri;
GFile* file;
@@ -294,32 +263,15 @@
IAnjutaProjectManager, NULL);
g_return_val_if_fail (pm != NULL, FALSE);
- file_uri = ianjuta_project_manager_add_source (pm, name, "", NULL);
+ file_uri = ianjuta_project_manager_add_source (pm, name, NULL, NULL);
if (!file_uri)
return FALSE;
-
+
/* Create empty file */
- if (!confirm_file_overwrite (ANJUTA_PLUGIN (nfg->plugin), file_uri) ||
- gnome_vfs_create (&vfs_write, file_uri, GNOME_VFS_OPEN_WRITE,
- FALSE, 0664) != GNOME_VFS_OK ||
- gnome_vfs_close(vfs_write) != GNOME_VFS_OK)
- {
- g_free (file_uri);
- return FALSE;
- }
file = g_file_new_for_uri (file_uri);
- ianjuta_file_open (IANJUTA_FILE (docman), file, NULL);
- g_free (file_uri);
+ ianjuta_file_savable_save_as (IANJUTA_FILE_SAVABLE (te), file, NULL);
g_object_unref (file);
- }
- else
- {
- if (name && strlen (name) > 0)
- te = ianjuta_document_manager_add_buffer (docman, name, "", NULL);
- else
- te = ianjuta_document_manager_add_buffer (docman, "", "", NULL);
- if (te == NULL)
- return FALSE;
+ g_free (file_uri);
}
optionmenu = glade_xml_get_widget(nfg->xml, NEW_FILE_TYPE);
Modified: branches/gnome-2-24/plugins/project-manager/plugin.c
==============================================================================
--- branches/gnome-2-24/plugins/project-manager/plugin.c (original)
+++ branches/gnome-2-24/plugins/project-manager/plugin.c Sun Oct 19 08:10:09 2008
@@ -1708,13 +1708,14 @@
ptr = strrchr (path, ':');
if (ptr)
{
+ *ptr = '\0';
if (ptr[1] == '/')
{
/* ID is source ID, extract source uri */
- ptr = strrchr (ptr, ':');
- return g_strdup (ptr+1);
+ uri = strrchr (path, ':'); /* keep uri scheme */
+ *ptr = ':';
+ return g_strdup (uri+1);
}
- *ptr = '\0';
}
anjuta_shell_get (ANJUTA_PLUGIN (plugin)->shell,
@@ -2161,10 +2162,17 @@
g_return_val_if_fail (GBF_IS_PROJECT (plugin->project), FALSE);
update_operation_begin (plugin);
- default_location_type =
- ianjuta_project_manager_get_element_type (project_manager,
- default_location_uri, NULL);
- location_id = get_element_id_from_uri (plugin, default_location_uri);
+ if (default_location_uri == NULL)
+ {
+ default_location_type = IANJUTA_PROJECT_MANAGER_UNKNOWN;
+ }
+ else
+ {
+ default_location_type =
+ ianjuta_project_manager_get_element_type (project_manager,
+ default_location_uri, NULL);
+ location_id = get_element_id_from_uri (plugin, default_location_uri);
+ }
if (default_location_type == IANJUTA_PROJECT_MANAGER_GROUP)
{
source_id = gbf_project_util_add_source (plugin->model,
Modified: branches/gnome-2-24/plugins/sourceview/sourceview.c
==============================================================================
--- branches/gnome-2-24/plugins/sourceview/sourceview.c (original)
+++ branches/gnome-2-24/plugins/sourceview/sourceview.c Sun Oct 19 08:10:09 2008
@@ -226,6 +226,8 @@
gint len,
Sourceview* sv)
{
+ /* Update the status bar */
+ g_signal_emit_by_name(G_OBJECT(sv), "update_ui");
/* We only want ascii characters */
if (len > 1 || strlen(text) > 1)
return;
@@ -270,6 +272,12 @@
g_signal_emit_by_name(G_OBJECT(sv), "update_ui");
}
+static void on_backspace (GtkTextView* view,
+ Sourceview* sv)
+{
+ g_signal_emit_by_name(G_OBJECT(sv), "update_ui");
+}
+
/* Open / Save stuff */
/* Callback for dialog below */
@@ -554,6 +562,8 @@
G_CALLBACK(on_overwrite_toggled), sv);
g_signal_connect (G_OBJECT(sv->priv->view), "query-tooltip",
G_CALLBACK (on_sourceview_hover_over), sv);
+ g_signal_connect_after(G_OBJECT(sv->priv->view), "backspace",
+ G_CALLBACK(on_backspace),sv);
g_object_set (G_OBJECT (sv->priv->view), "has-tooltip", TRUE, NULL);
gtk_source_view_set_smart_home_end(GTK_SOURCE_VIEW(sv->priv->view), FALSE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]