Branch: refs/heads/document-messages
Author: Jiří Techet <techet(a)gmail.com>
Committer: Jiří Techet <techet(a)gmail.com>
Date: Sat, 24 Dec 2011 11:29:51
Commit: 0acb273c55869850113f81953772786cd1a8452a
https://github.com/geany/geany/commit/0acb273c55869850113f81953772786cd1a84…
Log Message:
-----------
Rewrite tab switching queue
There was one more bug related to the tab switching. When we switch
so many times that we return back to the original document (so we
actually don't switch at all) then the following switch attempt
doesn't switch immediately to the next document.
After spending two hours thinking what is wrong, I gave up and rewrote
the whole thing in a different way. The problem with the previous
implementation was that before you couldn't just look what's in the queue
"now" - you had to imagine what will be inserted there in the next step
because the switch_in_progress variable was set after the first switch
(this is also why I put the long comment why mru_pos = 2 - that is not
clear at all when you first look at it). Also there were some not very
nice "workarounds" like the idle function that was executed after the
switch and removed the double entry on top of the queue.
So with the new implementation things are much simpler IMO. The queue
starts with the current document and the previously opened documments
follow. It's *always* like that, no exceptions. The idle function
is gone and cb_func_switch_tablastused() is simplified too. The rest of
the functionality should be clear from the code.
Signed-off-by: Jiří Techet <techet(a)gmail.com>
Modified Paths:
--------------
src/keybindings.c
Modified: src/keybindings.c
65 files changed, 29 insertions(+), 36 deletions(-)
===================================================================
@@ -597,17 +597,12 @@ static void init_default_kb(void)
}
-/* before the tab changes, add the current document to the MRU list */
-static void on_notebook_switch_page(void)
+static void update_mru_docs_head(GeanyDocument *doc)
{
- GeanyDocument *old = document_get_current();
-
- /* when closing current doc, old is NULL.
- * Don't add to the mru list when switch dialog is visible. */
- if (old && !switch_in_progress)
+ if (doc)
{
- g_queue_remove(mru_docs, old);
- g_queue_push_head(mru_docs, old);
+ g_queue_remove(mru_docs, doc);
+ g_queue_push_head(mru_docs, doc);
if (g_queue_get_length(mru_docs) > MAX_MRU_DOCS)
g_queue_pop_tail(mru_docs);
@@ -615,16 +610,21 @@ static void on_notebook_switch_page(void)
}
-/* really this should be just after a document was closed, not idle */
-static gboolean on_idle_close(gpointer data)
+/* before the tab changes, add the current document to the MRU list */
+static void on_notebook_switch_page(GtkNotebook *notebook,
+ GtkNotebookPage *page, guint page_num, gpointer user_data)
{
- GeanyDocument *current;
+ GeanyDocument *new;
- current = document_get_current();
- if (current && g_queue_peek_head(mru_docs) == current)
- g_queue_pop_head(mru_docs);
+ new = document_get_from_page(page_num);
- return FALSE;
+ /* insert the very first document (when adding the second document
+ * and switching to it) */
+ if (g_queue_get_length(mru_docs) == 0 && gtk_notebook_get_n_pages(notebook) == 2)
+ update_mru_docs_head(document_get_current());
+
+ if (!switch_in_progress)
+ update_mru_docs_head(new);
}
@@ -634,7 +634,7 @@ static void on_document_close(GObject *obj, GeanyDocument *doc)
{
GeanyDocument *last_doc;
- last_doc = g_queue_peek_head(mru_docs);
+ last_doc = g_queue_peek_nth(mru_docs, 1);
if (DOC_VALID(last_doc) && document_get_current() == doc)
{
@@ -642,8 +642,10 @@ static void on_document_close(GObject *obj, GeanyDocument *doc)
document_get_notebook_page(last_doc));
}
g_queue_remove(mru_docs, doc);
-
- g_idle_add(on_idle_close, NULL);
+ /* this prevents the pop up window from showing when there's a single
+ * document */
+ if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook)) == 2)
+ g_queue_clear(mru_docs);
}
}
@@ -1768,6 +1770,7 @@ static gboolean on_key_release_event(GtkWidget *widget, GdkEventKey *ev, gpointe
switch_dialog = NULL;
}
+ update_mru_docs_head(document_get_current());
mru_pos = 0;
}
return FALSE;
@@ -1845,7 +1848,11 @@ static gboolean on_switch_timeout(G_GNUC_UNUSED gpointer data)
static void cb_func_switch_tablastused(G_GNUC_UNUSED guint key_id)
{
- GeanyDocument *last_doc = g_queue_peek_nth(mru_docs, mru_pos);
+ GeanyDocument *last_doc;
+ gboolean switch_start = !switch_in_progress;
+
+ mru_pos += 1;
+ last_doc = g_queue_peek_nth(mru_docs, mru_pos);
if (! DOC_VALID(last_doc))
{
@@ -1856,29 +1863,15 @@ static void cb_func_switch_tablastused(G_GNUC_UNUSED guint key_id)
if (! DOC_VALID(last_doc))
return;
+ switch_in_progress = TRUE;
document_show_tab(last_doc);
/* if there's a modifier key, we can switch back in MRU order each time unless
* the key is released */
- if (!switch_in_progress)
- {
- switch_in_progress = TRUE;
-
- /* because switch_in_progress was not set when we called
- * gtk_notebook_set_current_page() above, this function inserted last_doc
- * into the queue => on mru_pos = 0 there is last_doc, on mru_pos = 1
- * there is the currently displayed doc, so we want to continue from 2
- * next time this function is called */
- mru_pos = 2;
-
- /* delay showing dialog to give user time to let go of any modifier keys */
+ if (switch_start)
g_timeout_add(600, on_switch_timeout, NULL);
- }
else
- {
update_filename_label();
- mru_pos += 1;
- }
}
@@ Diff output truncated at 100000 characters. @@
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: TBD).
Branch: refs/heads/document-messages
Author: Jiří Techet <techet(a)gmail.com>
Committer: Jiří Techet <techet(a)gmail.com>
Date: Sat, 24 Dec 2011 11:30:01
Commit: f6be8b47d76facd50266d1c59100cfec96c282d2
https://github.com/geany/geany/commit/f6be8b47d76facd50266d1c59100cfec96c28…
Log Message:
-----------
Make the tab switching dialog a bit more useful
Right now the tab switching dialog shows the full
path of the current file. However this dialog is too
narrow and in my case usually displays one directory
per line. This makes it hard to find the base
filename, which is the thing you are most probably
looking for.
This patch displays only the base name - in bold. In
addition, it displays the following three filenames
in the MRU list, each on a new line (not in bold).
This helps to see what file comes next and how many
times one has to press ctrl+tab.
Modified Paths:
--------------
src/keybindings.c
Modified: src/keybindings.c
33 files changed, 30 insertions(+), 3 deletions(-)
===================================================================
@@ -1803,7 +1803,7 @@ static GtkWidget *create_switch_dialog(void)
dialog = ui_minimal_dialog_new(GTK_WINDOW(main_widgets.window), _("Switch to Document"));
gtk_window_set_decorated(GTK_WINDOW(dialog), FALSE);
- gtk_window_set_default_size(GTK_WINDOW(dialog), 150, -1);
+ gtk_window_set_default_size(GTK_WINDOW(dialog), 200, -1);
vbox = gtk_vbox_new(FALSE, 6);
gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
@@ -1812,7 +1812,7 @@ static GtkWidget *create_switch_dialog(void)
widget = gtk_image_new_from_stock(GTK_STOCK_JUMP_TO, GTK_ICON_SIZE_BUTTON);
gtk_container_add(GTK_CONTAINER(vbox), widget);
- widget = geany_wrap_label_new(NULL);
+ widget = gtk_label_new(NULL);
gtk_label_set_justify(GTK_LABEL(widget), GTK_JUSTIFY_CENTER);
gtk_container_add(GTK_CONTAINER(vbox), widget);
switch_dialog_label = widget;
@@ -1824,13 +1824,40 @@ static GtkWidget *create_switch_dialog(void)
static void update_filename_label(void)
{
+ guint i;
+ gchar *msg;
+ guint queue_length;
+ GeanyDocument *doc;
+
if (!switch_dialog)
{
switch_dialog = create_switch_dialog();
gtk_widget_show_all(switch_dialog);
}
- gtk_label_set_text(GTK_LABEL(switch_dialog_label), DOC_FILENAME(document_get_current()));
+ queue_length = g_queue_get_length(mru_docs);
+ for (i = mru_pos; (i <= mru_pos + 3) && (doc = g_queue_peek_nth(mru_docs, i % queue_length)); i++)
+ {
+ gchar *basename;
+
+ basename = g_path_get_basename(DOC_FILENAME(doc));
+ if (i == mru_pos)
+ msg = g_markup_printf_escaped ("<b>%s</b>", basename);
+ else if (i % queue_length == mru_pos) /* && i != mru_pos */
+ {
+ /* We have wrapped around and got to the starting document again */
+ g_free(basename);
+ break;
+ }
+ else
+ {
+ setptr(basename, g_markup_printf_escaped ("\n%s", basename));
+ setptr(msg, g_strconcat(msg, basename, NULL));
+ }
+ g_free(basename);
+ }
+ gtk_label_set_markup(GTK_LABEL(switch_dialog_label), msg);
+ g_free(msg);
}
@@ Diff output truncated at 100000 characters. @@
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: TBD).
Branch: refs/heads/document-messages
Author: Jiří Techet <techet(a)gmail.com>
Committer: Jiří Techet <techet(a)gmail.com>
Date: Sat, 24 Dec 2011 11:29:43
Commit: d0892b95d1ed54a2ab0ce411adff210712573899
https://github.com/geany/geany/commit/d0892b95d1ed54a2ab0ce411adff210712573…
Log Message:
-----------
When closing tab, return to the document at the top of the MRU list
This is a pretty frequent work pattern of mine:
1. Editing file A
2. Searching for function and opening file B
3. Closing file B because I just wanted to look at the function definition
4. Without this patch I get to the file following the B's tab (which
is just a random file) but my brain expects that I get to A
I know it's possible to kind of simulate the behaviour I want with
the "next to current" placement option but I really don't see a single
advantage of having tabs closed in sequential order. This is also
why I didn't make this behaviour optional. But maybe I miss some
use case of tabs being closed sequentially - just tell me.
Signed-off-by: Jiří Techet <techet(a)gmail.com>
Modified Paths:
--------------
src/keybindings.c
src/notebook.c
Modified: src/keybindings.c
10 files changed, 10 insertions(+), 0 deletions(-)
===================================================================
@@ -632,7 +632,17 @@ static void on_document_close(GObject *obj, GeanyDocument *doc)
{
if (! main_status.quitting)
{
+ GeanyDocument *last_doc;
+
+ last_doc = g_queue_peek_head(mru_docs);
+
+ if (DOC_VALID(last_doc) && document_get_current() == doc)
+ {
+ gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook),
+ document_get_notebook_page(last_doc));
+ }
g_queue_remove(mru_docs, doc);
+
g_idle_add(on_idle_close, NULL);
}
}
Modified: src/notebook.c
9 files changed, 0 insertions(+), 9 deletions(-)
===================================================================
@@ -493,15 +493,6 @@ gint notebook_new_tab(GeanyDocument *this)
/* Always use this instead of gtk_notebook_remove_page(). */
void notebook_remove_page(gint page_num)
{
- gint curpage = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets.notebook));
-
- /* Focus the next page, not the previous */
- if (curpage == page_num && file_prefs.tab_order_ltr)
- {
- gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook), curpage + 1);
- }
-
- /* now remove the page (so we don't temporarily switch to the previous page) */
gtk_notebook_remove_page(GTK_NOTEBOOK(main_widgets.notebook), page_num);
tab_count_changed();
@@ Diff output truncated at 100000 characters. @@
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: TBD).
Branch: refs/heads/document-messages
Author: Nick Treleaven <nick.treleaven(a)btinternet.com>
Committer: Nick Treleaven <nick.treleaven(a)btinternet.com>
Date: Wed, 21 Dec 2011 17:06:32
Commit: 0c6aed700dd89a7abab7b1b5bfca340e1a2d6c7f
https://github.com/geany/geany/commit/0c6aed700dd89a7abab7b1b5bfca340e1a2d6…
Log Message:
-----------
Make 'Replace Spaces by Tabs' only match leading spaces
Replacing spaces used for alignment with tabs would often break the
alignment as tab stop positions were not checked. It's also not
possible to distinguish between a true space and a single aligning
space, so we should ignore all spaces outside of indentation.
Modified Paths:
--------------
doc/geany.html
doc/geany.txt
src/editor.c
Modified: doc/geany.html
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -4407,7 +4407,7 @@ <h2 class="subtitle" id="a-fast-light-gtk-ide">A fast, light, GTK+ IDE</h2>
</tr>
<tr><td>Replace spaces by tabs</td>
<td> </td>
-<td>Replaces all spaces with tab characters.</td>
+<td>Replaces leading spaces with tab characters.</td>
</tr>
<tr><td>Toggle current fold</td>
<td> </td>
Modified: doc/geany.txt
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -3604,7 +3604,7 @@ Action Default shortcut Description
==================================== ==================== ==================================================
Replace tabs by space Replaces all tabs with the right amount of spaces.
-Replace spaces by tabs Replaces all spaces with tab characters.
+Replace spaces by tabs Replaces leading spaces with tab characters.
Toggle current fold Toggles the folding state of the current code block.
Modified: src/editor.c
8 files changed, 7 insertions(+), 1 deletions(-)
===================================================================
@@ -4320,7 +4320,13 @@ void editor_replace_spaces(GeanyEditor *editor)
search_pos = sci_find_text(editor->sci, SCFIND_MATCHCASE, &ttf);
if (search_pos == -1)
break;
-
+ /* only replace indentation because otherwise we can mess up alignment */
+ if (search_pos > sci_get_line_indent_position(editor->sci,
+ sci_get_line_from_position(editor->sci, search_pos)))
+ {
+ ttf.chrg.cpMin = search_pos + tab_len;
+ continue;
+ }
sci_set_target_start(editor->sci, search_pos);
sci_set_target_end(editor->sci, search_pos + tab_len);
sci_replace_target(editor->sci, "\t", FALSE);
@@ Diff output truncated at 100000 characters. @@
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: TBD).
Branch: refs/heads/document-messages
Author: Matthew Brush <matt(a)geany.org>
Committer: Matthew Brush <matt(a)geany.org>
Date: Mon, 19 Dec 2011 02:47:56
Commit: aaa62c39b436b7e973683c6a5551d6f5091a0ac6
https://github.com/geany/geany/commit/aaa62c39b436b7e973683c6a5551d6f5091a0…
Log Message:
-----------
Make editor menu initially hidden
Without this the menu won't emit the show signal the first time it's shown.
Modified Paths:
--------------
data/geany.glade
Modified: data/geany.glade
1 files changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -83,7 +83,6 @@
<property name="page_increment">10</property>
</object>
<object class="GtkMenu" id="edit_menu1">
- <property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem" id="undo1">
@@ Diff output truncated at 100000 characters. @@
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: TBD).