Revision: 4551
http://geany.svn.sourceforge.net/geany/?rev=4551&view=rev
Author: ntrel
Date: 2010-01-25 15:45:27 +0000 (Mon, 25 Jan 2010)
Log Message:
-----------
Avoid some unnecessary reallocations, add comment.
Modified Paths:
--------------
trunk/src/editor.c
Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c 2010-01-24 20:25:17 UTC (rev 4550)
+++ trunk/src/editor.c 2010-01-25 15:45:27 UTC (rev 4551)
@@ -1795,6 +1795,7 @@
flags = SCFIND_WORDSTART | SCFIND_MATCHCASE;
words = g_string_sized_new(256);
+ /* put space before first entry to make searching with strstr easy */
g_string_append_c(words, ' ');
/* search the whole document for the word root and collect results */
@@ -1872,7 +1873,7 @@
}
list = g_slist_sort(list, (GCompareFunc)utils_str_casecmp);
- str = g_string_sized_new(256);
+ str = g_string_sized_new(words->len);
foreach_slist(node, list)
{
g_string_append(str, node->data);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4549
http://geany.svn.sourceforge.net/geany/?rev=4549&view=rev
Author: statc
Date: 2010-01-24 20:24:52 +0000 (Sun, 24 Jan 2010)
Log Message:
-----------
Use `GeanyDocument.file_name's instead of `GeanyDocument.real_path's in restart command like Geany session management facilities do.
Modified Paths:
--------------
branches/sm/src/sm.c
Modified: branches/sm/src/sm.c
===================================================================
--- branches/sm/src/sm.c 2010-01-24 20:24:33 UTC (rev 4548)
+++ branches/sm/src/sm.c 2010-01-24 20:24:52 UTC (rev 4549)
@@ -59,6 +59,7 @@
#include "main.h" /* for cl_options */
#include "ui_utils.h" /* access main_widgets.notebook to iterate over opened docs */
#include "document.h"
+#include "utils.h"
static void ice_connection_watch(IceConn icecon, IcePointer client_data, Bool opening,
@@ -390,26 +391,31 @@
static void sm_set_runtime_props(SmcConn smcon)
{
const gint page_count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook));
- gint page;
GArray * arr;
- gint arr_real_len;
+ gint arr_real_len, arr_filenames_begin;
SmProp restart_command_prop, clone_command_prop;
SmPropValue * val;
SmProp * prop;
+ gint i;
/*
- * Allocate space for `page_count+4' elements:
+ * Allocate space for `page_count+5' elements:
* * two elements for program name and client ID;
* * possibly one element for "--no-session" option;
* * possibly one element for "--new-instance" option;
+ * * possible one element for "--" to separate options and filenames;
* * max `page_count' elements for file paths.
- * Store the number of actually used elements in `arr_real_len'.
+ * The number of actually used elements is saved in `arr_real_len'.
+ * Variable `arr_filenames_begin' stores the index in the array where
+ * the list of filenames begin. If there are no filenames in `arr',
+ * the value is -1.
*/
- arr = g_array_sized_new(FALSE, FALSE, sizeof(SmPropValue), page_count+4);
+ arr = g_array_sized_new(FALSE, FALSE, sizeof(SmPropValue), page_count + 5);
arr_real_len = 0;
+ arr_filenames_begin = -1;
((SmPropValue *)arr->data)[arr_real_len++] = sm_program_val;
((SmPropValue *)arr->data)[arr_real_len++] = sm_client_id_arg_val;
@@ -441,15 +447,29 @@
}
else
{
- /* specify file names in the command line */
- for (page = 0; page < page_count; page++)
+ /* Specify file names in the command line */
+
+ val = ((SmPropValue *)arr->data) + arr_real_len++;
+ val->length = 2; /* length of "--" */
+ val->value = "--";
+
+ arr_filenames_begin = arr_real_len;
+
+ /*
+ * NOTE: compare this cycle with the one inside
+ * configuration_save_session_files() function in keyfile.c.
+ */
+ for (i = 0; i < page_count; i++)
{
- GeanyDocument * doc = document_get_from_page(page);
- if (doc->real_path)
+ GeanyDocument * doc = document_get_from_page(i);
+ if (doc && doc->real_path)
{
+ /* this string will be freed when `arr' is no longer needed */
+ gchar * locale_filename = utils_get_locale_from_utf8(doc->file_name);
+
val = ((SmPropValue *)arr->data) + arr_real_len++;
- val->length = strlen(doc->real_path);
- val->value = doc->real_path;
+ val->length = strlen(locale_filename);
+ val->value = locale_filename;
}
}
}
@@ -470,10 +490,14 @@
clone_command_prop.name = SmCloneCommand;
clone_command_prop.type = SmLISTofARRAY8;
clone_command_prop.num_vals = arr_real_len - 1;
- clone_command_prop.vals = (SmPropValue *)arr->data + 1;
+ clone_command_prop.vals = ((SmPropValue *)arr->data) + 1;
prop = &clone_command_prop;
SmcSetProperties(smcon, 1, &prop);
+
+ if (arr_filenames_begin != -1)
+ for (i = arr_filenames_begin; i < arr_real_len; i++)
+ g_free(((SmPropValue *)arr->data)[i].value);
g_array_free(arr, TRUE);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4548
http://geany.svn.sourceforge.net/geany/?rev=4548&view=rev
Author: statc
Date: 2010-01-24 20:24:33 +0000 (Sun, 24 Jan 2010)
Log Message:
-----------
Handle --no-session properly.
The previous commit allows us to change --no-session command line option
handling back to normal. The issue was described in a FIXME section
inside src/sm.c, the section is now deleted.
Modified Paths:
--------------
branches/sm/src/sm.c
Modified: branches/sm/src/sm.c
===================================================================
--- branches/sm/src/sm.c 2010-01-24 20:24:13 UTC (rev 4547)
+++ branches/sm/src/sm.c 2010-01-24 20:24:33 UTC (rev 4548)
@@ -389,44 +389,6 @@
*/
static void sm_set_runtime_props(SmcConn smcon)
{
- /*
- * FIXME: We have to specify '--no-session' command-line argument in commands.
- *
- * Reason:
- *
- * Currently all Geany instances try to save session. Consider the
- * following use case.
- *
- * User creates two instances of geany, a "main" one (for example, using
- * the main menu of his DE) and a "non-main" one typing 'geany --new-instance'
- * in a terminal emulator. When this user logouts, session manager sends
- * termination messages to Geany instances in unpredictable order. Geany
- * session will be saved by the instance that was last to handle the
- * message. Suppose that was the "non-main" Geany instance.
- *
- * When the user logins again, session manager restores Geany instances,
- * again in unpredictable order. If we do not supply '--no-session' argument,
- * the "main" instance will catch the session stored by the "non-main"
- * one, which is not desired behaviour.
- *
- * Drawbacks of the '--no-session' solution:
- *
- * The "main" instance won't save Geany session as required.
- *
- * Possible fixes:
- *
- * * Disable saving of Geany session for "non-main" Geany instances.
- * Sounds sensible and applicable.
- *
- * * Save session even when '--no-session' option is specified (i.e.,
- * consider this options only when reading Geany session). Sounds
- * non-applicable as the described behaviour does not match
- * even the option's name.
- *
- * * Create a separate option to be used when reading Geany session
- * is needed and writing Geany session is forbidden. Sounds awkward.
- */
-
const gint page_count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook));
gint page;
@@ -440,20 +402,25 @@
/*
* Allocate space for `page_count+4' elements:
- * * tree elements for program name, client ID and '--no-session' option;
- * * possibly one element for '--new-instance' option;
+ * * two elements for program name and client ID;
+ * * possibly one element for "--no-session" option;
+ * * possibly one element for "--new-instance" option;
* * max `page_count' elements for file paths.
* Store the number of actually used elements in `arr_real_len'.
*/
arr = g_array_sized_new(FALSE, FALSE, sizeof(SmPropValue), page_count+4);
arr_real_len = 0;
- ((SmPropValue *)arr->data)[0] = sm_program_val;
- ((SmPropValue *)arr->data)[1] = sm_client_id_arg_val;
- ((SmPropValue *)arr->data)[2].length = 2; /* length of "-s" */
- ((SmPropValue *)arr->data)[2].value = "-s";
- arr_real_len = 3;
+ ((SmPropValue *)arr->data)[arr_real_len++] = sm_program_val;
+ ((SmPropValue *)arr->data)[arr_real_len++] = sm_client_id_arg_val;
+ if (!cl_options.load_session)
+ {
+ val = ((SmPropValue *)arr->data) + arr_real_len++;
+ val->length = 2; /* length of "-s" */
+ val->value = "-s";
+ }
+
#ifdef HAVE_SOCKET
if (cl_options.new_instance)
{
@@ -462,19 +429,32 @@
val->value = "-i";
}
#endif
+
/* TODO: handle other command-line options */
- for (page = 0; page < page_count; page++)
+ if (cl_options.load_session && !cl_options.new_instance)
{
- GeanyDocument * doc = document_get_from_page(page);
- if (doc->real_path)
+ /*
+ * Files will be restored by Geany session management facilities.
+ * NOTE: the condition matches the one inside configuration_save() function in keyfile.c.
+ */
+ }
+ else
+ {
+ /* specify file names in the command line */
+ for (page = 0; page < page_count; page++)
{
- val = ((SmPropValue *)arr->data) + arr_real_len++;
- val->length = strlen(doc->real_path);
- val->value = doc->real_path;
+ GeanyDocument * doc = document_get_from_page(page);
+ if (doc->real_path)
+ {
+ val = ((SmPropValue *)arr->data) + arr_real_len++;
+ val->length = strlen(doc->real_path);
+ val->value = doc->real_path;
+ }
}
}
+
restart_command_prop.name = SmRestartCommand;
restart_command_prop.type = SmLISTofARRAY8;
restart_command_prop.num_vals = arr_real_len;
@@ -487,7 +467,6 @@
* so "remove" the corresponding element from `arr'.
*/
((SmPropValue *)arr->data)[1] = sm_program_val;
-
clone_command_prop.name = SmCloneCommand;
clone_command_prop.type = SmLISTofARRAY8;
clone_command_prop.num_vals = arr_real_len - 1;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4544
http://geany.svn.sourceforge.net/geany/?rev=4544&view=rev
Author: statc
Date: 2010-01-24 20:23:14 +0000 (Sun, 24 Jan 2010)
Log Message:
-----------
Add sm_finalize().
Modified Paths:
--------------
branches/sm/src/main.c
branches/sm/src/sm.c
branches/sm/src/sm.h
Modified: branches/sm/src/main.c
===================================================================
--- branches/sm/src/main.c 2010-01-24 20:06:09 UTC (rev 4543)
+++ branches/sm/src/main.c 2010-01-24 20:23:14 UTC (rev 4544)
@@ -1122,6 +1122,8 @@
project_close(FALSE, FALSE);
document_close_all(TRUE);
+ sm_finalize();
+
#ifdef HAVE_SOCKET
socket_finalize();
#endif
Modified: branches/sm/src/sm.c
===================================================================
--- branches/sm/src/sm.c 2010-01-24 20:06:09 UTC (rev 4543)
+++ branches/sm/src/sm.c 2010-01-24 20:23:14 UTC (rev 4544)
@@ -27,7 +27,8 @@
* In order to support XSMP, we have to support Inter-Client Exchange
* Protocol (ICE). This file takes care of the latter too.
*
- * Typical usage: @c sm_init() is called when Geany is starting.
+ * Typical usage: @c sm_init() is called when Geany is starting and
+ * @c sm_finalize() is called when Geany is quitting.
*
* According to libSM documentation, client should retain the same ID after
* it is restarted. The main module (@c main.c) maintains "--libsm-client-id"
@@ -78,6 +79,9 @@
static void sm_die_callback(SmcConn smcon, SmPointer client_data);
+/** LibSM connection object initialized in @c sm_init() and used in @c sm_finalize(). */
+static SmcConn smc_conn;
+
/**
* @c SmPropValue storing a path to Geany's executable.
*
@@ -123,19 +127,43 @@
void sm_init(const char * argv0, const char * libsm_client_id)
{
#ifdef HAVE_LIBSM
-
char * new_client_id;
- SmcConn smcon = sm_connect(libsm_client_id, &new_client_id);
- if (!smcon)
+ /* This function should be called once */
+ g_assert(!smc_conn);
+ if (smc_conn)
+ return;
+
+ smc_conn = sm_connect(libsm_client_id, &new_client_id);
+ if (!smc_conn)
return;
sm_store_props(argv0, new_client_id);
- sm_set_constant_props(smcon);
+ sm_set_constant_props(smc_conn);
free(new_client_id);
#endif
}
+
+/**
+ * Perform cleanup.
+ *
+ * Call this function when XSMP support is no longer needed. In fact it is
+ * called when Geany is quitting.
+ *
+ * When Geany is compiled without XSMP support, this function is a no-op.
+ */
+void sm_finalize(void)
+{
+ #ifdef HAVE_LIBSM
+ if (smc_conn)
+ {
+ SmcCloseConnection(smc_conn, 0, NULL);
+ smc_conn = 0;
+ }
+ #endif
+}
+
/** @} */
#ifdef HAVE_LIBSM
@@ -590,11 +618,12 @@
*
* See libSM documentation for more details.
*
- * The session manager asks us to quit Geany and we do it.
+ * The session manager asks us to quit Geany and we do it. When quitting, the
+ * main module (@c main.c) will call @c sm_finalize() where we will close the
+ * connection to the session manager.
*/
static void sm_die_callback(SmcConn smcon, SmPointer client_data)
{
- SmcCloseConnection(smcon, 0, NULL);
main_finalize();
}
Modified: branches/sm/src/sm.h
===================================================================
--- branches/sm/src/sm.h 2010-01-24 20:06:09 UTC (rev 4543)
+++ branches/sm/src/sm.h 2010-01-24 20:23:14 UTC (rev 4544)
@@ -25,4 +25,6 @@
void sm_init(const char * argv0, const char * libsm_client_id);
+void sm_finalize(void);
+
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4542
http://geany.svn.sourceforge.net/geany/?rev=4542&view=rev
Author: eht16
Date: 2010-01-24 16:30:29 +0000 (Sun, 24 Jan 2010)
Log Message:
-----------
Rename fold_symbol_click() to editor_toggle_fold().
Use editor_toggle_fold() when the 'Toggle current fold' keybinding was used to respect the 'Fold/unfold all children' preference (closes #2935053).
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/editor.c
trunk/src/editor.h
trunk/src/keybindings.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-01-24 16:18:11 UTC (rev 4541)
+++ trunk/ChangeLog 2010-01-24 16:30:29 UTC (rev 4542)
@@ -12,6 +12,11 @@
Replace the old icons with smiley icons from the Rodent icon theme.
Fix showing the same icon for two or more slots.
Minor cleanups.
+ * src/editor.c, src/editor.j, src/keybindings.c:
+ Rename fold_symbol_click() to editor_toggle_fold().
+ Use editor_toggle_fold() when the 'Toggle current fold' keybinding
+ was used to respect the 'Fold/unfold all children' preference
+ (closes #2935053).
2010-01-22 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c 2010-01-24 16:18:11 UTC (rev 4541)
+++ trunk/src/editor.c 2010-01-24 16:30:29 UTC (rev 4542)
@@ -272,16 +272,21 @@
}
-static void fold_symbol_click(ScintillaObject *sci, SCNotification *nt)
+void editor_toggle_fold(GeanyEditor *editor, gint line, gint modifiers)
{
- gint line = sci_get_line_from_position(sci, nt->position);
+ ScintillaObject *sci;
+ g_return_if_fail(editor != NULL);
+
+ sci = editor->sci;
+
sci_toggle_fold(sci, line);
+
/* extra toggling of child fold points
* use when editor_prefs.unfold_all_children is set and Shift is NOT pressed or when
* editor_prefs.unfold_all_children is NOT set but Shift is pressed */
- if ((editor_prefs.unfold_all_children && ! (nt->modifiers & SCMOD_SHIFT)) ||
- (! editor_prefs.unfold_all_children && (nt->modifiers & SCMOD_SHIFT)))
+ if ((editor_prefs.unfold_all_children && ! (modifiers & SCMOD_SHIFT)) ||
+ (! editor_prefs.unfold_all_children && (modifiers & SCMOD_SHIFT)))
{
gint last_line = SSM(sci, SCI_GETLASTCHILD, line, -1);
gint i;
@@ -312,20 +317,21 @@
}
-static void on_margin_click(ScintillaObject *sci, SCNotification *nt)
+static void on_margin_click(GeanyEditor *editor, SCNotification *nt)
{
/* left click to marker margin marks the line */
if (nt->margin == 1)
{
- gint line = sci_get_line_from_position(sci, nt->position);
+ gint line = sci_get_line_from_position(editor->sci, nt->position);
/*sci_marker_delete_all(editor->sci, 1);*/
- sci_toggle_marker_at_line(sci, line, 1); /* toggle the marker */
+ sci_toggle_marker_at_line(editor->sci, line, 1); /* toggle the marker */
}
/* left click on the folding margin to toggle folding state of current line */
else if (nt->margin == 2 && editor_prefs.folding)
{
- fold_symbol_click(sci, nt);
+ gint line = sci_get_line_from_position(editor->sci, nt->position);
+ editor_toggle_fold(editor, line, nt->modifiers);
}
}
@@ -849,7 +855,7 @@
break;
case SCN_MARGINCLICK:
- on_margin_click(sci, nt);
+ on_margin_click(editor, nt);
break;
case SCN_UPDATEUI:
Modified: trunk/src/editor.h
===================================================================
--- trunk/src/editor.h 2010-01-24 16:18:11 UTC (rev 4541)
+++ trunk/src/editor.h 2010-01-24 16:30:29 UTC (rev 4542)
@@ -281,4 +281,6 @@
gint insert_pos, gint cursor_index,
gint newline_indent_size, gboolean replace_newlines);
+void editor_toggle_fold(GeanyEditor *editor, gint line, gint modifiers);
+
#endif
Modified: trunk/src/keybindings.c
===================================================================
--- trunk/src/keybindings.c 2010-01-24 16:18:11 UTC (rev 4541)
+++ trunk/src/keybindings.c 2010-01-24 16:30:29 UTC (rev 4542)
@@ -2479,7 +2479,7 @@
if (editor_prefs.folding)
{
gint line = sci_get_current_line(doc->editor->sci);
- sci_toggle_fold(doc->editor->sci, line);
+ editor_toggle_fold(doc->editor, line, 0);
break;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.