1 module webkit2.WindowProperties; 2 3 private import gobject.ObjectG; 4 private import webkit2.c.functions; 5 public import webkit2.c.types; 6 7 8 /** 9 * The content of a #WebKitWebView can request to change certain 10 * properties of the window containing the view. This can include the x, y position 11 * of the window, the width and height but also if a toolbar, 12 * scrollbar, statusbar, locationbar should be visible to the user, 13 * and the request to show the #WebKitWebView fullscreen. 14 * 15 * The #WebKitWebView::ready-to-show signal handler is the proper place 16 * to apply the initial window properties. Then you can monitor the 17 * #WebKitWindowProperties by connecting to ::notify signal. 18 * 19 * <informalexample><programlisting> 20 * static void ready_to_show_cb (WebKitWebView *web_view, gpointer user_data) 21 * { 22 * GtkWidget *window; 23 * WebKitWindowProperties *window_properties; 24 * gboolean visible; 25 * 26 * /<!-- -->* Create the window to contain the WebKitWebView *<!-- -->/ 27 * window = browser_window_new (); 28 * gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (web_view)); 29 * gtk_widget_show (GTK_WIDGET (web_view)); 30 * 31 * /<!-- -->* Get the WebKitWindowProperties of the web view and monitor it *<!-- -->/ 32 * window_properties = webkit_web_view_get_window_properties (web_view); 33 * g_signal_connect (window_properties, "notify::geometry", 34 * G_CALLBACK (window_geometry_changed), window); 35 * g_signal_connect (window_properties, "notify::toolbar-visible", 36 * G_CALLBACK (window_toolbar_visibility_changed), window); 37 * g_signal_connect (window_properties, "notify::menubar-visible", 38 * G_CALLBACK (window_menubar_visibility_changed), window); 39 * .... 40 * 41 * /<!-- -->* Apply the window properties before showing the window *<!-- -->/ 42 * visible = webkit_window_properties_get_toolbar_visible (window_properties); 43 * browser_window_set_toolbar_visible (BROWSER_WINDOW (window), visible); 44 * visible = webkit_window_properties_get_menubar_visible (window_properties); 45 * browser_window_set_menubar_visible (BROWSER_WINDOW (window), visible); 46 * .... 47 * 48 * if (webkit_window_properties_get_fullscreen (window_properties)) { 49 * gtk_window_fullscreen (GTK_WINDOW (window)); 50 * } else { 51 * GdkRectangle geometry; 52 * 53 * gtk_window_set_resizable (GTK_WINDOW (window), 54 * webkit_window_properties_get_resizable (window_properties)); 55 * webkit_window_properties_get_geometry (window_properties, &geometry); 56 * gtk_window_move (GTK_WINDOW (window), geometry.x, geometry.y); 57 * gtk_window_resize (GTK_WINDOW (window), geometry.width, geometry.height); 58 * } 59 * 60 * gtk_widget_show (window); 61 * } 62 * </programlisting></informalexample> 63 */ 64 public class WindowProperties : ObjectG 65 { 66 /** the main Gtk struct */ 67 protected WebKitWindowProperties* webKitWindowProperties; 68 69 /** Get the main Gtk struct */ 70 public WebKitWindowProperties* getWindowPropertiesStruct(bool transferOwnership = false) 71 { 72 if (transferOwnership) 73 ownedRef = false; 74 return webKitWindowProperties; 75 } 76 77 /** the main Gtk struct as a void* */ 78 protected override void* getStruct() 79 { 80 return cast(void*)webKitWindowProperties; 81 } 82 83 /** 84 * Sets our main struct and passes it to the parent class. 85 */ 86 public this (WebKitWindowProperties* webKitWindowProperties, bool ownedRef = false) 87 { 88 this.webKitWindowProperties = webKitWindowProperties; 89 super(cast(GObject*)webKitWindowProperties, ownedRef); 90 } 91 92 93 /** */ 94 public static GType getType() 95 { 96 return webkit_window_properties_get_type(); 97 } 98 99 /** 100 * Get whether the window should be shown in fullscreen state or not. 101 * 102 * Returns: %TRUE if the window should be fullscreen or %FALSE otherwise. 103 */ 104 public bool getFullscreen() 105 { 106 return webkit_window_properties_get_fullscreen(webKitWindowProperties) != 0; 107 } 108 109 /** 110 * Get the geometry the window should have on the screen when shown. 111 * 112 * Params: 113 * geometry = return location for the window geometry 114 */ 115 public void getGeometry(out GdkRectangle geometry) 116 { 117 webkit_window_properties_get_geometry(webKitWindowProperties, &geometry); 118 } 119 120 /** 121 * Get whether the window should have the locationbar visible or not. 122 * 123 * Returns: %TRUE if locationbar should be visible or %FALSE otherwise. 124 */ 125 public bool getLocationbarVisible() 126 { 127 return webkit_window_properties_get_locationbar_visible(webKitWindowProperties) != 0; 128 } 129 130 /** 131 * Get whether the window should have the menubar visible or not. 132 * 133 * Returns: %TRUE if menubar should be visible or %FALSE otherwise. 134 */ 135 public bool getMenubarVisible() 136 { 137 return webkit_window_properties_get_menubar_visible(webKitWindowProperties) != 0; 138 } 139 140 /** 141 * Get whether the window should be resizable by the user or not. 142 * 143 * Returns: %TRUE if the window should be resizable or %FALSE otherwise. 144 */ 145 public bool getResizable() 146 { 147 return webkit_window_properties_get_resizable(webKitWindowProperties) != 0; 148 } 149 150 /** 151 * Get whether the window should have the scrollbars visible or not. 152 * 153 * Returns: %TRUE if scrollbars should be visible or %FALSE otherwise. 154 */ 155 public bool getScrollbarsVisible() 156 { 157 return webkit_window_properties_get_scrollbars_visible(webKitWindowProperties) != 0; 158 } 159 160 /** 161 * Get whether the window should have the statusbar visible or not. 162 * 163 * Returns: %TRUE if statusbar should be visible or %FALSE otherwise. 164 */ 165 public bool getStatusbarVisible() 166 { 167 return webkit_window_properties_get_statusbar_visible(webKitWindowProperties) != 0; 168 } 169 170 /** 171 * Get whether the window should have the toolbar visible or not. 172 * 173 * Returns: %TRUE if toolbar should be visible or %FALSE otherwise. 174 */ 175 public bool getToolbarVisible() 176 { 177 return webkit_window_properties_get_toolbar_visible(webKitWindowProperties) != 0; 178 } 179 }