anjuta r4045 - in trunk: . plugins/debug-manager plugins/document-manager plugins/language-support-cpp-java
- From: jhs svn gnome org
- To: svn-commits-list gnome org
- Subject: anjuta r4045 - in trunk: . plugins/debug-manager plugins/document-manager plugins/language-support-cpp-java
- Date: Thu, 3 Jul 2008 09:22:33 +0000 (UTC)
Author: jhs
Date: Thu Jul 3 09:22:32 2008
New Revision: 4045
URL: http://svn.gnome.org/viewvc/anjuta?rev=4045&view=rev
Log:
2008-07-03 Johannes Schmid <jhs gnome org>
* plugins/debug-manager/plugin.c (dma_plugin_location_changed):
Removed useless DEBUG_PRINTs
* plugins/document-manager/action-callbacks.c:
* plugins/document-manager/action-callbacks.h:
* plugins/document-manager/anjuta-docman.c
(anjuta_docman_goto_file_line_mark):
* plugins/document-manager/anjuta-document-manager.ui:
* plugins/document-manager/plugin.c
(update_document_ui_interface_items), (register_stock_icons):
* plugins/language-support-cpp-java/anjuta-language-support-cpp-jav
a.ui:
* plugins/language-support-cpp-java/plugin.c (on_swap_activate),
(register_stock_icons):
Moved \"Swap .c/.h\" from document-manager to language-support where it
belongs and reimplemented it without gnome-vfs
Modified:
trunk/ChangeLog
trunk/plugins/debug-manager/plugin.c
trunk/plugins/document-manager/action-callbacks.c
trunk/plugins/document-manager/action-callbacks.h
trunk/plugins/document-manager/anjuta-docman.c
trunk/plugins/document-manager/anjuta-document-manager.ui
trunk/plugins/document-manager/plugin.c
trunk/plugins/language-support-cpp-java/anjuta-language-support-cpp-java.ui
trunk/plugins/language-support-cpp-java/plugin.c
Modified: trunk/plugins/debug-manager/plugin.c
==============================================================================
--- trunk/plugins/debug-manager/plugin.c (original)
+++ trunk/plugins/debug-manager/plugin.c Thu Jul 3 09:22:32 2008
@@ -566,8 +566,6 @@
if (file != NULL)
{
IAnjutaDocumentManager *docman;
- DEBUG_PRINT ("Plugin uri: %s", g_file_get_uri (file));
-
docman = anjuta_shell_get_interface (ANJUTA_PLUGIN(self)->shell, IAnjutaDocumentManager, NULL);
if (docman)
{
Modified: trunk/plugins/document-manager/action-callbacks.c
==============================================================================
--- trunk/plugins/document-manager/action-callbacks.c (original)
+++ trunk/plugins/document-manager/action-callbacks.c Thu Jul 3 09:22:32 2008
@@ -877,42 +877,6 @@
}
}
-/* Gets the swapped (c/h) file names */
-static GFile*
-get_swapped_filename (GFile* file)
-{
- // TODO!
- return NULL;
-}
-
-void
-on_swap_activate (GtkAction *action, gpointer user_data)
-{
- IAnjutaDocument *doc;
- AnjutaDocman *docman;
- DocmanPlugin *plugin;
-
- plugin = ANJUTA_PLUGIN_DOCMAN (user_data);
- docman = ANJUTA_DOCMAN (plugin->docman);
- doc = anjuta_docman_get_current_document (docman);
- if (doc)
- {
- GFile* file;
- file = ianjuta_file_get_file (IANJUTA_FILE (doc), NULL);
- if (file)
- {
- GFile* new_file;
- new_file = get_swapped_filename (file);
- if (new_file)
- {
- anjuta_docman_goto_file_line (docman, new_file, -1);
- g_object_unref (new_file);
- }
- g_object_unref (file);
- }
- }
-}
-
void
on_show_search (GtkAction *action, gpointer user_data)
{
Modified: trunk/plugins/document-manager/action-callbacks.h
==============================================================================
--- trunk/plugins/document-manager/action-callbacks.h (original)
+++ trunk/plugins/document-manager/action-callbacks.h Thu Jul 3 09:22:32 2008
@@ -93,7 +93,6 @@
void on_indent1_activate (GtkAction *action, gpointer user_data);
void on_format_indent_style_clicked (GtkAction *action, gpointer user_data);
-void on_swap_activate (GtkAction *action, gpointer user_data);
void on_editor_add_view_activate (GtkAction *action, gpointer user_data);
void on_editor_remove_view_activate (GtkAction *action, gpointer user_data);
Modified: trunk/plugins/document-manager/anjuta-docman.c
==============================================================================
--- trunk/plugins/document-manager/anjuta-docman.c (original)
+++ trunk/plugins/document-manager/anjuta-docman.c Thu Jul 3 09:22:32 2008
@@ -1225,8 +1225,6 @@
const gchar* line_str;
GFile* real_file;
- DEBUG_PRINT ("Open uri: %s", uri);
-
if ((line_str = strstr(uri, "#")) && line <= 0)
{
line = atoi (line_str + 1);
Modified: trunk/plugins/document-manager/anjuta-document-manager.ui
==============================================================================
--- trunk/plugins/document-manager/anjuta-document-manager.ui (original)
+++ trunk/plugins/document-manager/anjuta-document-manager.ui Thu Jul 3 09:22:32 2008
@@ -131,8 +131,6 @@
<toolitem name="Undo" action="ActionEditUndo" />
<toolitem name="Redo" action="ActionEditRedo" />
<separator name="separator17" />
- <toolitem name="Swap" action="ActionFileSwap" />
- <separator name="separator18" />
<toolitem name="Print" action="ActionPrintFile" />
</placeholder>
</toolbar>
@@ -155,7 +153,6 @@
<menuitem name="Copy" action="ActionEditCopy" />
<menuitem name="Paste" action="ActionEditPaste" />
<separator name="separator26"/>
- <menuitem name="Swap" action="ActionFileSwap" />
<menuitem name="Toggle" action="ActionBookmarkToggle" />
<menu name="Goto" action="ActionMenuGoto">
<separator name="separator27"/>
Modified: trunk/plugins/document-manager/plugin.c
==============================================================================
--- trunk/plugins/document-manager/plugin.c (original)
+++ trunk/plugins/document-manager/plugin.c Thu Jul 3 09:22:32 2008
@@ -53,8 +53,6 @@
#define PREFS_GLADE PACKAGE_DATA_DIR"/glade/anjuta-document-manager.glade"
#define ICON_FILE "anjuta-document-manager-plugin-48.png"
-/* Pixmaps */
-#define ANJUTA_PIXMAP_SWAP "anjuta-swap"
#define ANJUTA_PIXMAP_BOOKMARK_TOGGLE "anjuta-bookmark-toggle"
#define ANJUTA_PIXMAP_BOOKMARK_FIRST "anjuta-bookmark-first"
#define ANJUTA_PIXMAP_BOOKMARK_PREV "anjuta-bookmark-prev"
@@ -80,7 +78,6 @@
/* Stock icons */
-#define ANJUTA_STOCK_SWAP "anjuta-swap"
#define ANJUTA_STOCK_FOLD_TOGGLE "anjuta-fold-toggle"
#define ANJUTA_STOCK_FOLD_OPEN "anjuta-fold-open"
#define ANJUTA_STOCK_FOLD_CLOSE "anjuta-fold-close"
@@ -167,9 +164,6 @@
{ "ActionFileReload", GTK_STOCK_REVERT_TO_SAVED, N_("Reload F_ile"), NULL,
N_("Reload current file"),
G_CALLBACK (on_reload_file_activate)},
- { "ActionFileSwap", ANJUTA_STOCK_SWAP, N_("Swap .h/.c"), NULL,
- N_("Swap c header and source files"),
- G_CALLBACK (on_swap_activate)},
{ "ActionMenuFileRecentFiles", NULL, N_("Recent _Files"), NULL, NULL, NULL}, /* menu title */
};
@@ -722,23 +716,6 @@
action = anjuta_ui_get_action (ui, "ActionGroupEditorStyle",
"ActionMenuFormatStyle");
g_object_set (G_OBJECT (action), "visible", flag, "sensitive", flag, NULL);
-
- if (flag)
- {
- IAnjutaLanguage *language;
- language = anjuta_shell_get_interface (plugin->shell, IAnjutaLanguage, NULL);
- if (language)
- {
- /* Check if it is a C or C++ file */
- const gchar *lang_name =
- ianjuta_language_get_name_from_editor (language, IANJUTA_EDITOR_LANGUAGE (doc), NULL);
- flag = (lang_name && (g_str_equal (lang_name, "C") || g_str_equal (lang_name, "C++")));
- }
- }
-
- action = anjuta_ui_get_action (ui, "ActionGroupEditorFile",
- "ActionFileSwap");
- g_object_set (G_OBJECT (action), "sensitive", flag, NULL);
/* IAnjutaDocument */
flag = IANJUTA_IS_DOCUMENT (doc);
@@ -903,7 +880,6 @@
/* Register stock icons */
BEGIN_REGISTER_ICON (plugin);
REGISTER_ICON (ICON_FILE, "editor-plugin-icon");
- REGISTER_ICON_FULL (ANJUTA_PIXMAP_SWAP, ANJUTA_STOCK_SWAP);
REGISTER_ICON_FULL (ANJUTA_PIXMAP_FOLD_TOGGLE, ANJUTA_STOCK_FOLD_TOGGLE);
REGISTER_ICON_FULL (ANJUTA_PIXMAP_FOLD_OPEN, ANJUTA_STOCK_FOLD_OPEN);
REGISTER_ICON_FULL (ANJUTA_PIXMAP_FOLD_CLOSE, ANJUTA_STOCK_FOLD_CLOSE);
Modified: trunk/plugins/language-support-cpp-java/anjuta-language-support-cpp-java.ui
==============================================================================
--- trunk/plugins/language-support-cpp-java/anjuta-language-support-cpp-java.ui (original)
+++ trunk/plugins/language-support-cpp-java/anjuta-language-support-cpp-java.ui Thu Jul 3 09:22:32 2008
@@ -9,4 +9,9 @@
</placeholder>
</menu>
</menubar>
+ <popup name="PopupDocumentManager">
+ <separator name="separator1"/>
+ <menuitem name="Swap" action="ActionFileSwap" />
+ <separator name="separator2"/>
+ </popup>
</ui>
Modified: trunk/plugins/language-support-cpp-java/plugin.c
==============================================================================
--- trunk/plugins/language-support-cpp-java/plugin.c (original)
+++ trunk/plugins/language-support-cpp-java/plugin.c Thu Jul 3 09:22:32 2008
@@ -26,6 +26,7 @@
#include <libanjuta/interfaces/ianjuta-document.h>
#include <libanjuta/interfaces/ianjuta-document-manager.h>
#include <libanjuta/interfaces/ianjuta-editor.h>
+#include <libanjuta/interfaces/ianjuta-file.h>
#include <libanjuta/interfaces/ianjuta-editor-cell.h>
#include <libanjuta/interfaces/ianjuta-editor-language.h>
#include <libanjuta/interfaces/ianjuta-editor-selection.h>
@@ -37,9 +38,12 @@
#include "plugin.h"
#include "cpp-java-utils.h"
+/* Pixmaps */
+#define ANJUTA_PIXMAP_SWAP "anjuta-swap"
#define ANJUTA_PIXMAP_COMPLETE "anjuta-complete"
#define ANJUTA_PIXMAP_AUTOCOMPLETE "anjuta-complete-auto"
#define ANJUTA_PIXMAP_AUTOINDENT "anjuta-indent-auto"
+#define ANJUTA_STOCK_SWAP "anjuta-swap"
#define ANJUTA_STOCK_COMPLETE "anjuta-complete"
#define ANJUTA_STOCK_AUTOCOMPLETE "anjuta-autocomplete"
#define ANJUTA_STOCK_AUTOINDENT "anjuta-indent"
@@ -1663,6 +1667,117 @@
lang_plugin->current_editor = NULL;
}
+const gchar* SOURCE_EXT[] =
+{
+ ".c",
+ ".cc",
+ ".C",
+ ".cpp",
+ ".cxx",
+ ".ccg",
+ NULL
+};
+
+const gchar* HEADER_EXT[] =
+{
+ ".h",
+ ".hh",
+ ".H",
+ ".hpp",
+ ".hxx",
+ ".hg",
+ NULL
+};
+
+static void
+on_swap_activate (GtkAction* action, gpointer data)
+{
+ GFile* file;
+ GFile* parent;
+ gchar* parent_uri;
+ gchar* basename;
+ gchar* ext;
+ CppJavaPlugin *lang_plugin = ANJUTA_PLUGIN_CPP_JAVA (data);
+ IAnjutaDocumentManager* docman =
+ anjuta_shell_get_interface (ANJUTA_PLUGIN(lang_plugin)->shell,
+ IAnjutaDocumentManager,
+ NULL);
+ if (!lang_plugin->current_editor || !docman)
+ return;
+
+ file = ianjuta_file_get_file (IANJUTA_FILE (lang_plugin->current_editor),
+ NULL);
+ parent = g_file_get_parent (file);
+ parent_uri = g_file_get_uri (parent);
+ basename = g_file_get_basename (file);
+ g_object_unref (file);
+ g_object_unref (parent);
+ ext = strstr (basename, ".");
+ if (ext)
+ {
+ int i;
+ for (i = 0; SOURCE_EXT[i] != NULL; i++)
+ {
+ if (g_str_equal (ext, SOURCE_EXT[i]))
+ {
+ int j;
+ for (j = 0; HEADER_EXT[j] != NULL; j++)
+ {
+ gchar* filename;
+ gchar* uri;
+ GFile* new_file;
+ *ext = '\0';
+ filename = g_strdup_printf ("%s%s", basename, HEADER_EXT[j]);
+ uri = g_build_filename (parent_uri, filename, NULL);
+ new_file = g_file_new_for_uri (uri);
+ g_free (uri);
+ g_free(filename);
+ if (g_file_query_exists (new_file, NULL))
+ {
+ ianjuta_document_manager_goto_file_line (docman,
+ new_file,
+ -1,
+ NULL);
+ g_object_unref (new_file);
+ break;
+ }
+ g_object_unref (new_file);
+ }
+ break;
+ }
+ if (g_str_equal (ext, HEADER_EXT[i]))
+ {
+ int j;
+ for (j = 0; SOURCE_EXT[j] != NULL; j++)
+ {
+ gchar* filename;
+ gchar* uri;
+ GFile* new_file;
+ *ext = '\0';
+ filename = g_strdup_printf ("%s%s", basename, SOURCE_EXT[j]);
+ uri = g_build_filename (parent_uri, filename, NULL);
+ new_file = g_file_new_for_uri (uri);
+ g_free (uri);
+ g_free(filename);
+ if (g_file_query_exists (new_file, NULL))
+ {
+ ianjuta_document_manager_goto_file_line (docman,
+ new_file,
+ -1,
+ NULL);
+ g_object_unref (new_file);
+ break;
+ }
+ g_object_unref (new_file);
+ }
+ break;
+ }
+ }
+ }
+ g_free(basename);
+ g_free (parent_uri);
+}
+
static void
on_auto_indent (GtkAction *action, gpointer data)
{
@@ -1736,6 +1851,12 @@
N_("Auto Indent"), "<control>i",
N_("Auto indent current line or selection based on indentation settings"),
G_CALLBACK (on_auto_indent)
+ },
+ { "ActionFileSwap",
+ ANJUTA_STOCK_SWAP,
+ N_("Swap .h/.c"), NULL,
+ N_("Swap c header and source files"),
+ G_CALLBACK (on_swap_activate)
}
};
@@ -1750,6 +1871,7 @@
/* Register stock icons */
BEGIN_REGISTER_ICON (plugin);
+ REGISTER_ICON_FULL (ANJUTA_PIXMAP_SWAP, ANJUTA_STOCK_SWAP);
REGISTER_ICON_FULL (ANJUTA_PIXMAP_COMPLETE, ANJUTA_STOCK_COMPLETE);
REGISTER_ICON_FULL (ANJUTA_PIXMAP_AUTOCOMPLETE, ANJUTA_STOCK_AUTOCOMPLETE);
REGISTER_ICON_FULL (ANJUTA_PIXMAP_AUTOINDENT, ANJUTA_STOCK_AUTOINDENT);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]