Revision: 1965 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1965&view=re... Author: codebrainz Date: 2011-03-08 10:10:18 +0000 (Tue, 08 Mar 2011)
Log Message: ----------- Store last URI loaded in WebKit to configuration file.
Load the last page that was open in the WebKitWebView from the configuration file when the plugin/Geany starts and save it on unload/close.
Modified Paths: -------------- trunk/geany-plugins/devhelp/data/devhelp.conf trunk/geany-plugins/devhelp/src/devhelpplugin.c trunk/geany-plugins/devhelp/src/devhelpplugin.h trunk/geany-plugins/devhelp/src/plugin.c
Modified: trunk/geany-plugins/devhelp/data/devhelp.conf =================================================================== --- trunk/geany-plugins/devhelp/data/devhelp.conf 2011-03-08 09:12:58 UTC (rev 1964) +++ trunk/geany-plugins/devhelp/data/devhelp.conf 2011-03-08 10:10:18 UTC (rev 1965) @@ -1,3 +1,4 @@ [general] move_sidebar_tabs_bottom=true show_in_message_window=false +last_uri=
Modified: trunk/geany-plugins/devhelp/src/devhelpplugin.c =================================================================== --- trunk/geany-plugins/devhelp/src/devhelpplugin.c 2011-03-08 09:12:58 UTC (rev 1964) +++ trunk/geany-plugins/devhelp/src/devhelpplugin.c 2011-03-08 10:10:18 UTC (rev 1965) @@ -163,10 +163,11 @@ */ static void on_link_clicked(GObject *ignored, DhLink *link, gpointer user_data) { - gchar *uri = dh_link_get_uri(link); DevhelpPlugin *plug = user_data; - webkit_web_view_open(WEBKIT_WEB_VIEW(plug->webview), uri); - g_free(uri); + if (plug->last_uri) + g_free(plug->last_uri); + plug->last_uri = dh_link_get_uri(link); + webkit_web_view_open(WEBKIT_WEB_VIEW(plug->webview), plug->last_uri); gtk_notebook_set_current_page(GTK_NOTEBOOK(plug->main_notebook), plug->webview_tab); } @@ -181,7 +182,8 @@ * * @return A newly allocated DevhelpPlugin struct or null on error. */ -DevhelpPlugin *devhelp_plugin_new(gboolean sb_tabs_bottom, gboolean show_in_msgwin) +DevhelpPlugin* +devhelp_plugin_new(gboolean sb_tabs_bottom, gboolean show_in_msgwin, gchar *last_uri) { gchar *homepage_uri; GtkWidget *book_tree_sw, *webview_sw, *contents_label; @@ -326,12 +328,14 @@ geany->main_widgets->sidebar_notebook)); dhplug->tabs_toggled = FALSE; - /* load the default homepage for the webview */ - homepage_uri = g_filename_to_uri(DHPLUG_WEBVIEW_HOME_FILE, NULL, NULL); - if (homepage_uri) { - webkit_web_view_load_uri(WEBKIT_WEB_VIEW(dhplug->webview), - homepage_uri); - g_free(homepage_uri); + dhplug->last_uri = last_uri; + if (dhplug->last_uri) + webkit_web_view_load_uri(WEBKIT_WEB_VIEW(dhplug->webview), dhplug->last_uri); + else { + dhplug->last_uri = g_filename_to_uri(DHPLUG_WEBVIEW_HOME_FILE, NULL, NULL); + if (dhplug->last_uri) + webkit_web_view_load_uri(WEBKIT_WEB_VIEW(dhplug->webview), + dhplug->last_uri); } return dhplug;
Modified: trunk/geany-plugins/devhelp/src/devhelpplugin.h =================================================================== --- trunk/geany-plugins/devhelp/src/devhelpplugin.h 2011-03-08 09:12:58 UTC (rev 1964) +++ trunk/geany-plugins/devhelp/src/devhelpplugin.h 2011-03-08 10:10:18 UTC (rev 1965) @@ -78,6 +78,8 @@ gboolean sidebar_tab_bottom; gboolean in_message_window; + gchar *last_uri; + DevhelpPluginPrivate *priv; };
@@ -88,7 +90,8 @@
GType devhelp_plugin_get_type (void); -DevhelpPlugin* devhelp_plugin_new (gboolean sb_tabs_bottom, gboolean show_in_msgwin); +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);
Modified: trunk/geany-plugins/devhelp/src/plugin.c =================================================================== --- trunk/geany-plugins/devhelp/src/plugin.c 2011-03-08 09:12:58 UTC (rev 1964) +++ trunk/geany-plugins/devhelp/src/plugin.c 2011-03-08 10:10:18 UTC (rev 1965) @@ -46,6 +46,7 @@ static gchar *user_config = NULL; static gboolean move_sidebar_tabs_bottom; static gboolean show_in_msg_window; +static gchar *last_uri = NULL;
/* keybindings */ enum @@ -155,6 +156,17 @@ rcode++; } + error = NULL; + last_uri = g_key_file_get_string(kf, "general", "last_uri", &error); + if (error) + { + g_warning("Unable to load 'last_uri' setting: %s", error->message); + g_error_free(error); + error = NULL; + last_uri = NULL; + rcode++; + } + g_key_file_free(kf); return rcode; @@ -174,6 +186,7 @@ move_sidebar_tabs_bottom); g_key_file_set_boolean(kf, "general", "show_in_message_window", show_in_msg_window); + g_key_file_set_string(kf, "general", "last_uri", dev_help_plugin->last_uri); config_text = g_key_file_to_data(kf, NULL, NULL); g_key_file_free(kf); @@ -281,7 +294,8 @@ plugin_load_preferences(); dev_help_plugin = devhelp_plugin_new(move_sidebar_tabs_bottom, - show_in_msg_window); + show_in_msg_window, + last_uri);
/* setup keybindings */ key_group = plugin_set_key_group(geany_plugin, "devhelp", KB_COUNT, NULL); @@ -298,7 +312,10 @@ void plugin_cleanup(void) { plugin_store_preferences(); - + + if (dev_help_plugin->last_uri) + g_free(dev_help_plugin->last_uri); + g_object_unref(dev_help_plugin); g_free(default_config);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.