On Thu, Sep 16, 2010 at 17:52, Nick Treleaven
<[email protected]> wrote:
> On Wed, 15 Sep 2010 21:34:52 +0200
> Jiří Techet <[email protected]> wrote:
>
>> > Thanks, I'd like to commit this now. I realize it's been a while, but
>> > the patch doesn't apply cleanly and I can't see any commits since that
>> > would have caused conflicts. Any chance you could update and resubmit
>> > please?
>>
>> Hi Nick,
>>
>> no problem, I have just rebased all my patches on top of mainline.
>> This particular patch is attached.
>
> Thanks, but still no joy. The problem is these 2 hunks:
>
>> @@ -599,7 +599,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)
>> {
>> @@ -607,8 +607,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);
>> }
>> }
>
> I haven't been able to work out where they apply to. It didn't seem
> that a conflict had been introduced since your first patch for this
> code, but maybe I'm missing something.
I see, the patch depends on the "When closing tab, return to the
document at the top of the MRU list" commit. This is actually a commit
I'd really like to see in geany so even though I could make the patch
independent of this commit, I would like both to be applied in which
case their separation doesn't make sense.
Please see the attached files. First apply tab_closing.patch and then
tab_switching.patch. Everything should apply cleanly now.
Jiri
>
>> You can find the remaining pending
>> patches under for_review3 branch here:
>>
>> http://gitorious.org/~techy/geany/gproject-geany
>>
>> If you wish me to resubmit them by email, just tell me - I would
>
> Thanks - no need to resend. I can download the patches.
>
>> really like to see the patches extending geany's API to be a part of
>> mainline so my gproject plugin would not depend on patched geany and
>> could be moved among other plugins repository.
>
> I've applied some this afternoon, will get through them soon hopefully.
>
> Regards,
> Nick
> _______________________________________________
> Geany-devel mailing list
> [email protected]
> http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
>
diff --git a/src/keybindings.c b/src/keybindings.c
index 4cf2992..0d227c5 100644
--- a/src/keybindings.c
+++ b/src/keybindings.c
@@ -597,7 +597,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);
}
}
diff --git a/src/notebook.c b/src/notebook.c
index a1d10bd..0a4af68 100644
--- a/src/notebook.c
+++ b/src/notebook.c
@@ -551,15 +551,6 @@ notebook_tab_close_clicked_cb(GtkButton *button, gpointer user_data)
/* 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 --git a/src/keybindings.c b/src/keybindings.c
index 0d227c5..3d54cd0 100644
--- a/src/keybindings.c
+++ b/src/keybindings.c
@@ -562,17 +562,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);
@@ -580,16 +575,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);
}
@@ -599,7 +599,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)
{
@@ -607,8 +607,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);
}
}
@@ -1728,6 +1730,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;
@@ -1806,7 +1809,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))
{
@@ -1817,30 +1824,16 @@ static void cb_func_switch_tablastused(G_GNUC_UNUSED guint key_id)
if (! DOC_VALID(last_doc))
return;
+ switch_in_progress = TRUE;
gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook),
document_get_notebook_page(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;
- }
}
_______________________________________________
Geany-devel mailing list
[email protected]
http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel