Revision: 5754
http://geany.svn.sourceforge.net/geany/?rev=5754&view=rev
Author: colombanw
Date: 2011-04-30 21:50:50 +0000 (Sat, 30 Apr 2011)
Log Message:
-----------
Open the file in the msgwindow even if no line number is specified
Plugins may need to open a file from the message window without
specifying the line number, so allow messages of the form:
file[:line[...]]
For instance, all the following are now correctly parsed and the
corresponding file is opened:
/path/to/file
/path/to/file:line
/path/to/file: something not a line
/path/to/file:line: something
/path/to/file:line something
etc.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/msgwindow.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2011-04-30 21:50:37 UTC (rev 5753)
+++ trunk/ChangeLog 2011-04-30 21:50:50 UTC (rev 5754)
@@ -6,6 +6,8 @@
* src/search.c:
Use project patterns in the FIF dialog (based on a patch
by Jiří Techet, thanks).
+ * src/msgwindow.c:
+ Open the file in the msgwindow even if no line number is specified.
2011-04-30 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/src/msgwindow.c
===================================================================
--- trunk/src/msgwindow.c 2011-04-30 21:50:37 UTC (rev 5753)
+++ trunk/src/msgwindow.c 2011-04-30 21:50:50 UTC (rev 5754)
@@ -71,7 +71,6 @@
static void prepare_status_tree_view(void);
static void prepare_compiler_tree_view(void);
static GtkWidget *create_message_popup_menu(gint type);
-static void msgwin_parse_grep_line(const gchar *string, gchar **filename, gint *line);
static gboolean on_msgwin_button_press_event(GtkWidget *widget, GdkEventButton *event,
gpointer user_data);
static void on_scribble_populate(GtkTextView *textview, GtkMenu *arg1, gpointer user_data);
@@ -996,6 +995,51 @@
}
+/* Tries to parse strings of the file:line style, allowing line field to be missing
+ * * filename is filled with the filename, should be freed
+ * * line is filled with the line number or -1 */
+static void msgwin_parse_generic_line(const gchar *string, gchar **filename, gint *line)
+{
+ gchar **fields;
+ gboolean incertain = TRUE; /* whether we're reasonably certain of the result */
+
+ *filename = NULL;
+ *line = -1;
+
+ fields = g_strsplit(string, ":", 2);
+ /* extract the filename */
+ if (fields[0] != NULL)
+ {
+ *filename = g_strdup(fields[0]);
+ if (msgwindow.messages_dir != NULL)
+ make_absolute(filename, msgwindow.messages_dir);
+
+ /* now the line */
+ if (fields[1] != NULL)
+ {
+ gchar *end;
+
+ *line = strtol(fields[1], &end, 10);
+ if (end == fields[1])
+ *line = -1;
+ else if (*end == ':' || g_ascii_isspace(*end))
+ { /* if we have a blank or a separator right after the number, assume we really got a
+ * filename (it's a grep-like syntax) */
+ incertain = FALSE;
+ }
+ }
+
+ /* if we aren't sure we got a supposedly correct filename, check it */
+ if (incertain && ! g_file_test(*filename, G_FILE_TEST_EXISTS))
+ {
+ setptr(*filename, NULL);
+ *line = -1;
+ }
+ }
+ g_strfreev(fields);
+}
+
+
gboolean msgwin_goto_messages_file_line(guint keyval)
{
GtkTreeIter iter;
@@ -1023,14 +1067,15 @@
{
gchar *filename;
- msgwin_parse_grep_line(string, &filename, &line);
- if (filename != NULL && line > -1)
+ /* try with a file:line parsing */
+ msgwin_parse_generic_line(string, &filename, &line);
+ if (filename != NULL)
{
/* use document_open_file to find an already open file, or open it in place */
doc = document_open_file(filename, FALSE, NULL, NULL);
if (doc != NULL)
{
- ret = navqueue_goto_line(old_doc, doc, line);
+ ret = (line < 0) ? TRUE : navqueue_goto_line(old_doc, doc, line);
if (ret && ui_is_keyval_enter_or_return(keyval))
gtk_widget_grab_focus(GTK_WIDGET(doc->editor->sci));
}
@@ -1043,36 +1088,6 @@
}
-/* Try to parse the file and line number for string and when something useful is
- * found, store the line number in *line and the relevant file with the error in
- * *filename.
- * *line will be -1 if no error was found in string.
- * *filename must be freed unless NULL. */
-static void msgwin_parse_grep_line(const gchar *string, gchar **filename, gint *line)
-{
- ParseData data;
-
- *filename = NULL;
- *line = -1;
-
- if (string == NULL)
- return;
-
- /* conflict:3:conflicting types for `foo' */
- data.string = string;
- data.pattern = ":";
- data.min_fields = 3;
- data.line_idx = 1;
- data.file_idx = 0;
-
- parse_file_line(&data, filename, line);
-
- /* FIF dir should be set, but a plugin might not have set it */
- if (msgwindow.messages_dir != NULL)
- make_absolute(filename, msgwindow.messages_dir);
-}
-
-
static gboolean on_msgwin_button_press_event(GtkWidget *widget, GdkEventButton *event,
gpointer user_data)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5751
http://geany.svn.sourceforge.net/geany/?rev=5751&view=rev
Author: ntrel
Date: 2011-04-30 16:24:53 +0000 (Sat, 30 Apr 2011)
Log Message:
-----------
Read color scheme name and description for menu item label and
tooltip (based on patch by Matthew Brush, thanks).
Modified Paths:
--------------
trunk/ChangeLog
trunk/data/colorschemes/alt.conf
trunk/doc/geany.html
trunk/doc/geany.txt
trunk/src/highlighting.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2011-04-30 15:25:09 UTC (rev 5750)
+++ trunk/ChangeLog 2011-04-30 16:24:53 UTC (rev 5751)
@@ -5,6 +5,10 @@
agree on whether e.g. Java is a compiled language).
* doc/geany.txt, doc/geany.html:
Add section 'Filetype group membership'.
+ * src/highlighting.c, doc/geany.txt, doc/geany.html,
+ data/colorschemes/alt.conf:
+ Read color scheme name and description for menu item label and
+ tooltip (based on patch by Matthew Brush, thanks).
2011-04-29 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/data/colorschemes/alt.conf
===================================================================
--- trunk/data/colorschemes/alt.conf 2011-04-30 15:25:09 UTC (rev 5750)
+++ trunk/data/colorschemes/alt.conf 2011-04-30 16:24:53 UTC (rev 5751)
@@ -1,4 +1,6 @@
-# Set of styles like the Geany <= 0.19 Python/script defaults with gray comments.
+[theme_info]
+name=Alternate
+description=Alternate Geany color scheme with styles like the Geany <= 0.19 Python/script defaults with gray comments.
[named_styles]
# see filetypes.common for details
Modified: trunk/doc/geany.html
===================================================================
--- trunk/doc/geany.html 2011-04-30 15:25:09 UTC (rev 5750)
+++ trunk/doc/geany.html 2011-04-30 16:24:53 UTC (rev 5751)
@@ -6,7 +6,7 @@
<meta name="generator" content="Docutils 0.4: http://docutils.sourceforge.net/" />
<title>Geany</title>
<meta name="authors" content="Enrico Tröger Nick Treleaven Frank Lanitz" />
-<meta name="date" content="2011-04-26" />
+<meta name="date" content="2011-04-30" />
<style type="text/css">
/*
@@ -139,7 +139,7 @@
<br />Nick Treleaven
<br />Frank Lanitz</td></tr>
<tr><th class="docinfo-name">Date:</th>
-<td>2011-04-26</td></tr>
+<td>2011-04-30</td></tr>
<tr><th class="docinfo-name">Version:</th>
<td>0.21</td></tr>
</tbody>
@@ -1891,13 +1891,17 @@
on what color scheme files Geany found at startup.</p>
<p>Color scheme files are read from the <a class="reference" href="#configuration-file-paths">Configuration file paths</a> under
the <tt class="docutils literal"><span class="pre">colorschemes</span></tt> subdirectory. They should have the extension
-<tt class="docutils literal"><span class="pre">.conf</span></tt> and currently only contain a <a class="reference" href="#named-styles-section">[named_styles] section</a>. The
-default color scheme is read from <tt class="docutils literal"><span class="pre">filetypes.common</span></tt>.</p>
+<tt class="docutils literal"><span class="pre">.conf</span></tt>. The default color scheme
+is read from <tt class="docutils literal"><span class="pre">filetypes.common</span></tt>.</p>
+<p>The <a class="reference" href="#named-styles-section">[named_styles] section</a> is the same as for <tt class="docutils literal"><span class="pre">filetypes.common</span></tt>.</p>
<div class="note">
<p class="first admonition-title">Note</p>
<p class="last">Some filetypes do not yet support named styles so will ignore
any chosen color scheme.</p>
</div>
+<p>The <tt class="docutils literal"><span class="pre">[theme_info]</span></tt> section can contain information about the
+theme. The <tt class="docutils literal"><span class="pre">name</span></tt> and <tt class="docutils literal"><span class="pre">description</span></tt> keys are read to set the
+menu item text and tooltip, respectively.</p>
</div>
</div>
<div class="section">
@@ -6556,7 +6560,7 @@
<div class="footer">
<hr class="footer" />
<a class="reference" href="geany.txt">View document source</a>.
-Generated on: 2011-04-30 15:22 UTC.
+Generated on: 2011-04-30 16:23 UTC.
Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
</div>
Modified: trunk/doc/geany.txt
===================================================================
--- trunk/doc/geany.txt 2011-04-30 15:25:09 UTC (rev 5750)
+++ trunk/doc/geany.txt 2011-04-30 16:24:53 UTC (rev 5751)
@@ -1478,13 +1478,19 @@
Color scheme files are read from the `Configuration file paths`_ under
the ``colorschemes`` subdirectory. They should have the extension
-``.conf`` and currently only contain a `[named_styles] section`_. The
-default color scheme is read from ``filetypes.common``.
+``.conf``. The default color scheme
+is read from ``filetypes.common``.
+The `[named_styles] section`_ is the same as for ``filetypes.common``.
+
.. note::
Some filetypes do not yet support named styles so will ignore
any chosen color scheme.
+The ``[theme_info]`` section can contain information about the
+theme. The ``name`` and ``description`` keys are read to set the
+menu item text and tooltip, respectively.
+
Tags
----
Modified: trunk/src/highlighting.c
===================================================================
--- trunk/src/highlighting.c 2011-04-30 15:25:09 UTC (rev 5750)
+++ trunk/src/highlighting.c 2011-04-30 16:24:53 UTC (rev 5751)
@@ -3600,7 +3600,7 @@
filetypes_reload();
return;
}
- fname = ui_menu_item_get_text(menuitem);
+ fname = g_strdup(g_object_get_data(G_OBJECT(menuitem), "colorscheme_file"));
setptr(fname, utils_get_locale_from_utf8(fname));
/* fname is just the basename from the menu item, so prepend the custom files path */
@@ -3632,16 +3632,37 @@
static GSList *group = NULL;
GtkWidget *item;
- if (fname)
+ if (!fname)
{
- gchar *label = utils_get_utf8_from_locale(fname);
-
- item = gtk_radio_menu_item_new_with_label(group, label);
- g_free(label);
+ item = gtk_radio_menu_item_new_with_mnemonic(group, _("_Default"));
}
else
- item = gtk_radio_menu_item_new_with_mnemonic(group, _("_Default"));
+ {
+ GKeyFile *hkeyfile, *skeyfile;
+ gchar *path, *theme_name, *tooltip;
+ gchar *theme_fn = utils_get_utf8_from_locale(fname);
+ path = utils_build_path(app->configdir, GEANY_COLORSCHEMES_SUBDIR, fname, NULL);
+ hkeyfile = utils_key_file_new(path);
+ setptr(path, utils_build_path(app->datadir, GEANY_COLORSCHEMES_SUBDIR, fname, NULL));
+ skeyfile = utils_key_file_new(path);
+
+ theme_name = utils_get_setting(string, hkeyfile, skeyfile, "theme_info", "name", theme_fn);
+ item = gtk_radio_menu_item_new_with_label(group, theme_name);
+ g_object_set_data_full(G_OBJECT(item), "colorscheme_file", theme_fn, g_free);
+
+ tooltip = utils_get_setting(string, hkeyfile, skeyfile, "theme_info", "description", NULL);
+ if (tooltip != NULL)
+ {
+ ui_widget_set_tooltip_text(item, tooltip);
+ g_free(tooltip);
+ }
+ g_free(path);
+ g_free(theme_name);
+ g_key_file_free(hkeyfile);
+ g_key_file_free(skeyfile);
+ }
+
group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(item));
if (utils_str_equal(editor_prefs.color_scheme, fname))
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5747
http://geany.svn.sourceforge.net/geany/?rev=5747&view=rev
Author: ntrel
Date: 2011-04-29 16:49:32 +0000 (Fri, 29 Apr 2011)
Log Message:
-----------
Make custom filetype titles use 'source file' only if their group
is Compiled or Script.
Use 'source file' for reStructuredText title.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/filetypes.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2011-04-29 16:27:40 UTC (rev 5746)
+++ trunk/ChangeLog 2011-04-29 16:49:32 UTC (rev 5747)
@@ -9,6 +9,10 @@
Fix filetype title for some languages.
Don't use 'Languages' for Miscellaneous group label.
These changes mostly proposed by Matthew Brush (thanks).
+ * src/filetypes.c:
+ Make custom filetype titles use 'source file' only if their group
+ is Compiled or Script.
+ Use 'source file' for reStructuredText title.
2011-04-26 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/src/filetypes.c
===================================================================
--- trunk/src/filetypes.c 2011-04-29 16:27:40 UTC (rev 5746)
+++ trunk/src/filetypes.c 2011-04-29 16:49:32 UTC (rev 5747)
@@ -442,7 +442,7 @@
ft = filetypes[GEANY_FILETYPES_REST];
ft->lang = 28;
ft->name = g_strdup("reStructuredText");
- filetype_make_title(ft, TITLE_FILE);
+ filetype_make_title(ft, TITLE_SOURCE_FILE);
ft->group = GEANY_FILETYPE_GROUP_MARKUP;
#define MATLAB
@@ -573,7 +573,7 @@
ft = filetype_new();
ft->name = g_strdup(fn);
- filetype_make_title(ft, TITLE_SOURCE_FILE);
+ filetype_make_title(ft, TITLE_FILE);
ft->priv->custom = TRUE;
filetype_add(ft);
geany_debug("Added filetype %s (%d).", ft->name, ft->id);
@@ -1640,7 +1640,15 @@
GeanyFiletype *ft = filetypes_lookup_by_name(*name);
if (ft)
+ {
ft->group = group_id;
+ if (ft->priv->custom &&
+ (group_id == GEANY_FILETYPE_GROUP_COMPILED || group_id == GEANY_FILETYPE_GROUP_SCRIPT))
+ {
+ setptr(ft->title, NULL);
+ filetype_make_title(ft, TITLE_SOURCE_FILE);
+ }
+ }
else
geany_debug("Filetype '%s' not found for group '%s'!", *name, group_name);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.