2008-03-10 21:26:09 +00:00
|
|
|
/*
|
2009-04-10 20:29:45 +00:00
|
|
|
Copyright (C) 2007-2009 Christian Dywan <christian@twotoasts.de>
|
2008-03-10 21:26:09 +00:00
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
See the file COPYING for the full license text.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "midori-panel.h"
|
|
|
|
|
2008-10-18 22:15:02 +00:00
|
|
|
#include "midori-view.h"
|
2009-01-08 01:29:07 +00:00
|
|
|
|
2008-07-19 03:05:21 +00:00
|
|
|
#include "compat.h"
|
2009-01-08 01:29:07 +00:00
|
|
|
#include "marshal.h"
|
|
|
|
#include "sokoke.h"
|
2008-07-19 03:05:21 +00:00
|
|
|
|
2008-03-22 02:38:23 +00:00
|
|
|
#include <glib/gi18n.h>
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2009-10-30 20:00:58 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#ifdef HAVE_HILDON_2_2
|
|
|
|
#include <hildon/hildon.h>
|
|
|
|
#endif
|
|
|
|
|
2008-06-19 18:40:37 +00:00
|
|
|
struct _MidoriPanel
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-06-19 18:40:37 +00:00
|
|
|
GtkHBox parent_instance;
|
|
|
|
|
2009-07-26 20:00:10 +00:00
|
|
|
GtkWidget* labelbar;
|
2008-03-10 21:26:09 +00:00
|
|
|
GtkWidget* toolbar;
|
2009-02-22 18:23:45 +00:00
|
|
|
GtkToolItem* button_align;
|
2009-04-25 21:26:54 +00:00
|
|
|
GtkToolItem* button_detach;
|
2008-03-10 21:26:09 +00:00
|
|
|
GtkWidget* toolbar_label;
|
|
|
|
GtkWidget* frame;
|
2008-04-26 00:43:32 +00:00
|
|
|
GtkWidget* toolbook;
|
2008-03-10 21:26:09 +00:00
|
|
|
GtkWidget* notebook;
|
2009-10-31 22:47:44 +00:00
|
|
|
GtkActionGroup* action_group;
|
2008-03-10 21:26:09 +00:00
|
|
|
GtkMenu* menu;
|
2009-02-22 18:23:45 +00:00
|
|
|
|
2009-07-26 20:00:10 +00:00
|
|
|
gboolean show_titles;
|
|
|
|
gboolean show_controls;
|
2009-02-22 18:23:45 +00:00
|
|
|
gboolean right_aligned;
|
2008-03-10 21:26:09 +00:00
|
|
|
};
|
|
|
|
|
2008-11-24 00:41:45 +00:00
|
|
|
struct _MidoriPanelClass
|
|
|
|
{
|
|
|
|
GtkHBoxClass parent_class;
|
|
|
|
|
|
|
|
/* Signals */
|
|
|
|
gboolean
|
|
|
|
(*close) (MidoriPanel* panel);
|
|
|
|
};
|
|
|
|
|
2008-06-19 18:40:37 +00:00
|
|
|
G_DEFINE_TYPE (MidoriPanel, midori_panel, GTK_TYPE_HBOX)
|
2008-03-10 21:26:09 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
|
|
|
|
PROP_SHADOW_TYPE,
|
2009-10-31 22:47:44 +00:00
|
|
|
PROP_ACTION_GROUP,
|
2008-03-10 21:26:09 +00:00
|
|
|
PROP_MENU,
|
2009-02-22 18:23:45 +00:00
|
|
|
PROP_PAGE,
|
2009-07-26 20:00:10 +00:00
|
|
|
PROP_SHOW_TITLES,
|
|
|
|
PROP_SHOW_CONTROLS,
|
2009-02-22 18:23:45 +00:00
|
|
|
PROP_RIGHT_ALIGNED,
|
2008-03-10 21:26:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
CLOSE,
|
|
|
|
SWITCH_PAGE,
|
|
|
|
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
static guint signals[LAST_SIGNAL];
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_panel_finalize (GObject* object);
|
|
|
|
|
|
|
|
static void
|
2008-03-26 23:55:09 +00:00
|
|
|
midori_panel_set_property (GObject* object,
|
|
|
|
guint prop_id,
|
2008-03-10 21:26:09 +00:00
|
|
|
const GValue* value,
|
2008-03-26 23:55:09 +00:00
|
|
|
GParamSpec* pspec);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
|
|
|
static void
|
2008-03-26 23:55:09 +00:00
|
|
|
midori_panel_get_property (GObject* object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue* value,
|
2008-03-10 21:26:09 +00:00
|
|
|
GParamSpec* pspec);
|
|
|
|
|
|
|
|
static gboolean
|
2008-11-24 00:41:45 +00:00
|
|
|
midori_panel_close (MidoriPanel* panel)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
|
|
|
gtk_widget_hide (GTK_WIDGET (panel));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_panel_class_init (MidoriPanelClass* class)
|
|
|
|
{
|
2008-11-16 01:00:17 +00:00
|
|
|
GObjectClass* gobject_class;
|
|
|
|
GParamFlags flags;
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
signals[CLOSE] = g_signal_new (
|
|
|
|
"close",
|
|
|
|
G_TYPE_FROM_CLASS (class),
|
|
|
|
(GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
|
|
|
|
G_STRUCT_OFFSET (MidoriPanelClass, close),
|
|
|
|
g_signal_accumulator_true_handled,
|
|
|
|
NULL,
|
|
|
|
midori_cclosure_marshal_BOOLEAN__VOID,
|
|
|
|
G_TYPE_BOOLEAN, 0);
|
|
|
|
|
|
|
|
signals[SWITCH_PAGE] = g_signal_new (
|
|
|
|
"switch-page",
|
|
|
|
G_TYPE_FROM_CLASS (class),
|
2008-05-22 22:17:10 +00:00
|
|
|
(GSignalFlags)(G_SIGNAL_RUN_LAST),
|
2008-11-24 00:41:45 +00:00
|
|
|
0,
|
2008-03-10 21:26:09 +00:00
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
g_cclosure_marshal_VOID__INT,
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
G_TYPE_INT);
|
|
|
|
|
2008-11-16 01:00:17 +00:00
|
|
|
gobject_class = G_OBJECT_CLASS (class);
|
2008-03-10 21:26:09 +00:00
|
|
|
gobject_class->finalize = midori_panel_finalize;
|
|
|
|
gobject_class->set_property = midori_panel_set_property;
|
|
|
|
gobject_class->get_property = midori_panel_get_property;
|
|
|
|
|
2008-11-24 00:41:45 +00:00
|
|
|
class->close = midori_panel_close;
|
|
|
|
|
2009-01-16 04:19:43 +00:00
|
|
|
flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS;
|
2008-03-10 21:26:09 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_SHADOW_TYPE,
|
|
|
|
g_param_spec_enum (
|
|
|
|
"shadow-type",
|
2008-10-15 01:32:11 +00:00
|
|
|
"Shadow Type",
|
|
|
|
"Appearance of the shadow around each panel",
|
2008-03-10 21:26:09 +00:00
|
|
|
GTK_TYPE_SHADOW_TYPE,
|
|
|
|
GTK_SHADOW_NONE,
|
|
|
|
flags));
|
|
|
|
|
2009-10-31 22:47:44 +00:00
|
|
|
/**
|
|
|
|
* MidoriWebSettings:action-group:
|
|
|
|
*
|
|
|
|
* This is the action group the panel will add actions
|
|
|
|
* corresponding to pages to.
|
|
|
|
*
|
|
|
|
* Since: 0.2.1
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_ACTION_GROUP,
|
|
|
|
g_param_spec_object (
|
|
|
|
"action-group",
|
|
|
|
"Action Group",
|
|
|
|
"The action group the panel will add actions to",
|
|
|
|
GTK_TYPE_ACTION_GROUP,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
2009-07-24 21:55:57 +00:00
|
|
|
/**
|
|
|
|
* MidoriWebSettings:menu:
|
|
|
|
*
|
|
|
|
* This is the menu that holds the panel menu items.
|
|
|
|
*
|
|
|
|
* You shouldn't use this menu or add items.
|
|
|
|
*
|
|
|
|
* Deprecated: 0.1.9
|
|
|
|
*/
|
2008-03-10 21:26:09 +00:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_MENU,
|
|
|
|
g_param_spec_object (
|
|
|
|
"menu",
|
2008-10-15 01:32:11 +00:00
|
|
|
"Menu",
|
|
|
|
"Menu to hold panel items",
|
2008-03-10 21:26:09 +00:00
|
|
|
GTK_TYPE_MENU,
|
2009-01-16 04:19:43 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2008-03-10 21:26:09 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_PAGE,
|
|
|
|
g_param_spec_int (
|
|
|
|
"page",
|
2008-10-15 01:32:11 +00:00
|
|
|
"Page",
|
|
|
|
"The index of the current page",
|
2008-03-10 21:26:09 +00:00
|
|
|
-1, G_MAXINT, -1,
|
|
|
|
flags));
|
2009-02-22 18:23:45 +00:00
|
|
|
|
2009-07-26 20:00:10 +00:00
|
|
|
/**
|
|
|
|
* MidoriWebSettings:show-titles:
|
|
|
|
*
|
|
|
|
* Whether to show panel titles.
|
|
|
|
*
|
|
|
|
* Since: 0.1.9
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_SHOW_TITLES,
|
|
|
|
g_param_spec_boolean (
|
|
|
|
"show-titles",
|
|
|
|
"Show Titles",
|
|
|
|
"Whether to show panel titles",
|
|
|
|
TRUE,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MidoriWebSettings:show-controls:
|
|
|
|
*
|
|
|
|
* Whether to show operating controls.
|
|
|
|
*
|
|
|
|
* Since: 0.1.9
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_SHOW_CONTROLS,
|
|
|
|
g_param_spec_boolean (
|
|
|
|
"show-controls",
|
|
|
|
"Show Controls",
|
|
|
|
"Whether to show operating controls",
|
|
|
|
TRUE,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
2009-02-22 18:23:45 +00:00
|
|
|
/**
|
|
|
|
* MidoriWebSettings:right-aligned:
|
|
|
|
*
|
|
|
|
* Whether to align the panel on the right.
|
|
|
|
*
|
|
|
|
* Since: 0.1.3
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_RIGHT_ALIGNED,
|
|
|
|
g_param_spec_boolean (
|
|
|
|
"right-aligned",
|
|
|
|
"Right aligned",
|
|
|
|
"Whether the panel is aligned to the right",
|
|
|
|
FALSE,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-03-24 13:15:23 +00:00
|
|
|
midori_panel_button_close_clicked_cb (GtkWidget* toolitem,
|
|
|
|
MidoriPanel* panel)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-04-06 23:17:17 +00:00
|
|
|
gboolean return_value;
|
|
|
|
g_signal_emit (panel, signals[CLOSE], 0, &return_value);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2009-04-10 20:29:45 +00:00
|
|
|
static GtkToolItem*
|
|
|
|
midori_panel_construct_tool_item (MidoriPanel* panel,
|
|
|
|
MidoriViewable* viewable);
|
|
|
|
|
|
|
|
static GtkWidget*
|
|
|
|
_midori_panel_child_for_scrolled (MidoriPanel* panel,
|
|
|
|
GtkWidget* scrolled);
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
midori_panel_detached_window_delete_event_cb (GtkWidget* window,
|
|
|
|
GdkEvent* event,
|
|
|
|
MidoriPanel* panel)
|
|
|
|
{
|
|
|
|
/* FIXME: The panel will not end up at its original position */
|
|
|
|
/* FIXME: The menuitem may be mispositioned */
|
|
|
|
GtkWidget* vbox = gtk_bin_get_child (GTK_BIN (window));
|
|
|
|
GtkWidget* scrolled = g_object_get_data (G_OBJECT (window), "scrolled");
|
|
|
|
GtkWidget* toolbar = g_object_get_data (G_OBJECT (scrolled), "panel-toolbar");
|
|
|
|
GtkWidget* menuitem = g_object_get_data (G_OBJECT (scrolled), "panel-menuitem");
|
|
|
|
GtkToolItem* toolitem;
|
2009-04-26 14:57:23 +00:00
|
|
|
gint n;
|
|
|
|
|
2009-04-10 20:29:45 +00:00
|
|
|
g_object_ref (toolbar);
|
|
|
|
gtk_container_remove (GTK_CONTAINER (vbox), toolbar);
|
|
|
|
gtk_container_add (GTK_CONTAINER (panel->toolbook), toolbar);
|
|
|
|
g_object_unref (toolbar);
|
|
|
|
g_object_ref (scrolled);
|
|
|
|
gtk_container_remove (GTK_CONTAINER (vbox), scrolled);
|
2009-04-26 14:57:23 +00:00
|
|
|
n = gtk_notebook_append_page (GTK_NOTEBOOK (panel->notebook), scrolled, NULL);
|
2009-04-10 20:29:45 +00:00
|
|
|
g_object_unref (scrolled);
|
|
|
|
toolitem = midori_panel_construct_tool_item (panel,
|
|
|
|
MIDORI_VIEWABLE (_midori_panel_child_for_scrolled (panel, scrolled)));
|
|
|
|
if (menuitem)
|
|
|
|
{
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
g_object_set_data (G_OBJECT (menuitem), "toolitem", toolitem);
|
|
|
|
}
|
2009-04-26 14:57:23 +00:00
|
|
|
midori_panel_set_current_page (panel, n);
|
2009-04-10 20:29:45 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-04-26 15:11:16 +00:00
|
|
|
static void
|
|
|
|
midori_panel_widget_destroy_cb (GtkWidget* viewable,
|
|
|
|
GtkWidget* widget)
|
|
|
|
{
|
|
|
|
gtk_widget_destroy (widget);
|
|
|
|
g_signal_handlers_disconnect_by_func (
|
|
|
|
viewable, midori_panel_widget_destroy_cb, widget);
|
|
|
|
}
|
|
|
|
|
2009-04-10 20:29:45 +00:00
|
|
|
static void
|
|
|
|
midori_panel_button_detach_clicked_cb (GtkWidget* toolbutton,
|
|
|
|
MidoriPanel* panel)
|
|
|
|
{
|
|
|
|
/* FIXME: What happens when the browser is destroyed? */
|
|
|
|
/* FIXME: What about multiple browsers? */
|
|
|
|
/* FIXME: Should we remember if the child was detached? */
|
|
|
|
gint n = midori_panel_get_current_page (panel);
|
|
|
|
GtkToolItem* toolitem = gtk_toolbar_get_nth_item (
|
|
|
|
GTK_TOOLBAR (panel->toolbar), n);
|
|
|
|
const gchar* title = gtk_tool_button_get_label (GTK_TOOL_BUTTON (toolitem));
|
|
|
|
GtkWidget* toolbar = gtk_notebook_get_nth_page (
|
|
|
|
GTK_NOTEBOOK (panel->toolbook), n);
|
|
|
|
GtkWidget* scrolled = gtk_notebook_get_nth_page (
|
|
|
|
GTK_NOTEBOOK (panel->notebook), n);
|
|
|
|
GtkWidget* menuitem = g_object_get_data (G_OBJECT (scrolled), "panel-menuitem");
|
|
|
|
GtkWidget* vbox = gtk_vbox_new (FALSE, 0);
|
2009-10-30 20:00:58 +00:00
|
|
|
#if HAVE_HILDON
|
|
|
|
GtkWidget* window = hildon_window_new ();
|
|
|
|
hildon_program_add_window (hildon_program_get_instance (), HILDON_WINDOW (window));
|
|
|
|
#else
|
|
|
|
GtkWidget* window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
2009-06-26 19:19:09 +00:00
|
|
|
gtk_window_set_skip_taskbar_hint (GTK_WINDOW (window), TRUE);
|
2009-04-10 20:29:45 +00:00
|
|
|
gtk_window_set_default_size (GTK_WINDOW (window), 250, 400);
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (window),
|
|
|
|
GTK_WINDOW (gtk_widget_get_toplevel (panel->notebook)));
|
2009-10-30 20:00:58 +00:00
|
|
|
#endif
|
2009-04-10 20:29:45 +00:00
|
|
|
gtk_widget_show (vbox);
|
|
|
|
gtk_container_add (GTK_CONTAINER (window), vbox);
|
2009-10-30 20:00:58 +00:00
|
|
|
g_object_set_data (G_OBJECT (window), "scrolled", scrolled);
|
|
|
|
gtk_window_set_title (GTK_WINDOW (window), title);
|
2009-04-10 20:29:45 +00:00
|
|
|
if (menuitem)
|
|
|
|
gtk_widget_hide (menuitem);
|
2009-04-26 15:11:16 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (
|
|
|
|
_midori_panel_child_for_scrolled (panel, scrolled),
|
|
|
|
midori_panel_widget_destroy_cb, toolitem);
|
2009-04-10 20:29:45 +00:00
|
|
|
gtk_container_remove (GTK_CONTAINER (panel->toolbar), GTK_WIDGET (toolitem));
|
|
|
|
g_object_ref (toolbar);
|
|
|
|
gtk_container_remove (GTK_CONTAINER (panel->toolbook), toolbar);
|
2009-10-30 20:00:58 +00:00
|
|
|
#if HAVE_HILDON
|
|
|
|
hildon_window_add_toolbar (HILDON_WINDOW (window), GTK_TOOLBAR (toolbar));
|
|
|
|
#else
|
2009-04-10 20:29:45 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), toolbar, FALSE, FALSE, 0);
|
2009-10-30 20:00:58 +00:00
|
|
|
#endif
|
2009-04-10 20:29:45 +00:00
|
|
|
g_object_unref (toolbar);
|
|
|
|
g_object_set_data (G_OBJECT (scrolled), "panel-toolbar", toolbar);
|
|
|
|
g_object_ref (scrolled);
|
|
|
|
gtk_container_remove (GTK_CONTAINER (panel->notebook), scrolled);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), scrolled, TRUE, TRUE, 0);
|
|
|
|
g_object_unref (scrolled);
|
2009-04-26 14:57:23 +00:00
|
|
|
midori_panel_set_current_page (panel, n > 0 ? n - 1 : 0);
|
|
|
|
toolitem = gtk_toolbar_get_nth_item (GTK_TOOLBAR (panel->toolbar),
|
|
|
|
n > 0 ? n - 1 : 0);
|
2009-04-25 21:26:54 +00:00
|
|
|
if (!gtk_notebook_get_n_pages (GTK_NOTEBOOK (panel->notebook)))
|
|
|
|
gtk_widget_set_sensitive (toolbutton, FALSE);
|
2009-04-10 20:29:45 +00:00
|
|
|
g_signal_connect (window, "delete-event",
|
|
|
|
G_CALLBACK (midori_panel_detached_window_delete_event_cb), panel);
|
|
|
|
gtk_widget_show (window);
|
|
|
|
}
|
|
|
|
|
2009-02-22 18:23:45 +00:00
|
|
|
static void
|
|
|
|
midori_panel_button_align_clicked_cb (GtkWidget* toolitem,
|
|
|
|
MidoriPanel* panel)
|
|
|
|
{
|
|
|
|
midori_panel_set_right_aligned (panel, !panel->right_aligned);
|
|
|
|
}
|
|
|
|
|
2009-01-20 21:17:04 +00:00
|
|
|
static void
|
|
|
|
midori_panel_destroy_cb (MidoriPanel* panel)
|
|
|
|
{
|
|
|
|
/* Destroy pages first, so they don't need special care */
|
|
|
|
gtk_container_foreach (GTK_CONTAINER (panel->notebook),
|
|
|
|
(GtkCallback) gtk_widget_destroy, NULL);
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
midori_panel_init (MidoriPanel* panel)
|
|
|
|
{
|
2008-11-16 01:00:17 +00:00
|
|
|
GtkWidget* vbox;
|
|
|
|
GtkWidget* labelbar;
|
|
|
|
GtkToolItem* toolitem;
|
|
|
|
|
2009-10-31 22:47:44 +00:00
|
|
|
panel->action_group = NULL;
|
2009-07-26 20:00:10 +00:00
|
|
|
panel->show_titles = TRUE;
|
|
|
|
panel->show_controls = TRUE;
|
2009-02-22 18:23:45 +00:00
|
|
|
panel->right_aligned = FALSE;
|
|
|
|
|
2008-06-19 18:40:37 +00:00
|
|
|
/* Create the sidebar */
|
|
|
|
panel->toolbar = gtk_toolbar_new ();
|
|
|
|
gtk_toolbar_set_style (GTK_TOOLBAR (panel->toolbar), GTK_TOOLBAR_BOTH);
|
|
|
|
gtk_toolbar_set_icon_size (GTK_TOOLBAR (panel->toolbar),
|
2008-03-10 21:26:09 +00:00
|
|
|
GTK_ICON_SIZE_BUTTON);
|
2009-10-03 21:59:32 +00:00
|
|
|
g_object_set (panel->toolbar, "orientation", GTK_ORIENTATION_VERTICAL, NULL);
|
2008-06-19 18:40:37 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (panel), panel->toolbar, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show_all (panel->toolbar);
|
2008-11-16 01:00:17 +00:00
|
|
|
vbox = gtk_vbox_new (FALSE, 0);
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (panel), vbox, TRUE, TRUE, 0);
|
|
|
|
|
2008-06-19 18:40:37 +00:00
|
|
|
/* Create the titlebar */
|
2008-11-16 01:00:17 +00:00
|
|
|
labelbar = gtk_toolbar_new ();
|
2009-07-26 20:00:10 +00:00
|
|
|
panel->labelbar = labelbar;
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_toolbar_set_icon_size (GTK_TOOLBAR (labelbar), GTK_ICON_SIZE_MENU);
|
|
|
|
gtk_toolbar_set_style (GTK_TOOLBAR (labelbar), GTK_TOOLBAR_ICONS);
|
2008-11-16 01:00:17 +00:00
|
|
|
toolitem = gtk_tool_item_new ();
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_tool_item_set_expand (toolitem, TRUE);
|
2008-06-19 18:40:37 +00:00
|
|
|
panel->toolbar_label = gtk_label_new (NULL);
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (panel->toolbar_label), 0, 0.5);
|
|
|
|
gtk_container_add (GTK_CONTAINER (toolitem), panel->toolbar_label);
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (toolitem), 6);
|
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (labelbar), toolitem, -1);
|
2009-04-10 20:29:45 +00:00
|
|
|
toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_FULLSCREEN);
|
2009-04-25 21:26:54 +00:00
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (toolitem), FALSE);
|
|
|
|
panel->button_detach = toolitem;
|
2009-07-28 20:36:35 +00:00
|
|
|
gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem),
|
|
|
|
_("Detach chosen panel from the window"));
|
2009-04-10 20:29:45 +00:00
|
|
|
gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (toolitem),
|
2009-06-01 06:23:35 +00:00
|
|
|
_("Detach chosen panel from the window"));
|
2009-04-10 20:29:45 +00:00
|
|
|
g_signal_connect (toolitem, "clicked",
|
|
|
|
G_CALLBACK (midori_panel_button_detach_clicked_cb), panel);
|
|
|
|
#if HAVE_OSX
|
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (labelbar), toolitem, 0);
|
|
|
|
#else
|
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (labelbar), toolitem, -1);
|
|
|
|
#endif
|
2009-02-22 18:23:45 +00:00
|
|
|
toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_GO_FORWARD);
|
2009-07-28 20:36:35 +00:00
|
|
|
gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem),
|
|
|
|
_("Align sidepanel to the right"));
|
2009-02-22 18:23:45 +00:00
|
|
|
gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (toolitem),
|
2009-06-01 06:23:35 +00:00
|
|
|
_("Align sidepanel to the right"));
|
2009-02-22 18:23:45 +00:00
|
|
|
g_signal_connect (toolitem, "clicked",
|
|
|
|
G_CALLBACK (midori_panel_button_align_clicked_cb), panel);
|
|
|
|
#if HAVE_OSX
|
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (labelbar), toolitem, 0);
|
|
|
|
#else
|
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (labelbar), toolitem, -1);
|
|
|
|
#endif
|
|
|
|
panel->button_align = toolitem;
|
2008-03-10 21:26:09 +00:00
|
|
|
toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_CLOSE);
|
2008-03-22 02:38:23 +00:00
|
|
|
gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem), _("Close panel"));
|
2008-06-08 17:45:33 +00:00
|
|
|
gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (toolitem), _("Close panel"));
|
2008-03-10 21:26:09 +00:00
|
|
|
g_signal_connect (toolitem, "clicked",
|
|
|
|
G_CALLBACK (midori_panel_button_close_clicked_cb), panel);
|
2008-10-25 22:54:57 +00:00
|
|
|
#if HAVE_OSX
|
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (labelbar), toolitem, 0);
|
|
|
|
#else
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (labelbar), toolitem, -1);
|
2008-10-25 22:54:57 +00:00
|
|
|
#endif
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), labelbar, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show_all (vbox);
|
|
|
|
|
2008-06-19 18:40:37 +00:00
|
|
|
/* Create the toolbook */
|
|
|
|
panel->toolbook = gtk_notebook_new ();
|
|
|
|
gtk_notebook_set_show_border (GTK_NOTEBOOK (panel->toolbook), FALSE);
|
|
|
|
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (panel->toolbook), FALSE);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), panel->toolbook, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (panel->toolbook);
|
|
|
|
|
|
|
|
/* Create the notebook */
|
|
|
|
panel->notebook = gtk_notebook_new ();
|
|
|
|
gtk_notebook_set_show_border (GTK_NOTEBOOK (panel->notebook), FALSE);
|
|
|
|
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (panel->notebook), FALSE);
|
|
|
|
panel->frame = gtk_frame_new (NULL);
|
|
|
|
gtk_container_add (GTK_CONTAINER (panel->frame), panel->notebook);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), panel->frame, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show_all (panel->frame);
|
2009-01-20 21:17:04 +00:00
|
|
|
|
|
|
|
g_signal_connect (panel, "destroy",
|
|
|
|
G_CALLBACK (midori_panel_destroy_cb), NULL);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_panel_finalize (GObject* object)
|
|
|
|
{
|
|
|
|
G_OBJECT_CLASS (midori_panel_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_panel_set_property (GObject* object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue* value,
|
|
|
|
GParamSpec* pspec)
|
|
|
|
{
|
|
|
|
MidoriPanel* panel = MIDORI_PANEL (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_SHADOW_TYPE:
|
2008-06-19 18:40:37 +00:00
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (panel->frame),
|
2008-03-10 21:26:09 +00:00
|
|
|
g_value_get_enum (value));
|
|
|
|
break;
|
2009-10-31 22:47:44 +00:00
|
|
|
case PROP_ACTION_GROUP:
|
|
|
|
katze_object_assign (panel->action_group, g_value_dup_object (value));
|
|
|
|
break;
|
2008-03-10 21:26:09 +00:00
|
|
|
case PROP_MENU:
|
2008-10-30 01:21:19 +00:00
|
|
|
katze_object_assign (panel->menu, g_value_dup_object (value));
|
2008-03-10 21:26:09 +00:00
|
|
|
break;
|
|
|
|
case PROP_PAGE:
|
2008-03-26 23:55:09 +00:00
|
|
|
midori_panel_set_current_page (panel, g_value_get_int (value));
|
2008-03-10 21:26:09 +00:00
|
|
|
break;
|
2009-07-26 20:00:10 +00:00
|
|
|
case PROP_SHOW_TITLES:
|
|
|
|
panel->show_titles = g_value_get_boolean (value);
|
|
|
|
gtk_toolbar_set_style (GTK_TOOLBAR (panel->toolbar),
|
|
|
|
panel->show_titles ? GTK_TOOLBAR_BOTH : GTK_TOOLBAR_ICONS);
|
|
|
|
break;
|
|
|
|
case PROP_SHOW_CONTROLS:
|
|
|
|
panel->show_controls = g_value_get_boolean (value);
|
|
|
|
sokoke_widget_set_visible (panel->labelbar, panel->show_controls);
|
|
|
|
sokoke_widget_set_visible (panel->toolbar, panel->show_controls);
|
|
|
|
break;
|
2009-02-22 18:23:45 +00:00
|
|
|
case PROP_RIGHT_ALIGNED:
|
|
|
|
midori_panel_set_right_aligned (panel, g_value_get_boolean (value));
|
|
|
|
break;
|
2008-03-10 21:26:09 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_panel_get_property (GObject* object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue* value,
|
|
|
|
GParamSpec* pspec)
|
|
|
|
{
|
|
|
|
MidoriPanel* panel = MIDORI_PANEL (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_SHADOW_TYPE:
|
|
|
|
g_value_set_enum (value,
|
2008-06-19 18:40:37 +00:00
|
|
|
gtk_frame_get_shadow_type (GTK_FRAME (panel->frame)));
|
2008-03-10 21:26:09 +00:00
|
|
|
break;
|
2009-10-31 22:47:44 +00:00
|
|
|
case PROP_ACTION_GROUP:
|
|
|
|
g_value_set_object (value, panel->action_group);
|
|
|
|
break;
|
2008-03-10 21:26:09 +00:00
|
|
|
case PROP_MENU:
|
2008-06-19 18:40:37 +00:00
|
|
|
g_value_set_object (value, panel->menu);
|
2008-03-10 21:26:09 +00:00
|
|
|
break;
|
|
|
|
case PROP_PAGE:
|
2008-03-26 23:55:09 +00:00
|
|
|
g_value_set_int (value, midori_panel_get_current_page (panel));
|
2008-03-10 21:26:09 +00:00
|
|
|
break;
|
2009-07-26 20:00:10 +00:00
|
|
|
case PROP_SHOW_TITLES:
|
|
|
|
g_value_set_boolean (value, panel->show_titles);
|
|
|
|
break;
|
|
|
|
case PROP_SHOW_CONTROLS:
|
|
|
|
g_value_set_boolean (value, panel->show_controls);
|
|
|
|
break;
|
2009-02-22 18:23:45 +00:00
|
|
|
case PROP_RIGHT_ALIGNED:
|
|
|
|
g_value_set_boolean (value, panel->right_aligned);
|
|
|
|
break;
|
2008-03-10 21:26:09 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* midori_panel_new:
|
|
|
|
*
|
|
|
|
* Creates a new empty panel.
|
|
|
|
*
|
|
|
|
* Return value: a new #MidoriPanel
|
|
|
|
**/
|
|
|
|
GtkWidget*
|
|
|
|
midori_panel_new (void)
|
|
|
|
{
|
|
|
|
MidoriPanel* panel = g_object_new (MIDORI_TYPE_PANEL,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
return GTK_WIDGET (panel);
|
|
|
|
}
|
|
|
|
|
2008-10-21 22:01:01 +00:00
|
|
|
/**
|
|
|
|
* midori_panel_set_compact:
|
|
|
|
* @compact: %TRUE if the panel should be compact
|
|
|
|
*
|
|
|
|
* Determines if the panel should be compact.
|
2009-07-26 20:00:10 +00:00
|
|
|
*
|
|
|
|
* Deprecated: 0.1.9
|
2008-10-21 22:01:01 +00:00
|
|
|
**/
|
|
|
|
void
|
|
|
|
midori_panel_set_compact (MidoriPanel* panel,
|
|
|
|
gboolean compact)
|
|
|
|
{
|
|
|
|
g_return_if_fail (MIDORI_IS_PANEL (panel));
|
|
|
|
|
2009-07-26 20:00:10 +00:00
|
|
|
g_object_set (panel, "show-titles", !compact, NULL);
|
2008-10-21 22:01:01 +00:00
|
|
|
}
|
|
|
|
|
2009-02-22 15:03:08 +00:00
|
|
|
/**
|
|
|
|
* midori_panel_set_right_aligned:
|
2009-05-30 22:22:23 +00:00
|
|
|
* @right_aligned: %TRUE if the panel should be aligned to the right
|
2009-02-22 15:03:08 +00:00
|
|
|
*
|
|
|
|
* Determines if the panel should be right aligned.
|
|
|
|
*
|
|
|
|
* Since: 0.1.3
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
midori_panel_set_right_aligned (MidoriPanel* panel,
|
|
|
|
gboolean right_aligned)
|
|
|
|
{
|
|
|
|
GtkWidget* box;
|
|
|
|
|
|
|
|
g_return_if_fail (MIDORI_IS_PANEL (panel));
|
|
|
|
|
|
|
|
box = gtk_widget_get_parent (panel->toolbar);
|
|
|
|
gtk_box_reorder_child (GTK_BOX (box), panel->toolbar,
|
|
|
|
right_aligned ? -1 : 0);
|
2009-02-22 18:23:45 +00:00
|
|
|
gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON (panel->button_align),
|
|
|
|
right_aligned ? GTK_STOCK_GO_BACK : GTK_STOCK_GO_FORWARD);
|
|
|
|
panel->right_aligned = right_aligned;
|
2009-07-28 20:36:35 +00:00
|
|
|
gtk_tool_button_set_label (GTK_TOOL_BUTTON (panel->button_align),
|
|
|
|
!panel->right_aligned ? _("Align sidepanel to the right")
|
|
|
|
: _("Align sidepanel to the left"));
|
2009-06-01 06:23:35 +00:00
|
|
|
gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (panel->button_align),
|
|
|
|
!panel->right_aligned ? _("Align sidepanel to the right")
|
|
|
|
: _("Align sidepanel to the left"));
|
2009-02-22 18:23:45 +00:00
|
|
|
g_object_notify (G_OBJECT (panel), "right-aligned");
|
2009-02-22 15:03:08 +00:00
|
|
|
}
|
|
|
|
|
2009-07-24 21:55:57 +00:00
|
|
|
/* Private function, used by MidoriBrowser */
|
|
|
|
/* static */ GtkWidget*
|
|
|
|
midori_panel_construct_menu_item (MidoriPanel* panel,
|
|
|
|
MidoriViewable* viewable)
|
|
|
|
{
|
2009-10-31 22:47:44 +00:00
|
|
|
GtkAction* action;
|
2009-07-24 21:55:57 +00:00
|
|
|
GtkWidget* menuitem;
|
|
|
|
|
2009-10-31 22:47:44 +00:00
|
|
|
action = g_object_get_data (G_OBJECT (viewable), "midori-panel-action");
|
|
|
|
menuitem = gtk_action_create_menu_item (action);
|
2009-07-24 21:55:57 +00:00
|
|
|
g_object_set_data (G_OBJECT (menuitem), "page", viewable);
|
2009-10-30 20:43:42 +00:00
|
|
|
|
|
|
|
if (GTK_WIDGET_VISIBLE (viewable))
|
|
|
|
gtk_widget_show (menuitem);
|
2009-07-24 21:55:57 +00:00
|
|
|
return menuitem;
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2009-01-20 21:17:04 +00:00
|
|
|
static void
|
|
|
|
midori_panel_viewable_destroy_cb (GtkWidget* viewable,
|
|
|
|
MidoriPanel* panel)
|
|
|
|
{
|
2009-05-03 19:13:54 +00:00
|
|
|
gint i = gtk_notebook_page_num (GTK_NOTEBOOK (panel->notebook),
|
|
|
|
g_object_get_data (G_OBJECT (viewable), "parent"));
|
2009-01-20 21:17:04 +00:00
|
|
|
if (i > -1)
|
2009-05-03 19:13:54 +00:00
|
|
|
gtk_notebook_remove_page (GTK_NOTEBOOK (panel->notebook), i);
|
2009-01-20 21:17:04 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (
|
|
|
|
viewable, midori_panel_viewable_destroy_cb, panel);
|
|
|
|
}
|
|
|
|
|
2009-04-10 20:29:45 +00:00
|
|
|
static GtkToolItem*
|
|
|
|
midori_panel_construct_tool_item (MidoriPanel* panel,
|
|
|
|
MidoriViewable* viewable)
|
|
|
|
{
|
2009-10-31 22:47:44 +00:00
|
|
|
GtkAction* action;
|
|
|
|
GtkWidget* toolitem;
|
|
|
|
|
|
|
|
action = g_object_get_data (G_OBJECT (viewable), "midori-panel-action");
|
|
|
|
toolitem = gtk_action_create_tool_item (action);
|
2009-04-10 20:29:45 +00:00
|
|
|
g_object_set_data (G_OBJECT (toolitem), "page", viewable);
|
2009-10-31 22:47:44 +00:00
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (panel->toolbar), GTK_TOOL_ITEM (toolitem), -1);
|
2009-04-10 20:29:45 +00:00
|
|
|
g_signal_connect (viewable, "destroy",
|
|
|
|
G_CALLBACK (midori_panel_widget_destroy_cb), toolitem);
|
2009-04-25 21:26:54 +00:00
|
|
|
|
|
|
|
if (gtk_notebook_get_n_pages (GTK_NOTEBOOK (panel->notebook)))
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (panel->button_detach), TRUE);
|
|
|
|
|
2009-10-31 22:47:44 +00:00
|
|
|
return GTK_TOOL_ITEM (toolitem);
|
2009-04-10 20:29:45 +00:00
|
|
|
}
|
|
|
|
|
2009-10-22 21:26:35 +00:00
|
|
|
#if !HAVE_HILDON
|
2009-07-26 20:00:10 +00:00
|
|
|
static void
|
|
|
|
midori_panel_show_titles_toggled_cb (GtkWidget* menuitem,
|
|
|
|
MidoriPanel* panel)
|
|
|
|
{
|
|
|
|
g_object_set (panel, "show-titles", !panel->show_titles, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_panel_show_controls_toggled_cb (GtkWidget* menuitem,
|
|
|
|
MidoriPanel* panel)
|
|
|
|
{
|
|
|
|
g_object_set (panel, "show-controls", !panel->show_controls, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_panel_options_clicked_cb (GtkToolItem* toolitem,
|
|
|
|
MidoriPanel* panel)
|
|
|
|
{
|
|
|
|
gint n;
|
|
|
|
GtkWidget* viewable;
|
|
|
|
GtkWidget* menu;
|
|
|
|
GtkWidget* menuitem;
|
|
|
|
|
|
|
|
n = midori_panel_get_current_page (panel);
|
|
|
|
viewable = midori_panel_get_nth_page (panel, n);
|
|
|
|
menu = gtk_menu_new ();
|
|
|
|
menuitem = gtk_check_menu_item_new_with_mnemonic (_("Show panel _titles"));
|
|
|
|
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menuitem),
|
|
|
|
panel->show_titles);
|
|
|
|
g_signal_connect (menuitem, "toggled",
|
|
|
|
G_CALLBACK (midori_panel_show_titles_toggled_cb), panel);
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
menuitem = gtk_check_menu_item_new_with_mnemonic (_("Show operating _controls"));
|
|
|
|
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menuitem),
|
|
|
|
panel->show_controls);
|
|
|
|
g_signal_connect (menuitem, "toggled",
|
|
|
|
G_CALLBACK (midori_panel_show_controls_toggled_cb), panel);
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
g_signal_emit_by_name (viewable, "populate-option-menu", menu);
|
|
|
|
|
|
|
|
katze_widget_popup (GTK_WIDGET (toolitem), GTK_MENU (menu),
|
|
|
|
NULL, SOKOKE_MENU_POSITION_LEFT);
|
|
|
|
}
|
2009-10-30 20:00:58 +00:00
|
|
|
#endif
|
2009-07-26 20:00:10 +00:00
|
|
|
|
2009-10-31 22:47:44 +00:00
|
|
|
static void
|
|
|
|
midori_panel_action_activate_cb (GtkRadioAction* action,
|
|
|
|
MidoriPanel* panel)
|
|
|
|
{
|
|
|
|
gint n = katze_object_get_int (action, "value");
|
|
|
|
|
|
|
|
midori_panel_set_current_page (panel, n);
|
|
|
|
g_signal_emit (panel, signals[SWITCH_PAGE], 0, n);
|
|
|
|
gtk_widget_show (GTK_WIDGET (panel));
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
/**
|
|
|
|
* midori_panel_append_page:
|
|
|
|
* @panel: a #MidoriPanel
|
2008-11-29 15:45:24 +00:00
|
|
|
* @viewable: a viewable widget
|
2008-04-26 00:43:32 +00:00
|
|
|
* @toolbar: a toolbar widget, or %NULL
|
2008-08-17 14:14:15 +00:00
|
|
|
* @stock_id: a stock ID
|
|
|
|
* @label: a string to use as the label
|
2008-03-10 21:26:09 +00:00
|
|
|
*
|
2008-04-26 00:43:32 +00:00
|
|
|
* Appends a new page to the panel. If @toolbar is specified it will
|
2008-11-29 15:45:24 +00:00
|
|
|
* be packed above @viewable.
|
2008-03-10 21:26:09 +00:00
|
|
|
*
|
2009-01-20 21:17:04 +00:00
|
|
|
* Since 0.1.3 destroying the @viewable implicitly removes
|
|
|
|
* the page including the menu and eventual toolbar.
|
|
|
|
*
|
2009-10-30 20:43:42 +00:00
|
|
|
* Since 0.2.1 a hidden @viewable will not be shown in the panel.
|
|
|
|
*
|
2009-10-31 22:47:44 +00:00
|
|
|
* Since 0.2.1 an action with an accelerator is created implicitly.
|
|
|
|
*
|
2008-03-10 21:26:09 +00:00
|
|
|
* In the case of an error, -1 is returned.
|
|
|
|
*
|
|
|
|
* Return value: the index of the new page, or -1
|
|
|
|
**/
|
|
|
|
gint
|
2008-11-29 15:45:24 +00:00
|
|
|
midori_panel_append_page (MidoriPanel* panel,
|
|
|
|
MidoriViewable* viewable)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-08-10 12:17:21 +00:00
|
|
|
GtkWidget* scrolled;
|
|
|
|
GObjectClass* gobject_class;
|
2008-11-24 00:41:45 +00:00
|
|
|
GtkWidget* widget;
|
|
|
|
GtkWidget* toolbar;
|
2009-07-26 20:00:10 +00:00
|
|
|
GtkToolItem* toolitem;
|
2008-11-24 00:41:45 +00:00
|
|
|
guint n;
|
2009-10-31 22:47:44 +00:00
|
|
|
gchar* action_name;
|
|
|
|
GtkAction* action;
|
2008-08-10 12:17:21 +00:00
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
g_return_val_if_fail (MIDORI_IS_PANEL (panel), -1);
|
2008-11-29 15:45:24 +00:00
|
|
|
g_return_val_if_fail (MIDORI_IS_VIEWABLE (viewable), -1);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-11-29 15:45:24 +00:00
|
|
|
if (GTK_IS_SCROLLED_WINDOW (viewable))
|
|
|
|
scrolled = (GtkWidget*)viewable;
|
2008-09-26 21:13:46 +00:00
|
|
|
else
|
|
|
|
{
|
2008-10-18 22:15:02 +00:00
|
|
|
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
|
|
|
|
GTK_POLICY_AUTOMATIC,
|
|
|
|
GTK_POLICY_AUTOMATIC);
|
|
|
|
GTK_WIDGET_SET_FLAGS (scrolled, GTK_CAN_FOCUS);
|
|
|
|
gtk_widget_show (scrolled);
|
2008-11-29 15:45:24 +00:00
|
|
|
gobject_class = G_OBJECT_GET_CLASS (viewable);
|
2008-10-18 22:15:02 +00:00
|
|
|
if (GTK_WIDGET_CLASS (gobject_class)->set_scroll_adjustments_signal)
|
2008-11-29 15:45:24 +00:00
|
|
|
widget = (GtkWidget*)viewable;
|
2008-10-18 22:15:02 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
widget = gtk_viewport_new (NULL, NULL);
|
|
|
|
gtk_widget_show (widget);
|
2008-11-29 15:45:24 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (widget), GTK_WIDGET (viewable));
|
2008-10-18 22:15:02 +00:00
|
|
|
}
|
|
|
|
gtk_container_add (GTK_CONTAINER (scrolled), widget);
|
2008-09-26 21:13:46 +00:00
|
|
|
}
|
2008-06-19 18:40:37 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (panel->notebook), scrolled);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-11-29 15:45:24 +00:00
|
|
|
toolbar = midori_viewable_get_toolbar (viewable);
|
2009-10-30 20:00:58 +00:00
|
|
|
#if !HAVE_HILDON
|
2009-07-26 20:00:10 +00:00
|
|
|
toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_PROPERTIES);
|
|
|
|
gtk_tool_item_set_tooltip_text (toolitem, _("Options"));
|
|
|
|
g_signal_connect (toolitem, "clicked",
|
|
|
|
G_CALLBACK (midori_panel_options_clicked_cb), panel);
|
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, 0);
|
|
|
|
gtk_widget_show (GTK_WIDGET (toolitem));
|
2009-10-30 20:00:58 +00:00
|
|
|
#endif
|
2008-04-26 00:43:32 +00:00
|
|
|
gtk_widget_show (toolbar);
|
2008-06-19 18:40:37 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (panel->toolbook), toolbar);
|
2009-01-20 21:17:04 +00:00
|
|
|
g_signal_connect (viewable, "destroy",
|
|
|
|
G_CALLBACK (midori_panel_widget_destroy_cb), toolbar);
|
2008-04-26 00:43:32 +00:00
|
|
|
|
2009-10-31 22:47:44 +00:00
|
|
|
n = midori_panel_get_n_pages (panel) - 1;
|
|
|
|
/* FIXME: Use something better than the stock ID */
|
|
|
|
action_name = g_strconcat ("PanelPage",
|
|
|
|
midori_viewable_get_stock_id (viewable), NULL);
|
|
|
|
action = (GtkAction*)gtk_radio_action_new (action_name,
|
|
|
|
midori_viewable_get_label (viewable),
|
|
|
|
NULL, midori_viewable_get_stock_id (viewable), n);
|
|
|
|
g_signal_connect (action, "activate",
|
|
|
|
G_CALLBACK (midori_panel_action_activate_cb), panel);
|
|
|
|
if (panel->action_group)
|
|
|
|
{
|
|
|
|
/* FIXME: For some reason the accelerator only works if a menuitem
|
|
|
|
is created, but not before that. */
|
|
|
|
GtkWidget* toplevel = gtk_widget_get_toplevel (GTK_WIDGET (panel));
|
|
|
|
GSList* groups = gtk_accel_groups_from_object (G_OBJECT (toplevel));
|
|
|
|
gtk_action_set_accel_group (action, g_slist_nth_data (groups, 0));
|
|
|
|
gtk_action_group_add_action_with_accel (panel->action_group,
|
|
|
|
action, NULL);
|
|
|
|
}
|
|
|
|
if (n > 0)
|
|
|
|
g_object_set (action, "group", g_object_get_data (
|
|
|
|
G_OBJECT (midori_panel_get_nth_page (panel, 0)),
|
|
|
|
"midori-panel-action"), NULL);
|
|
|
|
g_object_set_data (G_OBJECT (viewable), "midori-panel-action", action);
|
|
|
|
g_free (action_name);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2009-05-03 19:13:54 +00:00
|
|
|
g_object_set_data (G_OBJECT (viewable), "parent", scrolled);
|
2009-10-30 20:43:42 +00:00
|
|
|
toolitem = midori_panel_construct_tool_item (panel, viewable);
|
2009-01-20 21:17:04 +00:00
|
|
|
g_signal_connect (viewable, "destroy",
|
|
|
|
G_CALLBACK (midori_panel_viewable_destroy_cb), panel);
|
|
|
|
|
2009-10-30 20:43:42 +00:00
|
|
|
if (!GTK_WIDGET_VISIBLE (viewable))
|
|
|
|
{
|
|
|
|
gtk_widget_hide (scrolled);
|
|
|
|
gtk_widget_hide (GTK_WIDGET (toolitem));
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* midori_panel_get_current_page:
|
|
|
|
* @panel: a #MidoriPanel
|
|
|
|
*
|
|
|
|
* Retrieves the index of the currently selected page.
|
|
|
|
*
|
|
|
|
* If @panel has no children, -1 is returned.
|
|
|
|
*
|
|
|
|
* Return value: the index of the current page, or -1
|
|
|
|
**/
|
|
|
|
gint
|
|
|
|
midori_panel_get_current_page (MidoriPanel* panel)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (MIDORI_IS_PANEL (panel), -1);
|
|
|
|
|
2008-06-19 18:40:37 +00:00
|
|
|
return gtk_notebook_get_current_page (GTK_NOTEBOOK (panel->notebook));
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2008-03-26 23:55:09 +00:00
|
|
|
static GtkWidget*
|
|
|
|
_midori_panel_child_for_scrolled (MidoriPanel* panel,
|
|
|
|
GtkWidget* scrolled)
|
|
|
|
{
|
2008-10-18 22:15:02 +00:00
|
|
|
GtkWidget* child;
|
|
|
|
|
|
|
|
/* This is a lazy hack, we should have a way of determining
|
|
|
|
whether the scrolled is the actual child. */
|
|
|
|
if (MIDORI_IS_VIEW (scrolled))
|
|
|
|
return scrolled;
|
|
|
|
child = gtk_bin_get_child (GTK_BIN (scrolled));
|
2008-03-26 23:55:09 +00:00
|
|
|
if (GTK_IS_VIEWPORT (child))
|
|
|
|
child = gtk_bin_get_child (GTK_BIN (child));
|
|
|
|
return child;
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
/**
|
|
|
|
* midori_panel_get_nth_page:
|
|
|
|
* @panel: a #MidoriPanel
|
|
|
|
*
|
|
|
|
* Retrieves the child widget of the nth page.
|
|
|
|
*
|
2008-03-26 23:55:09 +00:00
|
|
|
* If @panel has no children, %NULL is returned.
|
2008-03-10 21:26:09 +00:00
|
|
|
*
|
2008-03-26 23:55:09 +00:00
|
|
|
* Return value: the child widget of the new page, or %NULL
|
2008-03-10 21:26:09 +00:00
|
|
|
**/
|
|
|
|
GtkWidget*
|
|
|
|
midori_panel_get_nth_page (MidoriPanel* panel,
|
|
|
|
guint page_num)
|
|
|
|
{
|
2008-10-18 22:15:02 +00:00
|
|
|
GtkWidget* scrolled;
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
g_return_val_if_fail (MIDORI_IS_PANEL (panel), NULL);
|
|
|
|
|
2008-10-18 22:15:02 +00:00
|
|
|
scrolled = gtk_notebook_get_nth_page (
|
2008-06-19 18:40:37 +00:00
|
|
|
GTK_NOTEBOOK (panel->notebook), page_num);
|
2008-03-26 23:55:09 +00:00
|
|
|
if (scrolled)
|
|
|
|
return _midori_panel_child_for_scrolled (panel, scrolled);
|
|
|
|
return NULL;
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* midori_panel_get_n_pages:
|
|
|
|
* @panel: a #MidoriPanel
|
|
|
|
*
|
|
|
|
* Retrieves the number of pages contained in the panel.
|
|
|
|
*
|
|
|
|
* Return value: the number of pages
|
|
|
|
**/
|
|
|
|
guint
|
|
|
|
midori_panel_get_n_pages (MidoriPanel* panel)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (MIDORI_IS_PANEL (panel), 0);
|
|
|
|
|
2008-06-19 18:40:37 +00:00
|
|
|
return gtk_notebook_get_n_pages (GTK_NOTEBOOK (panel->notebook));
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GtkWidget*
|
|
|
|
_midori_panel_scrolled_for_child (MidoriPanel* panel,
|
|
|
|
GtkWidget* child)
|
|
|
|
{
|
2008-10-18 22:15:02 +00:00
|
|
|
GtkWidget* scrolled;
|
|
|
|
|
|
|
|
/* This is a lazy hack, we should have a way of determining
|
|
|
|
whether the scrolled is the actual child. */
|
|
|
|
if (MIDORI_IS_VIEW (child))
|
|
|
|
return child;
|
|
|
|
scrolled = gtk_widget_get_parent (GTK_WIDGET (child));
|
2008-03-10 21:26:09 +00:00
|
|
|
if (GTK_IS_VIEWPORT (scrolled))
|
|
|
|
scrolled = gtk_widget_get_parent (scrolled);
|
|
|
|
return scrolled;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* midori_panel_page_num:
|
|
|
|
* @panel: a #MidoriPanel
|
|
|
|
*
|
|
|
|
* Retrieves the index of the page associated to @widget.
|
|
|
|
*
|
|
|
|
* If @panel has no children, -1 is returned.
|
|
|
|
*
|
|
|
|
* Return value: the index of page associated to @widget, or -1
|
|
|
|
**/
|
|
|
|
gint
|
|
|
|
midori_panel_page_num (MidoriPanel* panel,
|
|
|
|
GtkWidget* child)
|
|
|
|
{
|
2008-11-16 01:00:17 +00:00
|
|
|
GtkWidget* scrolled;
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
g_return_val_if_fail (MIDORI_IS_PANEL (panel), -1);
|
2008-11-16 01:00:17 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_WIDGET (child), -1);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-11-16 01:00:17 +00:00
|
|
|
scrolled = _midori_panel_scrolled_for_child (panel, child);
|
2008-06-19 18:40:37 +00:00
|
|
|
return gtk_notebook_page_num (GTK_NOTEBOOK (panel->notebook), scrolled);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* midori_panel_set_current_page:
|
|
|
|
* @panel: a #MidoriPanel
|
|
|
|
* @n: index of the page to switch to, or -1 to mean the last page
|
|
|
|
*
|
|
|
|
* Switches to the page with the given index.
|
|
|
|
*
|
|
|
|
* The child must be visible, otherwise the underlying GtkNotebook will
|
|
|
|
* silently ignore the attempt to switch the page.
|
2009-06-22 22:25:09 +00:00
|
|
|
*
|
|
|
|
* Since 0.1.8 the "page" property is notifying changes.
|
2009-10-30 20:43:42 +00:00
|
|
|
*
|
|
|
|
* Since 0.2.1 switching to hidden pages fails silently.
|
2008-03-10 21:26:09 +00:00
|
|
|
**/
|
|
|
|
void
|
|
|
|
midori_panel_set_current_page (MidoriPanel* panel,
|
|
|
|
gint n)
|
|
|
|
{
|
2008-11-29 15:45:24 +00:00
|
|
|
GtkWidget* viewable;
|
2008-11-16 01:00:17 +00:00
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
g_return_if_fail (MIDORI_IS_PANEL (panel));
|
|
|
|
|
2008-11-29 15:45:24 +00:00
|
|
|
if ((viewable = midori_panel_get_nth_page (panel, n)))
|
2008-03-26 23:55:09 +00:00
|
|
|
{
|
2008-11-29 15:45:24 +00:00
|
|
|
const gchar* label;
|
|
|
|
|
2009-10-30 20:43:42 +00:00
|
|
|
if (!GTK_WIDGET_VISIBLE (viewable))
|
|
|
|
return;
|
2009-06-22 22:25:09 +00:00
|
|
|
gtk_notebook_set_current_page (GTK_NOTEBOOK (panel->toolbook), n);
|
|
|
|
gtk_notebook_set_current_page (GTK_NOTEBOOK (panel->notebook), n);
|
2008-11-29 15:45:24 +00:00
|
|
|
label = midori_viewable_get_label (MIDORI_VIEWABLE (viewable));
|
2008-06-19 18:40:37 +00:00
|
|
|
g_object_set (panel->toolbar_label, "label", label, NULL);
|
2009-06-22 22:25:09 +00:00
|
|
|
g_object_notify (G_OBJECT (panel), "page");
|
2008-03-26 23:55:09 +00:00
|
|
|
}
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
2008-11-24 00:41:45 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GtkAlignment parent_instance;
|
|
|
|
|
|
|
|
gchar* label;
|
|
|
|
gchar* stock_id;
|
|
|
|
GtkWidget* toolbar;
|
2008-11-29 15:45:24 +00:00
|
|
|
} MidoriDummyViewable;
|
2008-11-24 00:41:45 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GtkAlignmentClass parent_class;
|
2008-11-29 15:45:24 +00:00
|
|
|
} MidoriDummyViewableClass;
|
2008-11-24 00:41:45 +00:00
|
|
|
|
2009-01-09 21:54:40 +00:00
|
|
|
GType midori_dummy_viewable_get_type (void) G_GNUC_CONST;
|
2008-11-29 15:45:24 +00:00
|
|
|
#define MIDORI_TYPE_DUMMY_VIEWABLE (midori_dummy_viewable_get_type ())
|
|
|
|
#define MIDORI_DUMMY_VIEWABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
|
|
|
|
MIDORI_TYPE_DUMMY_VIEWABLE, MidoriDummyViewable))
|
|
|
|
#define MIDORI_IS_DUMMY_VIEWABLE(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIDORI_TYPE_DUMMY_VIEWABLE))
|
2008-11-24 00:41:45 +00:00
|
|
|
|
|
|
|
static void
|
2008-11-29 15:45:24 +00:00
|
|
|
midori_dummy_viewable_iface_init (MidoriViewableIface* iface);
|
2008-11-24 00:41:45 +00:00
|
|
|
|
|
|
|
static void
|
2008-11-29 15:45:24 +00:00
|
|
|
midori_dummy_viewable_finalize (GObject* object);
|
2008-11-24 00:41:45 +00:00
|
|
|
|
2008-11-29 15:45:24 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (MidoriDummyViewable, midori_dummy_viewable,
|
|
|
|
GTK_TYPE_ALIGNMENT,
|
|
|
|
G_IMPLEMENT_INTERFACE (MIDORI_TYPE_VIEWABLE,
|
|
|
|
midori_dummy_viewable_iface_init));
|
2008-11-24 00:41:45 +00:00
|
|
|
|
|
|
|
static void
|
2008-11-29 15:45:24 +00:00
|
|
|
midori_dummy_viewable_class_init (MidoriDummyViewableClass* class)
|
2008-11-24 00:41:45 +00:00
|
|
|
{
|
|
|
|
GObjectClass* gobject_class;
|
|
|
|
|
|
|
|
gobject_class = G_OBJECT_CLASS (class);
|
2008-11-29 15:45:24 +00:00
|
|
|
gobject_class->finalize = midori_dummy_viewable_finalize;
|
2008-11-24 00:41:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const gchar*
|
2008-11-29 15:45:24 +00:00
|
|
|
midori_dummy_viewable_get_label (MidoriViewable* viewable)
|
2008-11-24 00:41:45 +00:00
|
|
|
{
|
2008-11-29 15:45:24 +00:00
|
|
|
return MIDORI_DUMMY_VIEWABLE (viewable)->label;
|
2008-11-24 00:41:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const gchar*
|
2008-11-29 15:45:24 +00:00
|
|
|
midori_dummy_viewable_get_stock_id (MidoriViewable* viewable)
|
2008-11-24 00:41:45 +00:00
|
|
|
{
|
2008-11-29 15:45:24 +00:00
|
|
|
return MIDORI_DUMMY_VIEWABLE (viewable)->stock_id;
|
2008-11-24 00:41:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GtkWidget*
|
2008-11-29 15:45:24 +00:00
|
|
|
midori_dummy_viewable_get_toolbar (MidoriViewable* viewable)
|
2008-11-24 00:41:45 +00:00
|
|
|
{
|
2008-11-29 15:45:24 +00:00
|
|
|
return MIDORI_DUMMY_VIEWABLE (viewable)->toolbar;
|
2008-11-24 00:41:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-11-29 15:45:24 +00:00
|
|
|
midori_dummy_viewable_iface_init (MidoriViewableIface* iface)
|
2008-11-24 00:41:45 +00:00
|
|
|
{
|
2008-11-29 15:45:24 +00:00
|
|
|
iface->get_stock_id = midori_dummy_viewable_get_stock_id;
|
|
|
|
iface->get_label = midori_dummy_viewable_get_label;
|
|
|
|
iface->get_toolbar = midori_dummy_viewable_get_toolbar;
|
2008-11-24 00:41:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-11-29 15:45:24 +00:00
|
|
|
midori_dummy_viewable_init (MidoriDummyViewable* viewable)
|
2008-11-24 00:41:45 +00:00
|
|
|
{
|
2008-11-29 15:45:24 +00:00
|
|
|
viewable->stock_id = NULL;
|
|
|
|
viewable->label = NULL;
|
|
|
|
viewable->toolbar = NULL;
|
2008-11-24 00:41:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-11-29 15:45:24 +00:00
|
|
|
midori_dummy_viewable_finalize (GObject* object)
|
2008-11-24 00:41:45 +00:00
|
|
|
{
|
2008-11-29 15:45:24 +00:00
|
|
|
MidoriDummyViewable* viewable = MIDORI_DUMMY_VIEWABLE (object);
|
2008-11-24 00:41:45 +00:00
|
|
|
|
2008-11-29 15:45:24 +00:00
|
|
|
katze_assign (viewable->stock_id, NULL);
|
|
|
|
katze_assign (viewable->label, NULL);
|
2008-11-24 00:41:45 +00:00
|
|
|
|
2008-11-29 15:45:24 +00:00
|
|
|
G_OBJECT_CLASS (midori_dummy_viewable_parent_class)->finalize (object);
|
2008-11-24 00:41:45 +00:00
|
|
|
}
|
|
|
|
|
2009-02-19 22:30:08 +00:00
|
|
|
/* static */ GtkWidget*
|
2008-11-29 15:45:24 +00:00
|
|
|
midori_dummy_viewable_new (const gchar* stock_id,
|
2009-01-20 21:17:04 +00:00
|
|
|
const gchar* label,
|
|
|
|
GtkWidget* toolbar)
|
2008-11-24 00:41:45 +00:00
|
|
|
{
|
2008-11-29 15:45:24 +00:00
|
|
|
GtkWidget* viewable = g_object_new (MIDORI_TYPE_DUMMY_VIEWABLE, NULL);
|
2008-11-24 00:41:45 +00:00
|
|
|
|
2008-11-29 15:45:24 +00:00
|
|
|
MIDORI_DUMMY_VIEWABLE (viewable)->stock_id = g_strdup (stock_id);
|
|
|
|
MIDORI_DUMMY_VIEWABLE (viewable)->label = g_strdup (label);
|
|
|
|
MIDORI_DUMMY_VIEWABLE (viewable)->toolbar = toolbar;
|
2008-11-24 00:41:45 +00:00
|
|
|
|
2008-11-29 15:45:24 +00:00
|
|
|
return viewable;
|
2008-11-24 00:41:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* midori_panel_append_widget:
|
|
|
|
* @panel: a #MidoriPanel
|
|
|
|
* @widget: the child widget
|
|
|
|
* @stock_id: a stock ID
|
|
|
|
* @label: a string to use as the label, or %NULL
|
|
|
|
* @toolbar: a toolbar widget, or %NULL
|
|
|
|
*
|
|
|
|
* Appends an arbitrary widget to the panel by wrapping it
|
2008-11-29 15:45:24 +00:00
|
|
|
* in a #MidoriViewable created on the fly.
|
2008-11-24 00:41:45 +00:00
|
|
|
*
|
2008-11-29 15:45:24 +00:00
|
|
|
* Actually implementing #MidoriViewable instead of using
|
2008-11-24 00:41:45 +00:00
|
|
|
* this convenience is recommended.
|
|
|
|
*
|
2009-01-20 21:17:04 +00:00
|
|
|
* Since 0.1.3 destroying the @widget implicitly removes
|
|
|
|
* the page including the menu and eventual toolbar.
|
|
|
|
*
|
2008-11-24 00:41:45 +00:00
|
|
|
* In the case of an error, -1 is returned.
|
|
|
|
*
|
|
|
|
* Return value: the index of the new page, or -1
|
|
|
|
**/
|
|
|
|
gint
|
|
|
|
midori_panel_append_widget (MidoriPanel* panel,
|
|
|
|
GtkWidget* widget,
|
|
|
|
const gchar* stock_id,
|
|
|
|
const gchar* label,
|
|
|
|
GtkWidget* toolbar)
|
|
|
|
{
|
2008-11-29 15:45:24 +00:00
|
|
|
GtkWidget* viewable;
|
2008-11-24 00:41:45 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (MIDORI_IS_PANEL (panel), -1);
|
|
|
|
g_return_val_if_fail (GTK_IS_WIDGET (widget), -1);
|
|
|
|
|
|
|
|
g_return_val_if_fail (stock_id != NULL, -1);
|
|
|
|
g_return_val_if_fail (!toolbar || GTK_IS_WIDGET (toolbar), -1);
|
|
|
|
|
2008-11-29 15:45:24 +00:00
|
|
|
viewable = midori_dummy_viewable_new (stock_id, label, toolbar);
|
|
|
|
gtk_widget_show (viewable);
|
|
|
|
gtk_container_add (GTK_CONTAINER (viewable), widget);
|
2009-01-20 21:17:04 +00:00
|
|
|
g_signal_connect (widget, "destroy",
|
|
|
|
G_CALLBACK (midori_panel_widget_destroy_cb), viewable);
|
2008-11-29 15:45:24 +00:00
|
|
|
return midori_panel_append_page (panel, MIDORI_VIEWABLE (viewable));
|
2008-11-24 00:41:45 +00:00
|
|
|
}
|