]> spindle.queued.net Git - midori/commitdiff
Reorganize code in formhistory-gdom
authorAlexander Butenko <a.butenka@gmail.com>
Sun, 8 Jan 2012 00:17:06 +0000 (20:17 -0400)
committerChristian Dywan <christian@twotoasts.de>
Tue, 10 Jan 2012 01:10:38 +0000 (02:10 +0100)
extensions/formhistory/formhistory-gdom-frontend.c

index 2c89fc73249ccbc7f7c8772eac099b47c40baba7..18efd82d3d1a95fec8dc50b65b0232e0cd884dba 100644 (file)
@@ -116,8 +116,7 @@ finish:
 }
 
 static void
-formhistory_reposition_popup (FormHistoryPriv* priv,
-                              GtkWidget*       widget)
+formhistory_reposition_popup (FormHistoryPriv* priv)
 {
     WebKitDOMDocument* element_document;
     WebKitDOMNodeList* frames;
@@ -127,8 +126,9 @@ formhistory_reposition_popup (FormHistoryPriv* priv,
     glong x = 0, y = 0;
     glong height;
 
+    GtkWidget* toplevel = gtk_widget_get_toplevel (GTK_WIDGET (priv->root));
     /* Position of a root window */
-    window = gtk_widget_get_window (widget);
+    window = gtk_widget_get_window (toplevel);
     gdk_window_get_position (window, &rx, &ry);
 
     /* Postion of webview in root window */
@@ -142,8 +142,13 @@ formhistory_reposition_popup (FormHistoryPriv* priv,
     /* Add height as menu should start under editbox, now on top of it */
     g_object_get (priv->element, "client-height", &height, NULL);
     y += height + 1;
-
     gtk_window_move (GTK_WINDOW (priv->popup),  rx + wx + x, ry +wy + y);
+
+    /* Window configuration */
+    gtk_window_set_screen (GTK_WINDOW (priv->popup),
+                           gtk_widget_get_screen (GTK_WIDGET (priv->root)));
+    /* FIXME: If Midori window is small, popup doesn't show up */
+    gtk_window_set_transient_for (GTK_WINDOW (priv->popup), GTK_WINDOW (toplevel));
     gtk_tree_view_columns_autosize (GTK_TREE_VIEW (priv->treeview));
     /* FIXME: Adjust size according to treeview width and some reasonable height */
     gtk_window_resize (GTK_WINDOW (priv->popup), 50, 80);
@@ -210,13 +215,7 @@ formhistory_suggestions_show (FormHistoryPriv* priv)
 
     if (gtk_widget_get_visible (priv->popup))
         return;
-
-    GtkWidget* toplevel = gtk_widget_get_toplevel (GTK_WIDGET (priv->root));
-    gtk_window_set_screen (GTK_WINDOW (priv->popup),
-                           gtk_widget_get_screen (GTK_WIDGET (priv->root)));
-    /* FIXME: If Midori window is small, popup doesn't show up */
-    gtk_window_set_transient_for (GTK_WINDOW (priv->popup), GTK_WINDOW (toplevel));
-    formhistory_reposition_popup (priv, toplevel);
+    formhistory_reposition_popup (priv);
     gtk_widget_show_all (priv->popup);
     gtk_widget_grab_focus (priv->treeview);
 }