(GSourceFunc)midori_browser_panel_timeout, hpaned, NULL);
}
+static void
+midori_panel_notify_right_aligned_cb (MidoriPanel* panel,
+ GParamSpec* pspec,
+ MidoriBrowser* browser)
+{
+ gboolean right_aligned = katze_object_get_boolean (panel, "right-aligned");
+ GtkWidget* hpaned = gtk_widget_get_parent (browser->panel);
+ GtkWidget* vpaned = gtk_widget_get_parent (browser->notebook);
+
+ g_object_set (browser->settings, "right-align-sidepanel", right_aligned, NULL);
+
+ g_object_ref (browser->panel);
+ g_object_ref (vpaned);
+ gtk_container_remove (GTK_CONTAINER (hpaned), browser->panel);
+ gtk_container_remove (GTK_CONTAINER (hpaned), vpaned);
+ if (right_aligned)
+ {
+ gtk_paned_pack1 (GTK_PANED (hpaned), vpaned, FALSE, FALSE);
+ gtk_paned_pack2 (GTK_PANED (hpaned), browser->panel, FALSE, FALSE);
+ }
+ else
+ {
+ gtk_paned_pack1 (GTK_PANED (hpaned), browser->panel, FALSE, FALSE);
+ gtk_paned_pack2 (GTK_PANED (hpaned), vpaned, FALSE, FALSE);
+ }
+ g_object_unref (browser->panel);
+ g_object_unref (vpaned);
+}
+
static gboolean
midori_panel_close_cb (MidoriPanel* panel,
MidoriBrowser* browser)
gtk_box_pack_start (GTK_BOX (vbox), hpaned, TRUE, TRUE, 0);
gtk_widget_show (hpaned);
browser->panel = g_object_new (MIDORI_TYPE_PANEL,
- "shadow-type", GTK_SHADOW_IN,
- "menu", browser->menu_tools,
- NULL);
+ "shadow-type", GTK_SHADOW_IN,
+ "menu", browser->menu_tools,
+ NULL);
+ g_signal_connect (browser->panel, "notify::right-aligned",
+ G_CALLBACK (midori_panel_notify_right_aligned_cb), browser);
g_signal_connect (browser->panel, "close",
G_CALLBACK (midori_panel_close_cb), browser);
gtk_paned_pack1 (GTK_PANED (hpaned), browser->panel, FALSE, FALSE);
gint last_window_width, last_window_height;
MidoriWindowState last_window_state;
gboolean compact_sidepanel, right_align_sidepanel;
- GtkWidget* hpaned, *vpaned;
gint last_panel_position, last_panel_page;
gboolean show_menubar, show_navigationbar, show_bookmarkbar;
gboolean show_panel, show_statusbar;
}
midori_panel_set_compact (MIDORI_PANEL (browser->panel), compact_sidepanel);
- hpaned = gtk_widget_get_parent (browser->panel);
- vpaned = gtk_widget_get_parent (browser->notebook);
- g_object_ref (browser->panel);
- g_object_ref (vpaned);
- gtk_container_remove (GTK_CONTAINER (hpaned), browser->panel);
- gtk_container_remove (GTK_CONTAINER (hpaned), vpaned);
- if (right_align_sidepanel)
- {
- gtk_paned_pack1 (GTK_PANED (hpaned), vpaned, FALSE, FALSE);
- gtk_paned_pack2 (GTK_PANED (hpaned), browser->panel, FALSE, FALSE);
- }
- else
- {
- gtk_paned_pack1 (GTK_PANED (hpaned), browser->panel, FALSE, FALSE);
- gtk_paned_pack2 (GTK_PANED (hpaned), vpaned, FALSE, FALSE);
- }
- g_object_unref (browser->panel);
- g_object_unref (vpaned);
midori_panel_set_right_aligned (MIDORI_PANEL (browser->panel),
right_align_sidepanel);
gtk_paned_set_position (GTK_PANED (gtk_widget_get_parent (browser->panel)),
GtkHBox parent_instance;
GtkWidget* toolbar;
+ GtkToolItem* button_align;
GtkWidget* toolbar_label;
GtkWidget* frame;
GtkWidget* toolbook;
GtkWidget* notebook;
GSList* group;
GtkMenu* menu;
+
+ gboolean right_aligned;
};
struct _MidoriPanelClass
PROP_SHADOW_TYPE,
PROP_MENU,
- PROP_PAGE
+ PROP_PAGE,
+ PROP_RIGHT_ALIGNED,
};
enum {
"The index of the current page",
-1, G_MAXINT, -1,
flags));
+
+ /**
+ * 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));
}
static void
g_signal_emit (panel, signals[CLOSE], 0, &return_value);
}
+static void
+midori_panel_button_align_clicked_cb (GtkWidget* toolitem,
+ MidoriPanel* panel)
+{
+ midori_panel_set_right_aligned (panel, !panel->right_aligned);
+}
+
static void
midori_panel_destroy_cb (MidoriPanel* panel)
{
GtkWidget* labelbar;
GtkToolItem* toolitem;
+ panel->right_aligned = FALSE;
+
/* Create the sidebar */
panel->toolbar = gtk_toolbar_new ();
gtk_toolbar_set_style (GTK_TOOLBAR (panel->toolbar), GTK_TOOLBAR_BOTH);
gtk_container_add (GTK_CONTAINER (toolitem), panel->toolbar_label);
gtk_container_set_border_width (GTK_CONTAINER (toolitem), 6);
gtk_toolbar_insert (GTK_TOOLBAR (labelbar), toolitem, -1);
+ toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_GO_FORWARD);
+ gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem),
+ _("Align sidepanel on the right"));
+ gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (toolitem),
+ _("Whether to align the sidepanel on the right"));
+ 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;
toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_CLOSE);
gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem), _("Close panel"));
gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (toolitem), _("Close panel"));
case PROP_PAGE:
midori_panel_set_current_page (panel, g_value_get_int (value));
break;
+ case PROP_RIGHT_ALIGNED:
+ midori_panel_set_right_aligned (panel, g_value_get_boolean (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
case PROP_PAGE:
g_value_set_int (value, midori_panel_get_current_page (panel));
break;
+ case PROP_RIGHT_ALIGNED:
+ g_value_set_boolean (value, panel->right_aligned);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
box = gtk_widget_get_parent (panel->toolbar);
gtk_box_reorder_child (GTK_BOX (box), panel->toolbar,
right_aligned ? -1 : 0);
+ 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;
+ g_object_notify (G_OBJECT (panel), "right-aligned");
}
static void