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. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@3438 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
4428e31d93
commit
9962e8abb8
12
ChangeLog
12
ChangeLog
@ -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>
|
2009-01-02 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
|
||||||
|
|
||||||
* src/keybindings.c, src/keybindings.h, src/main.c:
|
* src/keybindings.c, src/keybindings.h, src/main.c:
|
||||||
|
@ -1770,7 +1770,6 @@
|
|||||||
<property name="tab_pos">GTK_POS_TOP</property>
|
<property name="tab_pos">GTK_POS_TOP</property>
|
||||||
<property name="scrollable">True</property>
|
<property name="scrollable">True</property>
|
||||||
<property name="enable_popup">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"/>
|
<signal name="switch_page" handler="on_notebook1_switch_page_after" after="yes" last_modification_time="Fri, 26 May 2006 11:47:25 GMT"/>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
|
@ -89,8 +89,6 @@ static gboolean insert_callback_from_menu = FALSE;
|
|||||||
* the selection-changed signal from tv.tree_openfiles */
|
* the selection-changed signal from tv.tree_openfiles */
|
||||||
/*static gboolean switch_tv_notebook_page = FALSE; */
|
/*static gboolean switch_tv_notebook_page = FALSE; */
|
||||||
|
|
||||||
CallbacksData callbacks_data = { NULL };
|
|
||||||
|
|
||||||
|
|
||||||
static gboolean check_no_unsaved(void)
|
static gboolean check_no_unsaved(void)
|
||||||
{
|
{
|
||||||
@ -703,17 +701,8 @@ on_toolbutton_preferences_clicked (GtkAction *action,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
/* Changes window-title after switching tabs and lots of other things.
|
||||||
on_notebook1_switch_page (GtkNotebook *notebook,
|
* note: using 'after' makes Scintilla redraw before the UI, appearing more responsive */
|
||||||
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
|
void
|
||||||
on_notebook1_switch_page_after (GtkNotebook *notebook,
|
on_notebook1_switch_page_after (GtkNotebook *notebook,
|
||||||
GtkNotebookPage *page,
|
GtkNotebookPage *page,
|
||||||
|
@ -25,14 +25,6 @@
|
|||||||
#include "geany.h" /* necessary for interface.c */
|
#include "geany.h" /* necessary for interface.c */
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
GeanyDocument *last_doc;
|
|
||||||
} CallbacksData;
|
|
||||||
|
|
||||||
extern CallbacksData callbacks_data;
|
|
||||||
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
on_exit_clicked (GtkWidget *widget, gpointer gdata);
|
on_exit_clicked (GtkWidget *widget, gpointer gdata);
|
||||||
|
|
||||||
@ -72,12 +64,6 @@ void
|
|||||||
on_toolbutton_close_all_clicked (GtkAction *action,
|
on_toolbutton_close_all_clicked (GtkAction *action,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
void
|
|
||||||
on_notebook1_switch_page (GtkNotebook *notebook,
|
|
||||||
GtkNotebookPage *page,
|
|
||||||
guint page_num,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
on_save_all1_activate (GtkMenuItem *menuitem,
|
on_save_all1_activate (GtkMenuItem *menuitem,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
@ -79,6 +79,8 @@ GeanyApp;
|
|||||||
|
|
||||||
extern GeanyApp *app;
|
extern GeanyApp *app;
|
||||||
|
|
||||||
|
extern GObject *geany_object;
|
||||||
|
|
||||||
|
|
||||||
extern gboolean ignore_callback;
|
extern gboolean ignore_callback;
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "geany.h"
|
#include "geany.h"
|
||||||
#include "geanyobject.h"
|
#include "geanyobject.h"
|
||||||
|
|
||||||
|
/* extern in geany.h */
|
||||||
GObject *geany_object;
|
GObject *geany_object;
|
||||||
|
|
||||||
static guint geany_object_signals[GCB_MAX] = { 0 };
|
static guint geany_object_signals[GCB_MAX] = { 0 };
|
||||||
|
@ -30,8 +30,6 @@
|
|||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
extern GObject *geany_object;
|
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
GCB_DOCUMENT_NEW,
|
GCB_DOCUMENT_NEW,
|
||||||
|
@ -1473,9 +1473,6 @@ create_window1 (void)
|
|||||||
g_signal_connect ((gpointer) notebook3, "key_press_event",
|
g_signal_connect ((gpointer) notebook3, "key_press_event",
|
||||||
G_CALLBACK (on_escape_key_press_event),
|
G_CALLBACK (on_escape_key_press_event),
|
||||||
NULL);
|
NULL);
|
||||||
g_signal_connect ((gpointer) notebook1, "switch_page",
|
|
||||||
G_CALLBACK (on_notebook1_switch_page),
|
|
||||||
NULL);
|
|
||||||
g_signal_connect_after ((gpointer) notebook1, "switch_page",
|
g_signal_connect_after ((gpointer) notebook1, "switch_page",
|
||||||
G_CALLBACK (on_notebook1_switch_page_after),
|
G_CALLBACK (on_notebook1_switch_page_after),
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -58,6 +58,9 @@ static gboolean ignore_keybinding = FALSE;
|
|||||||
static GtkAccelGroup *kb_accel_group = NULL;
|
static GtkAccelGroup *kb_accel_group = NULL;
|
||||||
static const gboolean swap_alt_tab_order = FALSE;
|
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 gboolean switch_dialog_cancelled = TRUE;
|
||||||
static GtkWidget *switch_dialog = NULL;
|
static GtkWidget *switch_dialog = NULL;
|
||||||
static GtkWidget *switch_dialog_label = NULL;
|
static GtkWidget *switch_dialog_label = NULL;
|
||||||
@ -483,8 +486,51 @@ static void init_default_kb(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* 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)
|
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);
|
keybinding_groups = g_ptr_array_sized_new(GEANY_KEY_GROUP_COUNT);
|
||||||
|
|
||||||
kb_accel_group = gtk_accel_group_new();
|
kb_accel_group = gtk_accel_group_new();
|
||||||
@ -671,6 +717,7 @@ void keybindings_write_to_file(void)
|
|||||||
void keybindings_free(void)
|
void keybindings_free(void)
|
||||||
{
|
{
|
||||||
g_ptr_array_free(keybinding_groups, TRUE);
|
g_ptr_array_free(keybinding_groups, TRUE);
|
||||||
|
g_queue_free(mru_docs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1428,7 +1475,7 @@ static gboolean on_switch_timeout(G_GNUC_UNUSED gpointer data)
|
|||||||
static void cb_func_switch_tablastused(G_GNUC_UNUSED guint key_id)
|
static void cb_func_switch_tablastused(G_GNUC_UNUSED guint key_id)
|
||||||
{
|
{
|
||||||
/* TODO: MRU switching order */
|
/* 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))
|
if (!DOC_VALID(last_doc))
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user