From 2af46ece40073b8bed96470d5463202bb7217d45 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Thu, 10 Jul 2014 23:33:22 +0200 Subject: [PATCH] Remove WebKitWebView creation from Glade The Glade template cannot assign an already created WebKitWebViewGroup to the WebKitWebView it creates. Thus we need to create it manuallp --- src/ag-app.c | 3 ++- src/ag-window.c | 41 +++++++++++++++++++++-------------- src/ag-window.h | 4 +++- src/resources/ui/ag-window.ui | 12 +++------- 4 files changed, 33 insertions(+), 27 deletions(-) diff --git a/src/ag-app.c b/src/ag-app.c index c75319c..876572a 100644 --- a/src/ag-app.c +++ b/src/ag-app.c @@ -52,8 +52,9 @@ static GtkWidget * ag_app_create_window(AgApp *app) { GtkWidget *window; + AgAppPrivate *priv = ag_app_get_instance_private(app); - window = ag_window_new(app); + window = ag_window_new(app, priv->web_view_group); gtk_application_add_window(GTK_APPLICATION(app), GTK_WINDOW(window)); gtk_widget_show_all(window); diff --git a/src/ag-window.c b/src/ag-window.c index 5f1f79b..387b69b 100644 --- a/src/ag-window.c +++ b/src/ag-window.c @@ -30,6 +30,7 @@ struct _AgWindowPrivate { GtkWidget *second; GtkWidget *timezone; + GtkWidget *tab_chart; GtkWidget *tab_edit; GtkWidget *current_tab; @@ -695,20 +696,6 @@ ag_window_init(AgWindow *window) g_signal_connect(G_OBJECT(main_settings), "changed::planets-char", G_CALLBACK(ag_window_display_changed), window); g_signal_connect(G_OBJECT(main_settings), "changed::aspects-char", G_CALLBACK(ag_window_display_changed), window); - // TODO: translate this error message! - webkit_web_view_load_html( - WEBKIT_WEB_VIEW(priv->chart_web_view), - "" \ - "" \ - "No Chart" \ - "" \ - "" \ - "

No Chart

" \ - "

No chart is loaded. Create one on the edit view, or open one from the application menu!

" \ - "" \ - "", - NULL); - gtk_stack_set_visible_child_name(GTK_STACK(priv->stack), "edit"); priv->current_tab = priv->tab_edit; g_object_set(priv->year_adjust, "lower", (gdouble)G_MININT, "upper", (gdouble)G_MAXINT, NULL); @@ -759,9 +746,13 @@ ag_window_class_init(AgWindowClass *klass) gtk_widget_class_bind_template_child_private(widget_class, AgWindow, west_long); gtk_widget_class_bind_template_child_private(widget_class, AgWindow, latitude); gtk_widget_class_bind_template_child_private(widget_class, AgWindow, longitude); - gtk_widget_class_bind_template_child_private(widget_class, AgWindow, chart_web_view); gtk_widget_class_bind_template_child_private(widget_class, AgWindow, aspect_table); gtk_widget_class_bind_template_child_private(widget_class, AgWindow, year_adjust); + gtk_widget_class_bind_template_child_private( + widget_class, + AgWindow, + tab_chart + ); gtk_widget_class_bind_template_child_private(widget_class, AgWindow, stack); gtk_widget_class_bind_template_child_private(widget_class, AgWindow, note_buffer); } @@ -784,11 +775,29 @@ ag_window_configure_event_cb(GtkWidget *widget, GdkEventConfigure *event, gpoint } GtkWidget * -ag_window_new(AgApp *app) +ag_window_new(AgApp *app, WebKitWebViewGroup *web_view_group) { AgWindow *window = g_object_new(AG_TYPE_WINDOW, NULL); AgWindowPrivate *priv = ag_window_get_instance_private(window); + priv->chart_web_view = webkit_web_view_new_with_group(web_view_group); + gtk_container_add(GTK_CONTAINER(priv->tab_chart), priv->chart_web_view); + + // TODO: translate this error message! + webkit_web_view_load_html( + WEBKIT_WEB_VIEW(priv->chart_web_view), + "" \ + "" \ + "No Chart" \ + "" \ + "" \ + "

No Chart

" \ + "

No chart is loaded. Create one on the " \ + "edit view, or open one from the application menu!

" \ + "" \ + "", + NULL); + gtk_window_set_application(GTK_WINDOW(window), GTK_APPLICATION(app)); gtk_window_set_icon_name(GTK_WINDOW(window), "astrognome"); diff --git a/src/ag-window.h b/src/ag-window.h index 3376bdd..66c591b 100644 --- a/src/ag-window.h +++ b/src/ag-window.h @@ -2,6 +2,8 @@ #define __AG_WINDOW_H__ #include +#include + #include "ag-app.h" #include "ag-chart.h" @@ -32,7 +34,7 @@ struct _AgWindowClass { }; GType ag_window_get_type(void) G_GNUC_CONST; -GtkWidget *ag_window_new(AgApp *app); +GtkWidget *ag_window_new(AgApp *app, WebKitWebViewGroup *web_view_group); void ag_window_set_chart(AgWindow *window, AgChart *chart); AgChart *ag_window_get_chart(AgWindow *window); diff --git a/src/resources/ui/ag-window.ui b/src/resources/ui/ag-window.ui index d7673a2..418743e 100644 --- a/src/resources/ui/ag-window.ui +++ b/src/resources/ui/ag-window.ui @@ -568,15 +568,9 @@ - - in - - - 600 - 600 - - - + + True + False chart