{
#ifdef HAVE_GRANITE
gboolean has_tabs = !(midori_browser_is_fullscreen (browser) || ignore_fullscreen);
- /* FIXME: Toggle tabbar visibility */
+ granite_widgets_dynamic_notebook_set_show_tabs (
+ GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook), has_tabs);
#else
gboolean has_tabs =
gtk_notebook_get_nth_page (GTK_NOTEBOOK (browser->notebook), 1) != NULL;
{
if (katze_object_get_boolean (widget, "minimized"))
{
- #ifdef HAVE_GRANITE
- /* FIXME */
- #else
+ #ifndef HAVE_GRANITE
GtkNotebook* notebook = GTK_NOTEBOOK (browser->notebook);
GtkWidget* label = gtk_notebook_get_tab_label (notebook, widget);
gtk_widget_set_size_request (label, -1, -1);
else
n = -1;
#ifdef HAVE_GRANITE
- /* FIXME: Move to desired position */
- granite_widgets_dynamic_notebook_append_page (
+ granite_widgets_dynamic_notebook_insert_tab (
GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (notebook),
- view, midori_view_get_display_title (MIDORI_VIEW (view)), "text-plain");
+ midori_view_get_tab (MIDORI_VIEW (view)), n);
#else
tab_label = midori_view_get_proxy_tab_label (MIDORI_VIEW (view));
/* Don't resize empty bin, which is used for thumbnail tabs */
GtkCallback callback,
gpointer callback_data)
{
- g_return_if_fail (MIDORI_IS_BROWSER (browser));
+ g_return_if_fail (MIDORI_IS_BROWSER (browser));
- gtk_container_foreach (GTK_CONTAINER (browser->notebook),
- callback, callback_data);
+ #ifdef HAVE_GRANITE
+ /* FIXME */
+ if (GTK_IS_BIN (browser->notebook))
+ gtk_container_foreach (GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (
+ browser->notebook))), callback, callback_data);
+ else
+ #endif
+ gtk_container_foreach (GTK_CONTAINER (browser->notebook),
+ callback, callback_data);
}
static void
gtk_widget_hide (browser->bookmarkbar);
gtk_widget_hide (browser->navigationbar);
gtk_widget_hide (browser->statusbar);
- #ifndef HAVE_GRANITE
- /* FIXME hide tabs */
+ #ifdef HAVE_GRANITE
+ granite_widgets_dynamic_notebook_set_show_tabs (
+ GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook), FALSE);
#else
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (browser->notebook), FALSE);
gtk_notebook_set_show_border (GTK_NOTEBOOK (browser->notebook), FALSE);
midori_browser_get_n_pages (MidoriBrowser* browser)
{
#ifdef HAVE_GRANITE
- return granite_widgets_dynamic_notebook_get_n_pages (
+ return granite_widgets_dynamic_notebook_get_n_tabs (
GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook));
#else
return gtk_notebook_get_n_pages (GTK_NOTEBOOK (browser->notebook));
else
new_pos = midori_browser_get_n_pages (browser) - 1;
#ifdef HAVE_GRANITE
- /* FIXME */
+ /* FIXME: There is no move/ set_tab_position function */
+ granite_widgets_dynamic_notebook_remove_tab (
+ GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook),
+ midori_view_get_tab (MIDORI_VIEW (widget)));
+ granite_widgets_dynamic_notebook_insert_tab (
+ GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook),
+ midori_view_get_tab (MIDORI_VIEW (widget)), new_pos);
#else
gtk_notebook_reorder_child (GTK_NOTEBOOK (browser->notebook), widget, new_pos);
- g_signal_emit (browser, signals[MOVE_TAB], 0, browser->notebook, cur_pos, new_pos);
#endif
+ g_signal_emit (browser, signals[MOVE_TAB], 0, browser->notebook, cur_pos, new_pos);
}
static void
else
new_pos = cur_pos + 1;
#ifdef HAVE_GRANITE
- /* FIXME */
+ /* FIXME: There is no move/ set_tab_position function */
+ granite_widgets_dynamic_notebook_remove_tab (
+ GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook),
+ midori_view_get_tab (MIDORI_VIEW (widget)));
+ granite_widgets_dynamic_notebook_insert_tab (
+ GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook),
+ midori_view_get_tab (MIDORI_VIEW (widget)), new_pos);
#else
gtk_notebook_reorder_child (GTK_NOTEBOOK (browser->notebook), widget, new_pos);
- g_signal_emit (browser, signals[MOVE_TAB], 0, browser->notebook, cur_pos, new_pos);
#endif
+ g_signal_emit (browser, signals[MOVE_TAB], 0, browser->notebook, cur_pos, new_pos);
}
static void
_midori_browser_update_progress (browser, view);
}
+static void
+midori_browser_notebook_page_reordered_cb (GtkWidget* notebook,
+ MidoriView* view,
+ guint page_num,
+ MidoriBrowser* browser)
+{
+ KatzeItem* item = midori_view_get_proxy_item (view);
+ katze_array_move_item (browser->proxy_array, item, page_num);
+ g_object_notify (G_OBJECT (browser), "tab");
+}
+
+static GtkWidget*
+midori_browser_notebook_create_window_cb (GtkNotebook* notebook,
+ MidoriView* view,
+ gint x,
+ gint y,
+ MidoriBrowser* browser)
+{
+ MidoriBrowser* new_browser;
+ g_signal_emit (browser, signals[NEW_WINDOW], 0, NULL, &new_browser);
+ if (new_browser)
+ {
+ GtkWidget* new_notebook = new_browser->notebook;
+ gtk_window_move (GTK_WINDOW (new_browser), x, y);
+ return new_notebook;
+ }
+ else /* No MidoriApp, so this is app or private mode */
+ return NULL;
+}
+
#ifdef HAVE_GRANITE
static void
-midori_browser_notebook_new_tab_created_cb (GtkWidget* notebook,
- GraniteWidgetsTab* tab,
- MidoriBrowser* browser)
+midori_browser_notebook_tab_added_cb (GtkWidget* notebook,
+ GraniteWidgetsTab* tab,
+ MidoriBrowser* browser)
{
- /* FIXME Pack view into tab: How? */
- KatzeItem* item = katze_item_new ();
- GtkWidget* view = midori_view_new_with_item (item, browser->settings);
+ GtkWidget* view = midori_view_new_with_item (NULL, browser->settings);
+ midori_view_set_tab (MIDORI_VIEW (view), tab);
gint n = midori_browser_add_tab (browser, view);
midori_browser_set_current_page (browser, n);
}
-#endif
static void
-midori_browser_notebook_page_reordered_cb (GtkNotebook* notebook,
- MidoriView* view,
- guint page_num,
- MidoriBrowser* browser)
+midori_browser_notebook_tab_removed_cb (GtkWidget* notebook,
+ GraniteWidgetsTab* tab,
+ MidoriBrowser* browser)
{
- KatzeItem* item = midori_view_get_proxy_item (view);
- katze_array_move_item (browser->proxy_array, item, page_num);
- g_object_notify (G_OBJECT (browser), "tab");
+ _midori_browser_remove_tab (browser, granite_widgets_tab_get_page (tab));
}
+static void
+midori_browser_notebook_tab_switched_cb (GtkWidget* notebook,
+ GraniteWidgetsTab* old_tab,
+ GraniteWidgetsTab* new_tab,
+ MidoriBrowser* browser)
+{
+ midori_browser_notebook_switch_page_cb (notebook, NULL, 0, browser);
+ midori_browser_notebook_switch_page_after_cb (notebook, NULL, 0, browser);
+}
+
+static void
+midori_browser_notebook_tab_moved_cb (GtkWidget* notebook,
+ GraniteWidgetsTab* tab,
+ gint old_pos,
+ gboolean new_window,
+ gint x,
+ gint y,
+ MidoriBrowser* browser)
+{
+ GtkWidget* view = granite_widgets_tab_get_page (tab);
+ if (new_window)
+ {
+ /* FIXME midori_browser_notebook_create_window_cb */
+ }
+ else
+ {
+ gint new_pos = granite_widgets_dynamic_notebook_get_tab_position (
+ GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (notebook), tab);
+ midori_browser_notebook_page_reordered_cb (notebook,
+ MIDORI_VIEW (view), new_pos, browser);
+ }
+}
+#else
static void
midori_browser_notebook_page_removed_cb (GtkWidget* notebook,
GtkWidget* view,
return TRUE;
}
-static GtkWidget*
-midori_browser_notebook_create_window_cb (GtkNotebook* notebook,
- MidoriView* view,
- gint x,
- gint y,
- MidoriBrowser* browser)
-{
- MidoriBrowser* new_browser;
- g_signal_emit (browser, signals[NEW_WINDOW], 0, NULL, &new_browser);
- if (new_browser)
- {
- GtkWidget* new_notebook = new_browser->notebook;
- gtk_window_move (GTK_WINDOW (new_browser), x, y);
- return new_notebook;
- }
- else /* No MidoriApp, so this is app or private mode */
- return NULL;
-}
-
static void
midori_browser_menu_item_switch_tab_cb (GtkWidget* menuitem,
MidoriBrowser* browser)
return FALSE;
}
+#endif
static void
_action_undo_tab_close_activate (GtkAction* action,
/* Destroy panel first, so panels don't need special care */
gtk_widget_destroy (browser->panel);
- /* Destroy tabs second, so child widgets don't need special care */
+ #ifndef HAVE_GRANITE
g_signal_handlers_disconnect_by_func (browser->notebook,
midori_browser_notebook_reorder_tab_cb,
NULL);
g_signal_handlers_disconnect_by_func (browser->notebook,
midori_browser_notebook_size_allocate_cb,
browser);
+ #endif
+ /* Destroy tabs second, so child widgets don't need special care */
gtk_container_foreach (GTK_CONTAINER (browser->notebook),
(GtkCallback) gtk_widget_destroy, NULL);
}
#ifdef HAVE_GRANITE
/* FIXME: granite: should return GtkWidget* like GTK+ */
browser->notebook = (GtkWidget*)granite_widgets_dynamic_notebook_new ();
+ /* FIXME: work-around a bug */
+ gtk_widget_show_all (browser->notebook);
#else
browser->notebook = gtk_notebook_new ();
gtk_notebook_set_scrollable (GTK_NOTEBOOK (browser->notebook), TRUE);
}
#endif
gtk_paned_pack1 (GTK_PANED (vpaned), browser->notebook, FALSE, FALSE);
+ #ifdef HAVE_GRANITE
+ /* FIXME menu items */
+ g_signal_connect (browser->notebook, "tab-added",
+ G_CALLBACK (midori_browser_notebook_tab_added_cb),
+ browser);
+ g_signal_connect (browser->notebook, "tab-removed",
+ G_CALLBACK (midori_browser_notebook_tab_removed_cb),
+ browser);
+ g_signal_connect (browser->notebook, "tab-switched",
+ G_CALLBACK (midori_browser_notebook_tab_switched_cb),
+ browser);
+ g_signal_connect (browser->notebook, "tab-moved",
+ G_CALLBACK (midori_browser_notebook_tab_moved_cb),
+ browser);
+ #else
g_signal_connect (browser->notebook, "switch-page",
G_CALLBACK (midori_browser_notebook_switch_page_cb),
browser);
g_signal_connect_after (browser->notebook, "switch-page",
G_CALLBACK (midori_browser_notebook_switch_page_after_cb),
browser);
- #ifdef HAVE_GRANITE
- g_signal_connect (browser->notebook, "new-tab-created",
- G_CALLBACK (midori_browser_notebook_new_tab_created_cb),
- browser);
- #endif
g_signal_connect (browser->notebook, "page-reordered",
G_CALLBACK (midori_browser_notebook_page_reordered_cb),
browser);
G_CALLBACK (midori_browser_notebook_reorder_tab_cb), NULL);
g_signal_connect (browser->notebook, "create-window",
G_CALLBACK (midori_browser_notebook_create_window_cb), browser);
+ #endif
gtk_widget_show (browser->notebook);
/* Inspector container */
"news-aggregator", &browser->news_aggregator,
NULL);
+ #ifdef HAVE_GRANITE
+ granite_widgets_dynamic_notebook_set_tabs_closable (
+ GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook), close_buttons_on_tabs);
+ #endif
midori_findbar_set_close_button_left (MIDORI_FINDBAR (browser->find),
katze_object_get_boolean (browser->settings, "close-buttons-left"));
_midori_browser_update_settings (browser);
g_signal_connect (browser->settings, "notify",
G_CALLBACK (midori_browser_settings_notify), browser);
- gtk_container_foreach (GTK_CONTAINER (browser->notebook),
+ midori_browser_foreach (browser,
(GtkCallback) midori_view_set_settings, browser->settings);
break;
case PROP_BOOKMARKS:
g_return_val_if_fail (MIDORI_IS_VIEW (view), -1);
#ifdef HAVE_GRANITE
- return granite_widgets_dynamic_notebook_page_num (
- GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook), view);
+ return granite_widgets_dynamic_notebook_get_tab_position (
+ GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook),
+ midori_view_get_tab (MIDORI_VIEW (view)));
#else
return gtk_notebook_page_num (GTK_NOTEBOOK (browser->notebook), view);
#endif
g_return_if_fail (view != NULL);
#ifdef HAVE_GRANITE
- granite_widgets_dynamic_notebook_set_current_page (
- GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook), n);
+ granite_widgets_dynamic_notebook_set_current (
+ GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook),
+ midori_view_get_tab (MIDORI_VIEW (view)));
#else
gtk_notebook_set_current_page (GTK_NOTEBOOK (browser->notebook), n);
#endif
g_return_val_if_fail (MIDORI_IS_BROWSER (browser), -1);
#ifdef HAVE_GRANITE
- return granite_widgets_dynamic_notebook_get_current_page (
+ GraniteWidgetsTab* tab = granite_widgets_dynamic_notebook_get_current (
GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook));
+ return tab ? granite_widgets_dynamic_notebook_get_tab_position (
+ GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook), tab) : -1;
#else
return gtk_notebook_get_current_page (GTK_NOTEBOOK (browser->notebook));
#endif
g_return_val_if_fail (MIDORI_IS_BROWSER (browser), NULL);
- tab = granite_widgets_dynamic_notebook_get_nth_page (
+ tab = granite_widgets_dynamic_notebook_get_tab_by_index (
GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook), page);
- return tab != NULL ? tab->widget : NULL;
+ return tab != NULL ? granite_widgets_tab_get_page (tab) : NULL;
#else
g_return_val_if_fail (MIDORI_IS_BROWSER (browser), NULL);
gint alerts;
GtkWidget* menu_item;
+ PangoEllipsizeMode ellipsize;
+ #ifdef HAVE_GRANITE
+ GraniteWidgetsTab* tab;
+ #else
GtkWidget* tab_label;
GtkWidget* tab_icon;
GtkWidget* tab_title;
GtkWidget* tab_close;
+ #endif
KatzeItem* item;
gint scrollh, scrollv;
gboolean back_forward_set;
flags));
}
-#ifdef HAVE_GRANITE
-static GraniteWidgetsTab*
-midori_view_get_tab (MidoriView* view)
-{
- GraniteWidgetsDynamicNotebook* notebook;
- GraniteWidgetsTab* tab = NULL;
-
- notebook = (GraniteWidgetsDynamicNotebook*)gtk_widget_get_parent ((GtkWidget*)view);
- if (notebook != NULL)
- tab = granite_widgets_dynamic_notebook_get_nth_page (notebook,
- granite_widgets_dynamic_notebook_page_num (notebook, (GtkWidget*)view));
-
- return tab;
-}
-#endif
-
static void
midori_view_set_title (MidoriView* view, const gchar* title)
{
const gchar* display_title;
- #ifdef HAVE_GRANITE
- GraniteWidgetsTab* tab;
- #endif
if (!title)
title = view->uri;
#endif
display_title = midori_view_get_display_title (view);
- #ifdef HAVE_GRANITE
- /* FIXME: granite: GraniteWidgetsTab.text should be a property */
- tab = midori_view_get_tab (view);
- if (tab != NULL)
- katze_assign (tab->text, g_strdup (display_title));
- #endif
- if (view->tab_label)
- {
/* If the title starts with the presumed name of the website, we
ellipsize differently, to emphasize the subtitle */
- if (gtk_label_get_angle (GTK_LABEL (view->tab_title)) == 0.0)
- {
SoupURI* uri = soup_uri_new (view->uri);
const gchar* host = uri ? (uri->host ? uri->host : "") : "";
const gchar* name = g_str_has_prefix (host, "www.") ? &host[4] : host;
if (name[i] == '.')
break;
if (!g_ascii_strncasecmp (display_title, name, i))
- gtk_label_set_ellipsize (GTK_LABEL (view->tab_title), PANGO_ELLIPSIZE_START);
+ view->ellipsize = PANGO_ELLIPSIZE_START;
else
- gtk_label_set_ellipsize (GTK_LABEL (view->tab_title), PANGO_ELLIPSIZE_END);
+ view->ellipsize = PANGO_ELLIPSIZE_END;
if (uri)
soup_uri_free (uri);
- }
+ #ifdef HAVE_GRANITE
+ g_object_set (midori_view_get_tab (view),
+ "label", display_title, "ellipsize-mode", view->ellipsize, NULL);
+ #else
+ if (view->tab_label)
+ {
gtk_label_set_text (GTK_LABEL (view->tab_title), display_title);
gtk_widget_set_tooltip_text (view->tab_icon, display_title);
gtk_widget_set_tooltip_text (view->tab_title, display_title);
+ if (gtk_label_get_angle (GTK_LABEL (view->tab_title)) == 0.0)
+ gtk_label_set_ellipsize (GTK_LABEL (view->tab_title), view->ellipsize);
}
+ #endif
if (view->menu_item)
gtk_label_set_text (GTK_LABEL (gtk_bin_get_child (GTK_BIN (
view->menu_item))), display_title);
GdkPixbuf* icon,
const gchar* icon_name)
{
- #ifdef HAVE_GRANITE
- GraniteWidgetsTab* tab = midori_view_get_tab (view);
- g_object_set (tab, "pixbuf", icon, NULL);
- #endif
-
katze_item_set_icon (view->item, icon_name);
/* katze_item_get_image knows about this pixbuf */
g_object_set_data_full (G_OBJECT (view->item), "pixbuf", g_object_ref (icon),
katze_object_assign (view->icon, icon);
g_object_notify (G_OBJECT (view), "icon");
+ #ifdef HAVE_GRANITE
+ g_object_set (midori_view_get_tab (view), "icon", icon, NULL);
+ #else
if (view->tab_icon)
{
if (icon_name && !strchr (icon_name, '/'))
katze_throbber_set_static_pixbuf (KATZE_THROBBER (view->tab_icon),
view->icon);
}
+ #endif
if (view->menu_item)
{
GtkWidget* image = katze_item_get_image (view->item);
#ifdef HAVE_GRANITE
g_object_set (midori_view_get_tab (view),
- "loading", view->load_status != MIDORI_LOAD_FINISHED, NULL);
- #endif
+ "working", view->load_status != MIDORI_LOAD_FINISHED, NULL);
+ #else
if (view->tab_icon)
katze_throbber_set_animated (KATZE_THROBBER (view->tab_icon),
view->load_status != MIDORI_LOAD_FINISHED);
+ #endif
}
static gboolean
view->minimized ? 1 : -1);
g_signal_handlers_unblock_by_func (view->item,
midori_view_item_meta_data_changed, view);
+ #ifdef HAVE_GRANITE
+ g_object_set (midori_view_get_tab (view), "label",
+ "fixed", view->minimized, NULL);
+ //view->minimized ? NULL : midori_view_get_display_title(view), NULL);
+ #else
if (view->tab_label)
sokoke_widget_set_visible (view->tab_title, !view->minimized);
+ #endif
break;
case PROP_ZOOM_LEVEL:
midori_view_set_zoom_level (view, g_value_get_float (value));
else if (name == g_intern_string ("close-buttons-on-tabs"))
{
view->close_buttons_on_tabs = g_value_get_boolean (&value);
+ #ifndef HAVE_GRANITE
sokoke_widget_set_visible (view->tab_close,
view->close_buttons_on_tabs);
+ #endif
}
else if (name == g_intern_string ("open-new-pages-in"))
view->open_new_pages_in = g_value_get_enum (&value);
return menu;
}
+#ifdef HAVE_GRANITE
+GraniteWidgetsTab*
+midori_view_get_tab (MidoriView* view)
+{
+ if (view->tab == NULL)
+ view->tab = granite_widgets_tab_new (
+ midori_view_get_display_title (view), G_ICON (view->icon), GTK_WIDGET (view));
+ return view->tab;
+}
+
+void
+midori_view_set_tab (MidoriView* view,
+ GraniteWidgetsTab* tab)
+{
+ g_return_if_fail (view->tab == NULL);
+
+ view->tab = tab;
+ g_object_set (tab,
+ "label", midori_view_get_display_title (view),
+ "icon", G_ICON (view->icon),
+ "page", GTK_WIDGET (view),
+ NULL);
+}
+#else
static gboolean
midori_view_tab_label_button_press_event (GtkWidget* tab_label,
GdkEventButton* event,
}
}
-/**
- * midori_view_get_label_ellipsize:
- * @view: a #MidoriView
- *
- * Determines how labels representing the view should be
- * ellipsized, which is helpful for alternative labels.
- *
- * Return value: how to ellipsize the label
- *
- * Since: 0.1.9
- **/
-PangoEllipsizeMode
-midori_view_get_label_ellipsize (MidoriView* view)
-{
- g_return_val_if_fail (MIDORI_IS_VIEW (view), PANGO_ELLIPSIZE_END);
-
- if (view->tab_label)
- return gtk_label_get_ellipsize (GTK_LABEL (view->tab_title));
- return PANGO_ELLIPSIZE_END;
-}
-
static void midori_view_tab_label_data_received (GtkWidget* widget,
GdkDragContext* context,
gint x,
}
return view->tab_label;
}
+#endif
+
+/**
+ * midori_view_get_label_ellipsize:
+ * @view: a #MidoriView
+ *
+ * Determines how labels representing the view should be
+ * ellipsized, which is helpful for alternative labels.
+ *
+ * Return value: how to ellipsize the label
+ *
+ * Since: 0.1.9
+ **/
+PangoEllipsizeMode
+midori_view_get_label_ellipsize (MidoriView* view)
+{
+ g_return_val_if_fail (MIDORI_IS_VIEW (view), PANGO_ELLIPSIZE_END);
+
+ return view->ellipsize;
+}
static void
midori_view_item_meta_data_changed (KatzeItem* item,