SF.net SVN: geany:[3976] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Thu Jul 16 15:04:22 UTC 2009
Revision: 3976
http://geany.svn.sourceforge.net/geany/?rev=3976&view=rev
Author: ntrel
Date: 2009-07-16 15:04:21 +0000 (Thu, 16 Jul 2009)
Log Message:
-----------
Add 'Show Paths' documents list popup item.
Add "load_settings" core-only signal emitted just after loading
main keyfile settings; useful to delay building UI elements until
settings have been read.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/geanyobject.c
trunk/src/geanyobject.h
trunk/src/keyfile.c
trunk/src/main.c
trunk/src/treeviews.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2009-07-16 14:41:59 UTC (rev 3975)
+++ trunk/ChangeLog 2009-07-16 15:04:21 UTC (rev 3976)
@@ -5,6 +5,12 @@
current word.
* src/search.c:
Fix wrong match length when using Mark with regex.
+ * src/geanyobject.c, src/geanyobject.h, src/treeviews.c,
+ src/keyfile.c, src/main.c:
+ Add 'Show Paths' documents list popup item.
+ Add "load_settings" core-only signal emitted just after loading
+ main keyfile settings; useful to delay building UI elements until
+ settings have been read.
2009-07-15 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/src/geanyobject.c
===================================================================
--- trunk/src/geanyobject.c 2009-07-16 14:41:59 UTC (rev 3975)
+++ trunk/src/geanyobject.c 2009-07-16 15:04:21 UTC (rev 3976)
@@ -27,8 +27,12 @@
* Mainly used for plugins - see the API docs.
*
* Core-only signals:
+ *
* signal void save_settings(GObject *obj, GKeyFile *keyfile, gpointer user_data);
* Emitted just before saving main keyfile settings.
+
+ * signal void load_settings(GObject *obj, GKeyFile *keyfile, gpointer user_data);
+ * Emitted just after loading main keyfile settings.
*/
#include "geany.h"
@@ -244,6 +248,15 @@
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
+ geany_object_signals[GCB_LOAD_SETTINGS] = g_signal_new (
+ "load-settings",
+ G_OBJECT_CLASS_TYPE (g_object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GeanyObjectClass, load_settings),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1,
+ G_TYPE_POINTER);
}
Modified: trunk/src/geanyobject.h
===================================================================
--- trunk/src/geanyobject.h 2009-07-16 14:41:59 UTC (rev 3975)
+++ trunk/src/geanyobject.h 2009-07-16 15:04:21 UTC (rev 3976)
@@ -43,6 +43,7 @@
GCB_UPDATE_EDITOR_MENU,
GCB_EDITOR_NOTIFY,
GCB_SAVE_SETTINGS,
+ GCB_LOAD_SETTINGS,
GCB_MAX
}
GeanyCallbackId;
@@ -84,6 +85,7 @@
void (*update_editor_menu)(const gchar *word, gint click_pos, GeanyDocument *doc);
gboolean (*editor_notify)(GeanyEditor *editor, gpointer scnt);
void (*save_settings)(GKeyFile *keyfile);
+ void (*load_settings)(GKeyFile *keyfile);
};
GType geany_object_get_type (void);
Modified: trunk/src/keyfile.c
===================================================================
--- trunk/src/keyfile.c 2009-07-16 14:41:59 UTC (rev 3975)
+++ trunk/src/keyfile.c 2009-07-16 15:04:21 UTC (rev 3976)
@@ -917,6 +917,9 @@
project_load_prefs(config);
configuration_load_session_files(config, TRUE);
+ /* this signal can be used e.g. to delay building UI elements until settings have been read */
+ g_signal_emit_by_name(geany_object, "load-settings", config);
+
g_key_file_free(config);
g_free(configfile);
return TRUE;
Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c 2009-07-16 14:41:59 UTC (rev 3975)
+++ trunk/src/main.c 2009-07-16 15:04:21 UTC (rev 3976)
@@ -957,7 +957,8 @@
#ifdef HAVE_PLUGINS
plugins_init();
#endif
- load_settings();
+ treeviews_init();
+ load_settings(); /* load keyfile */
msgwin_init();
build_init();
@@ -970,7 +971,6 @@
templates_init();
navqueue_init();
document_init_doclist();
- treeviews_init();
symbols_init();
filetypes_read_extensions();
editor_snippets_init();
Modified: trunk/src/treeviews.c
===================================================================
--- trunk/src/treeviews.c 2009-07-16 14:41:59 UTC (rev 3975)
+++ trunk/src/treeviews.c 2009-07-16 15:04:21 UTC (rev 3976)
@@ -40,18 +40,21 @@
#include "symbols.h"
#include "navqueue.h"
#include "project.h"
+#include "stash.h"
+#include "keyfile.h"
#include <gdk/gdkkeysyms.h>
-SidebarTreeviews tv;
+SidebarTreeviews tv = {NULL, NULL, NULL, NULL};
static struct
{
GtkWidget *close;
GtkWidget *save;
GtkWidget *reload;
+ GtkWidget *show_paths;
}
-doc_items = {NULL, NULL, NULL};
+doc_items = {NULL, NULL, NULL, NULL};
enum
{
@@ -77,6 +80,7 @@
};
static GtkTreeStore *store_openfiles;
+static gboolean documents_show_paths;
static GtkWidget *tag_window; /* scrolled window that holds the symbol list GtkTreeView */
/* callback prototypes */
@@ -303,6 +307,9 @@
static GtkTreeIter parent;
GtkTreeModel *model = GTK_TREE_MODEL(store_openfiles);
+ if (!documents_show_paths)
+ return NULL;
+
tmp_dirname = g_path_get_dirname(DOC_FILENAME(doc));
/* replace the project base path with the project name */
project_base_path = project_get_base_path();
@@ -362,7 +369,7 @@
gtk_tree_store_append(store_openfiles, iter, parent);
/* check if new parent */
- if (gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store_openfiles), parent) == 1)
+ if (parent && gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store_openfiles), parent) == 1)
{
GtkTreePath *path;
@@ -515,6 +522,13 @@
}
+static void on_openfiles_show_paths_activate(GtkCheckMenuItem *item, gpointer user_data)
+{
+ documents_show_paths = gtk_check_menu_item_get_active(item);
+ treeviews_openfiles_update_all();
+}
+
+
static void on_list_document_activate(GtkCheckMenuItem *item, gpointer user_data)
{
interface_prefs.sidebar_openfiles_visible = gtk_check_menu_item_get_active(item);
@@ -562,6 +576,16 @@
G_CALLBACK(on_openfiles_document_action), GINT_TO_POINTER(OPENFILES_ACTION_RELOAD));
doc_items.reload = item;
+ item = gtk_separator_menu_item_new();
+ gtk_widget_show(item);
+ gtk_container_add(GTK_CONTAINER(tv.popup_openfiles), item);
+
+ doc_items.show_paths = gtk_check_menu_item_new_with_mnemonic(_("Show _Paths"));
+ gtk_widget_show(doc_items.show_paths);
+ gtk_container_add(GTK_CONTAINER(tv.popup_openfiles), doc_items.show_paths);
+ g_signal_connect(doc_items.show_paths, "activate",
+ G_CALLBACK(on_openfiles_show_paths_activate), NULL);
+
sidebar_add_common_menu_items(GTK_MENU(tv.popup_openfiles));
}
@@ -571,11 +595,12 @@
GtkTreeIter parent;
GtkTreePath *path;
- gtk_tree_model_iter_parent(GTK_TREE_MODEL(store_openfiles), &parent, iter);
-
- path = gtk_tree_model_get_path(GTK_TREE_MODEL(store_openfiles), &parent);
- gtk_tree_view_expand_row(GTK_TREE_VIEW(tv.tree_openfiles), path, TRUE);
- gtk_tree_path_free(path);
+ if (gtk_tree_model_iter_parent(GTK_TREE_MODEL(store_openfiles), &parent, iter))
+ {
+ path = gtk_tree_model_get_path(GTK_TREE_MODEL(store_openfiles), &parent);
+ gtk_tree_view_expand_row(GTK_TREE_VIEW(tv.tree_openfiles), path, TRUE);
+ gtk_tree_path_free(path);
+ }
}
@@ -827,6 +852,9 @@
gtk_widget_set_sensitive(doc_items.save, (doc && doc->real_path) || path);
gtk_widget_set_sensitive(doc_items.reload, doc && doc->real_path);
g_free(shortname);
+
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(doc_items.show_paths),
+ documents_show_paths);
}
@@ -839,6 +867,9 @@
if (event->button == 3)
{
+ if (!tv.popup_openfiles)
+ create_openfiles_popup_menu();
+
documents_menu_update(selection);
gtk_menu_popup(GTK_MENU(tv.popup_openfiles), NULL, NULL, NULL, NULL,
event->button, event->time);
@@ -847,13 +878,24 @@
}
-void treeviews_init()
+static void on_load_settings(void)
{
- tv.default_tag_tree = NULL;
tag_window = ui_lookup_widget(main_widgets.window, "scrolledwindow2");
prepare_openfiles();
- create_openfiles_popup_menu();
}
+void treeviews_init(void)
+{
+ GeanyPrefGroup *group;
+
+ group = stash_group_new(PACKAGE);
+ stash_group_add_boolean(group, &documents_show_paths, "documents_show_paths", TRUE);
+ configuration_add_pref_group(group, FALSE);
+
+ /* delay building documents treeview until sidebar font has been read */
+ g_signal_connect(geany_object, "load-settings", on_load_settings, NULL);
+}
+
+
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