Revision: 1968 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1968&view=re... Author: codebrainz Date: 2011-03-09 06:41:00 +0000 (Wed, 09 Mar 2011)
Log Message: ----------- Add toolbar separator and cleanup code a bit using cppcheck.
Modified Paths: -------------- trunk/geany-plugins/devhelp/src/devhelpplugin.c trunk/geany-plugins/devhelp/src/devhelpplugin.h
Modified: trunk/geany-plugins/devhelp/src/devhelpplugin.c =================================================================== --- trunk/geany-plugins/devhelp/src/devhelpplugin.c 2011-03-09 06:40:46 UTC (rev 1967) +++ trunk/geany-plugins/devhelp/src/devhelpplugin.c 2011-03-09 06:41:00 UTC (rev 1968) @@ -198,7 +198,24 @@ plug->zoom_level = webkit_web_view_get_zoom_level(view); }
+static void on_document_load_finished(WebKitWebView *view, + WebKitWebFrame *frame, + gpointer user_data) +{ + DevhelpPlugin *plug = user_data; + + if (webkit_web_view_can_go_back(view)) + gtk_widget_set_sensitive(GTK_WIDGET(plug->btn_back), TRUE); + else + gtk_widget_set_sensitive(GTK_WIDGET(plug->btn_back), FALSE); + + if (webkit_web_view_can_go_forward(view)) + gtk_widget_set_sensitive(GTK_WIDGET(plug->btn_forward), TRUE); + else + gtk_widget_set_sensitive(GTK_WIDGET(plug->btn_forward), FALSE); +}
+ /** * devhelp_plugin_new: * @@ -211,11 +228,9 @@ 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; - GtkWidget *search_label, *dh_sidebar_label, *doc_label; - GtkWidget *vbox, *toolbar; - GtkToolItem *btn_back, *btn_forward, *tb_sep, *btn_zoom_in, *btn_zoom_out; + GtkWidget *search_label, *dh_sidebar_label, *doc_label, *vbox, *toolbar; + GtkToolItem *btn_zoom_in, *btn_zoom_out, *tb_sep; DevhelpPlugin *dhplug;
@@ -313,14 +328,16 @@ /* put the webview and toolbar stuff into the main notebook */ vbox = gtk_vbox_new(FALSE, 0); toolbar = gtk_toolbar_new(); - btn_back = gtk_tool_button_new_from_stock(GTK_STOCK_GO_BACK); - btn_forward = gtk_tool_button_new_from_stock(GTK_STOCK_GO_FORWARD); + dhplug->btn_back = gtk_tool_button_new_from_stock(GTK_STOCK_GO_BACK); + dhplug->btn_forward = gtk_tool_button_new_from_stock(GTK_STOCK_GO_FORWARD); btn_zoom_in = gtk_tool_button_new_from_stock(GTK_STOCK_ZOOM_IN); btn_zoom_out = gtk_tool_button_new_from_stock(GTK_STOCK_ZOOM_OUT); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(btn_back), -1); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(btn_forward), -1); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(btn_zoom_in), -1); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(btn_zoom_out), -1); + tb_sep = gtk_separator_tool_item_new(); + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), dhplug->btn_back, -1); + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), dhplug->btn_forward, -1); + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tb_sep, -1); + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), btn_zoom_in, -1); + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), btn_zoom_out, -1); gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), webview_sw, TRUE, TRUE, 0); gtk_notebook_append_page(GTK_NOTEBOOK(dhplug->main_notebook), vbox, doc_label); @@ -358,12 +375,12 @@ G_CALLBACK(on_link_clicked), dhplug); - g_signal_connect(btn_back, + g_signal_connect(dhplug->btn_back, "clicked", G_CALLBACK(on_back_button_clicked), dhplug); - g_signal_connect(btn_forward, + g_signal_connect(dhplug->btn_forward, "clicked", G_CALLBACK(on_forward_button_clicked), dhplug); @@ -377,6 +394,11 @@ "clicked", G_CALLBACK(on_zoom_out_button_clicked), dhplug); + + g_signal_connect(WEBKIT_WEB_VIEW(dhplug->webview), + "document-load-finished", + G_CALLBACK(on_document_load_finished), + dhplug);
/* toggle state tracking */ dhplug->last_main_tab_id = gtk_notebook_get_current_page(
Modified: trunk/geany-plugins/devhelp/src/devhelpplugin.h =================================================================== --- trunk/geany-plugins/devhelp/src/devhelpplugin.h 2011-03-09 06:40:46 UTC (rev 1967) +++ trunk/geany-plugins/devhelp/src/devhelpplugin.h 2011-03-09 06:41:00 UTC (rev 1968) @@ -81,6 +81,9 @@ gchar *last_uri; gfloat zoom_level; + GtkToolItem *btn_back; + GtkToolItem *btn_forward; + DevhelpPluginPrivate *priv; };
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
plugins-commits@lists.geany.org