SF.net SVN: geany:[3438] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Sat Jan 3 12:54:13 UTC 2009
Revision: 3438
http://geany.svn.sourceforge.net/geany/?rev=3438&view=rev
Author: ntrel
Date: 2009-01-03 12:54:13 +0000 (Sat, 03 Jan 2009)
Log Message:
-----------
Fix not switching to 2nd last used document when the last used
document has been closed (#1945162).
- Code changes:
Move geany_object extern to geany.h.
Remove CallbacksData struct.
Modified Paths:
--------------
trunk/ChangeLog
trunk/geany.glade
trunk/src/callbacks.c
trunk/src/callbacks.h
trunk/src/geany.h
trunk/src/geanyobject.c
trunk/src/geanyobject.h
trunk/src/interface.c
trunk/src/keybindings.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2009-01-02 14:01:24 UTC (rev 3437)
+++ trunk/ChangeLog 2009-01-03 12:54:13 UTC (rev 3438)
@@ -1,3 +1,15 @@
+2009-01-03 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
+
+ * src/interface.c, src/keybindings.c, src/geanyobject.c,
+ src/geanyobject.h, src/geany.h, src/callbacks.c, src/callbacks.h,
+ geany.glade:
+ Fix not switching to 2nd last used document when the last used
+ document has been closed (#1945162).
+ - Code changes:
+ Move geany_object extern to geany.h.
+ Remove CallbacksData struct.
+
+
2009-01-02 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/keybindings.c, src/keybindings.h, src/main.c:
Modified: trunk/geany.glade
===================================================================
--- trunk/geany.glade 2009-01-02 14:01:24 UTC (rev 3437)
+++ trunk/geany.glade 2009-01-03 12:54:13 UTC (rev 3438)
@@ -1770,7 +1770,6 @@
<property name="tab_pos">GTK_POS_TOP</property>
<property name="scrollable">True</property>
<property name="enable_popup">True</property>
- <signal name="switch_page" handler="on_notebook1_switch_page" last_modification_time="Sat, 23 Apr 2005 15:17:51 GMT"/>
<signal name="switch_page" handler="on_notebook1_switch_page_after" after="yes" last_modification_time="Fri, 26 May 2006 11:47:25 GMT"/>
</widget>
<packing>
Modified: trunk/src/callbacks.c
===================================================================
--- trunk/src/callbacks.c 2009-01-02 14:01:24 UTC (rev 3437)
+++ trunk/src/callbacks.c 2009-01-03 12:54:13 UTC (rev 3438)
@@ -89,9 +89,7 @@
* the selection-changed signal from tv.tree_openfiles */
/*static gboolean switch_tv_notebook_page = FALSE; */
-CallbacksData callbacks_data = { NULL };
-
static gboolean check_no_unsaved(void)
{
guint i;
@@ -703,18 +701,9 @@
}
+/* Changes window-title after switching tabs and lots of other things.
+ * note: using 'after' makes Scintilla redraw before the UI, appearing more responsive */
void
-on_notebook1_switch_page (GtkNotebook *notebook,
- GtkNotebookPage *page,
- guint page_num,
- gpointer user_data)
-{
- callbacks_data.last_doc = document_get_current();
-}
-
-
-/* changes window-title on switching tabs and lots of other things */
-void
on_notebook1_switch_page_after (GtkNotebook *notebook,
GtkNotebookPage *page,
guint page_num,
Modified: trunk/src/callbacks.h
===================================================================
--- trunk/src/callbacks.h 2009-01-02 14:01:24 UTC (rev 3437)
+++ trunk/src/callbacks.h 2009-01-03 12:54:13 UTC (rev 3438)
@@ -25,14 +25,6 @@
#include "geany.h" /* necessary for interface.c */
-typedef struct
-{
- GeanyDocument *last_doc;
-} CallbacksData;
-
-extern CallbacksData callbacks_data;
-
-
gboolean
on_exit_clicked (GtkWidget *widget, gpointer gdata);
@@ -73,12 +65,6 @@
gpointer user_data);
void
-on_notebook1_switch_page (GtkNotebook *notebook,
- GtkNotebookPage *page,
- guint page_num,
- gpointer user_data);
-
-void
on_save_all1_activate (GtkMenuItem *menuitem,
gpointer user_data);
Modified: trunk/src/geany.h
===================================================================
--- trunk/src/geany.h 2009-01-02 14:01:24 UTC (rev 3437)
+++ trunk/src/geany.h 2009-01-03 12:54:13 UTC (rev 3438)
@@ -79,7 +79,9 @@
extern GeanyApp *app;
+extern GObject *geany_object;
+
extern gboolean ignore_callback;
Modified: trunk/src/geanyobject.c
===================================================================
--- trunk/src/geanyobject.c 2009-01-02 14:01:24 UTC (rev 3437)
+++ trunk/src/geanyobject.c 2009-01-03 12:54:13 UTC (rev 3438)
@@ -34,6 +34,7 @@
#include "geany.h"
#include "geanyobject.h"
+/* extern in geany.h */
GObject *geany_object;
static guint geany_object_signals[GCB_MAX] = { 0 };
Modified: trunk/src/geanyobject.h
===================================================================
--- trunk/src/geanyobject.h 2009-01-02 14:01:24 UTC (rev 3437)
+++ trunk/src/geanyobject.h 2009-01-03 12:54:13 UTC (rev 3438)
@@ -30,8 +30,6 @@
G_BEGIN_DECLS
-extern GObject *geany_object;
-
typedef enum
{
GCB_DOCUMENT_NEW,
Modified: trunk/src/interface.c
===================================================================
--- trunk/src/interface.c 2009-01-02 14:01:24 UTC (rev 3437)
+++ trunk/src/interface.c 2009-01-03 12:54:13 UTC (rev 3438)
@@ -1473,9 +1473,6 @@
g_signal_connect ((gpointer) notebook3, "key_press_event",
G_CALLBACK (on_escape_key_press_event),
NULL);
- g_signal_connect ((gpointer) notebook1, "switch_page",
- G_CALLBACK (on_notebook1_switch_page),
- NULL);
g_signal_connect_after ((gpointer) notebook1, "switch_page",
G_CALLBACK (on_notebook1_switch_page_after),
NULL);
Modified: trunk/src/keybindings.c
===================================================================
--- trunk/src/keybindings.c 2009-01-02 14:01:24 UTC (rev 3437)
+++ trunk/src/keybindings.c 2009-01-03 12:54:13 UTC (rev 3438)
@@ -58,6 +58,9 @@
static GtkAccelGroup *kb_accel_group = NULL;
static const gboolean swap_alt_tab_order = FALSE;
+const gsize MAX_MRU_DOCS = 20;
+static GQueue *mru_docs = NULL;
+
static gboolean switch_dialog_cancelled = TRUE;
static GtkWidget *switch_dialog = NULL;
static GtkWidget *switch_dialog_label = NULL;
@@ -483,8 +486,51 @@
}
+/* before the tab changes, add the current document to the MRU list */
+static void on_notebook_switch_page()
+{
+ GeanyDocument *old = document_get_current();
+
+ /* when closing current doc, old is NULL */
+ if (old)
+ {
+ g_queue_push_head(mru_docs, old);
+
+ if (g_queue_get_length(mru_docs) > MAX_MRU_DOCS)
+ g_queue_pop_tail(mru_docs);
+ }
+}
+
+
+/* really this should be just after a document was closed, not idle */
+static gboolean on_idle_close(gpointer data)
+{
+ GeanyDocument *current;
+
+ current = document_get_current();
+
+ while (current && g_queue_peek_head(mru_docs) == current)
+ g_queue_pop_head(mru_docs);
+
+ return FALSE;
+}
+
+
+static void on_document_close(GObject *obj, GeanyDocument *doc)
+{
+ g_queue_remove_all(mru_docs, doc);
+ g_idle_add(on_idle_close, NULL);
+}
+
+
void keybindings_init(void)
{
+ mru_docs = g_queue_new();
+ g_signal_connect(main_widgets.notebook, "switch-page",
+ G_CALLBACK(on_notebook_switch_page), NULL);
+ g_signal_connect(geany_object, "document-close",
+ G_CALLBACK(on_document_close), NULL);
+
keybinding_groups = g_ptr_array_sized_new(GEANY_KEY_GROUP_COUNT);
kb_accel_group = gtk_accel_group_new();
@@ -671,6 +717,7 @@
void keybindings_free(void)
{
g_ptr_array_free(keybinding_groups, TRUE);
+ g_queue_free(mru_docs);
}
@@ -1428,7 +1475,7 @@
static void cb_func_switch_tablastused(G_GNUC_UNUSED guint key_id)
{
/* TODO: MRU switching order */
- GeanyDocument *last_doc = callbacks_data.last_doc;
+ GeanyDocument *last_doc = g_queue_peek_head(mru_docs);
if (!DOC_VALID(last_doc))
return;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list