Revision: 1993 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1993&view=re... Author: codebrainz Date: 2011-03-17 03:52:29 +0000 (Thu, 17 Mar 2011)
Log Message: ----------- Make Devhelp plugin cooperate with Split Window plugin.
Modified Paths: -------------- trunk/geany-plugins/devhelp/src/devhelpplugin.h trunk/geany-plugins/devhelp/src/main-notebook.c
Modified: trunk/geany-plugins/devhelp/src/devhelpplugin.h =================================================================== --- trunk/geany-plugins/devhelp/src/devhelpplugin.h 2011-03-17 00:23:50 UTC (rev 1992) +++ trunk/geany-plugins/devhelp/src/devhelpplugin.h 2011-03-17 03:52:29 UTC (rev 1993) @@ -25,22 +25,21 @@ #include <gtk/gtk.h>
G_BEGIN_DECLS + #ifndef DHPLUG_DATA_DIR #define DHPLUG_DATA_DIR "/usr/local/share/geany-devhelp" #endif + #define DHPLUG_WEBVIEW_HOME_FILE DHPLUG_DATA_DIR"/home.html" -#define DHPLUG_MAX_LABEL_TAG 30 +#define DHPLUG_MAX_LABEL_TAG 30 /* never search for more than this many chars */ + #define DEVHELP_TYPE_PLUGIN (devhelp_plugin_get_type()) -#define DEVHELP_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\ - DEVHELP_TYPE_PLUGIN, DevhelpPlugin)) -#define DEVHELP_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),\ - DEVHELP_TYPE_PLUGIN, DevhelpPluginClass)) -#define DEVHELP_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),\ - DEVHELP_TYPE_PLUGIN)) -#define DEVHELP_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),\ - DEVHELP_TYPE_PLUGIN)) -#define DEVHELP_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),\ - DEVHELP_TYPE_PLUGIN, DevhelpPluginClass)) +#define DEVHELP_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), DEVHELP_TYPE_PLUGIN, DevhelpPlugin)) +#define DEVHELP_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), DEVHELP_TYPE_PLUGIN, DevhelpPluginClass)) +#define DEVHELP_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), DEVHELP_TYPE_PLUGIN)) +#define DEVHELP_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), DEVHELP_TYPE_PLUGIN)) +#define DEVHELP_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), DEVHELP_TYPE_PLUGIN, DevhelpPluginClass)) + typedef struct _DevhelpPlugin DevhelpPlugin; typedef struct _DevhelpPluginClass DevhelpPluginClass; typedef struct _DevhelpPluginPrivate DevhelpPluginPrivate; @@ -88,14 +87,11 @@
GType devhelp_plugin_get_type(void); -DevhelpPlugin *devhelp_plugin_new(gboolean sb_tabs_bottom, - gboolean show_in_msgwin, gchar * last_uri); - +DevhelpPlugin *devhelp_plugin_new(gboolean sb_tabs_bottom, gboolean show_in_msgwin, gchar * last_uri); gchar *devhelp_plugin_clean_word(gchar * str); gchar *devhelp_plugin_get_current_tag(void); void devhelp_plugin_activate_tabs(DevhelpPlugin * dhplug, gboolean contents); -void devhelp_plugin_sidebar_tabs_bottom(DevhelpPlugin * dhplug, - gboolean bottom); +void devhelp_plugin_sidebar_tabs_bottom(DevhelpPlugin * dhplug, gboolean bottom);
G_END_DECLS #endif /* __DEVHELPPLUGIN_H__ */
Modified: trunk/geany-plugins/devhelp/src/main-notebook.c =================================================================== --- trunk/geany-plugins/devhelp/src/main-notebook.c 2011-03-17 00:23:50 UTC (rev 1992) +++ trunk/geany-plugins/devhelp/src/main-notebook.c 2011-03-17 03:52:29 UTC (rev 1993) @@ -64,7 +64,7 @@ */ void main_notebook_destroy(void) { - GtkWidget *main_notebook, *doc_nb_parent, *vbox; + GtkWidget *main_notebook, *doc_nb_parent, *vbox, *doc_nb; if (!main_notebook_needs_destroying()) return; @@ -73,15 +73,21 @@ "main_notebook");
doc_nb_parent = gtk_widget_get_parent(main_notebook); + doc_nb = g_object_get_data(G_OBJECT(main_notebook), "doc_notebook"); /* temporarily disable the notebook to prevent a segfault when * on_editor_focus_in() calls editor_check_colorize(). */ - gtk_widget_set_sensitive(geany->main_widgets->notebook, FALSE); - + gtk_widget_set_sensitive(geany->main_widgets->notebook, FALSE); + vbox = ui_lookup_widget(geany->main_widgets->window, "vbox1"); - gtk_widget_reparent(geany->main_widgets->notebook, vbox); - gtk_widget_destroy(main_notebook); - gtk_widget_reparent(geany->main_widgets->notebook, doc_nb_parent); + if (GTK_IS_WIDGET(doc_nb) && doc_nb->parent != NULL) + { + gtk_widget_ref(doc_nb); + gtk_container_remove(GTK_CONTAINER(main_notebook), doc_nb); + gtk_widget_destroy(main_notebook); + gtk_container_add(GTK_CONTAINER(doc_nb_parent), doc_nb); + gtk_widget_unref(doc_nb); + } gtk_widget_set_sensitive(geany->main_widgets->notebook, TRUE); } @@ -104,6 +110,7 @@ return create_main_notebook(); }
+ /* we need this since ui_lookup_widget() doesn't seem to realize when * the main_notebook widget is destroyed and so keeps returning something * even when main_notebook is gone. */ @@ -135,24 +142,40 @@ */ static GtkWidget *create_main_notebook(void) { - GtkWidget *main_notebook, *doc_nb_box, *doc_nb_parent, *code_label, *vbox; + GtkWidget *main_notebook, *doc_nb_box, *doc_nb_parent; + GtkWidget *vbox, *doc_nb;
if (main_notebook_exists()) return NULL; - code_label = gtk_label_new(_("Code")); - main_notebook = gtk_notebook_new(); doc_nb_box = gtk_vbox_new(FALSE, 0); vbox = ui_lookup_widget(geany->main_widgets->window, "vbox1"); - doc_nb_parent = gtk_widget_get_parent(geany->main_widgets->notebook); + main_notebook = gtk_notebook_new(); gtk_widget_set_name(main_notebook, "main_notebook"); - gtk_notebook_append_page(GTK_NOTEBOOK(main_notebook), doc_nb_box, code_label); - gtk_widget_reparent(geany->main_widgets->notebook, vbox); + + doc_nb_parent = gtk_widget_get_parent(geany->main_widgets->sidebar_notebook); + + /* sidebar on left */ + if (gtk_paned_get_child1(GTK_PANED(doc_nb_parent)) == geany->main_widgets->sidebar_notebook) + doc_nb = gtk_paned_get_child2(GTK_PANED(doc_nb_parent)); + else /* sidebar on right */ + doc_nb = gtk_paned_get_child1(GTK_PANED(doc_nb_parent)); + + gtk_notebook_append_page(GTK_NOTEBOOK(main_notebook), + doc_nb_box, + gtk_label_new(_("Code"))); + + gtk_widget_ref(doc_nb); + gtk_container_remove(GTK_CONTAINER(doc_nb_parent), doc_nb); + gtk_container_add(GTK_CONTAINER(doc_nb_parent), main_notebook); - /*gtk_paned_pack2(GTK_PANED(doc_nb_parent), main_notebook, TRUE, TRUE);*/ gtk_widget_show_all(main_notebook); - gtk_widget_reparent(geany->main_widgets->notebook, doc_nb_box); + + gtk_container_add(GTK_CONTAINER(doc_nb_box), doc_nb); + gtk_widget_unref(doc_nb); + gtk_widget_show_all(doc_nb); + gtk_notebook_set_current_page(GTK_NOTEBOOK(main_notebook), 0); gtk_notebook_set_tab_pos(GTK_NOTEBOOK(main_notebook), GTK_POS_BOTTOM);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.