diff options
Diffstat (limited to 'shell/e-shell-window.c')
-rw-r--r-- | shell/e-shell-window.c | 135 |
1 files changed, 95 insertions, 40 deletions
diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c index 5513efbe95..7970f5b015 100644 --- a/shell/e-shell-window.c +++ b/shell/e-shell-window.c @@ -19,10 +19,17 @@ * */ +/** + * SECTION: e-shell-window + * @short_description: the main window + * @include: shell/e-shell-window.h + **/ + #include "e-shell-window-private.h" #include <gconf/gconf-client.h> +#include <e-util/e-extensible.h> #include <e-util/e-plugin-ui.h> #include <e-util/e-util-private.h> @@ -45,9 +52,12 @@ enum { LAST_SIGNAL }; -static gpointer parent_class; static gulong signals[LAST_SIGNAL]; +G_DEFINE_TYPE_WITH_CODE ( + EShellWindow, e_shell_window, GTK_TYPE_WINDOW, + G_IMPLEMENT_INTERFACE (E_TYPE_EXTENSIBLE, NULL)) + static void shell_window_menubar_update_new_menu (EShellWindow *shell_window) { @@ -299,7 +309,7 @@ shell_window_dispose (GObject *object) e_shell_window_private_dispose (E_SHELL_WINDOW (object)); /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (parent_class)->dispose (object); + G_OBJECT_CLASS (e_shell_window_parent_class)->dispose (object); } static void @@ -308,13 +318,21 @@ shell_window_finalize (GObject *object) e_shell_window_private_finalize (E_SHELL_WINDOW (object)); /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (e_shell_window_parent_class)->finalize (object); } static void shell_window_constructed (GObject *object) { - e_shell_window_private_constructed (E_SHELL_WINDOW (object)); + EShellWindow *shell_window = E_SHELL_WINDOW (object); + + e_shell_window_private_constructed (shell_window); + + e_extensible_load_extensions (E_EXTENSIBLE (object)); + + if (e_shell_get_meego_mode (shell_window->priv->shell) && + e_shell_get_small_screen_mode (shell_window->priv->shell)) + gtk_window_set_decorated (GTK_WINDOW (object), FALSE); } static GtkWidget * @@ -326,6 +344,23 @@ shell_window_construct_menubar (EShellWindow *shell_window) shell_window, "/main-menu"); gtk_widget_show (main_menu); + if (e_shell_get_small_screen_mode (shell_window->priv->shell)) { + GtkWidget *parent, *child; + + parent = gtk_widget_get_parent (main_menu); + g_object_ref (parent); + gtk_container_remove ((GtkContainer *)parent, main_menu); + child = gtk_hbox_new (FALSE, 0); + gtk_box_pack_start ((GtkBox *)child, main_menu, TRUE, TRUE, 0); + gtk_widget_show (child); + gtk_container_add ((GtkContainer *)parent, child); + shell_window->priv->menubar_box = child; + + e_mutual_binding_new (main_menu, "visible", + child, "visible"); + main_menu = child; + } + g_signal_connect ( shell_window, "notify::active-view", G_CALLBACK (shell_window_menubar_update_new_menu), NULL); @@ -333,21 +368,34 @@ shell_window_construct_menubar (EShellWindow *shell_window) return main_menu; } +GtkWidget * +e_shell_window_get_menu_bar_box (EShellWindow *shell_window) +{ + return shell_window->priv->menubar_box; +} + static GtkWidget * shell_window_construct_toolbar (EShellWindow *shell_window) { GtkUIManager *ui_manager; - GtkWidget *main_toolbar; + GtkWidget *toolbar; + GtkWidget *box; GtkToolItem *item; ui_manager = e_shell_window_get_ui_manager (shell_window); - main_toolbar = e_shell_window_get_managed_widget ( - shell_window, "/main-toolbar"); + box = gtk_hbox_new (FALSE, 0); + gtk_widget_show (box); e_binding_new ( shell_window, "toolbar-visible", - main_toolbar, "visible"); + box, "visible"); + + toolbar = e_shell_window_get_managed_widget ( + shell_window, "/main-toolbar"); + + if (e_shell_get_meego_mode (shell_window->priv->shell)) + gtk_widget_set_name (GTK_WIDGET (toolbar), "MeeGoToolbar"); /* XXX Having this separator in the UI definition doesn't work * because GtkUIManager is unaware of the "New" button, so @@ -360,7 +408,7 @@ shell_window_construct_toolbar (EShellWindow *shell_window) * convinced having it proxy some new type of GtkAction * is worth the extra effort. */ item = gtk_separator_tool_item_new (); - gtk_toolbar_insert (GTK_TOOLBAR (main_toolbar), item, 0); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, 0); gtk_widget_show (GTK_WIDGET (item)); item = e_menu_tool_button_new (_("New")); @@ -369,7 +417,7 @@ shell_window_construct_toolbar (EShellWindow *shell_window) GTK_WIDGET (item), "clicked", gtk_ui_manager_get_accel_group (ui_manager), GDK_N, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); - gtk_toolbar_insert (GTK_TOOLBAR (main_toolbar), item, 0); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, 0); gtk_widget_show (GTK_WIDGET (item)); g_signal_connect ( @@ -377,7 +425,23 @@ shell_window_construct_toolbar (EShellWindow *shell_window) G_CALLBACK (shell_window_toolbar_update_new_menu), GTK_MENU_TOOL_BUTTON (item)); - return main_toolbar; + gtk_box_pack_start (GTK_BOX (box), toolbar, TRUE, TRUE, 0); + + toolbar = e_shell_window_get_managed_widget ( + shell_window, "/search-toolbar"); + gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), FALSE); + gtk_box_pack_start (GTK_BOX (box), toolbar, FALSE, FALSE, 0); + if (e_shell_get_meego_mode (shell_window->priv->shell)) + gtk_widget_set_name (GTK_WIDGET (toolbar), "MeeGoToolbar"); + + toolbar = e_shell_window_get_managed_widget ( + shell_window, "/close-toolbar"); + gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), FALSE); + gtk_box_pack_start (GTK_BOX (box), toolbar, FALSE, FALSE, 0); + if (e_shell_get_meego_mode (shell_window->priv->shell)) + gtk_widget_set_name (GTK_WIDGET (toolbar), "MeeGoToolbar"); + + return box; } static GtkWidget * @@ -582,11 +646,24 @@ shell_window_create_shell_view (EShellWindow *shell_window, } static void -shell_window_class_init (EShellWindowClass *class) +shell_window_realize (GtkWidget *widget) +{ + EShellWindow *shell_window; + + shell_window = E_SHELL_WINDOW (widget); + e_shell_adapt_window_size (shell_window->priv->shell, + GTK_WINDOW (widget)); + + /* Chain up to parent's dispose() method. */ + GTK_WIDGET_CLASS (e_shell_window_parent_class)->realize (widget); +} + +static void +e_shell_window_class_init (EShellWindowClass *class) { GObjectClass *object_class; + GtkWidgetClass *widget_class; - parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (EShellWindowPrivate)); object_class = G_OBJECT_CLASS (class); @@ -596,6 +673,9 @@ shell_window_class_init (EShellWindowClass *class) object_class->finalize = shell_window_finalize; object_class->constructed = shell_window_constructed; + widget_class = GTK_WIDGET_CLASS (class); + widget_class->realize = shell_window_realize; + class->construct_menubar = shell_window_construct_menubar; class->construct_toolbar = shell_window_construct_toolbar; class->construct_sidebar = shell_window_construct_sidebar; @@ -603,6 +683,7 @@ shell_window_class_init (EShellWindowClass *class) class->construct_taskbar = shell_window_construct_taskbar; class->create_shell_view = shell_window_create_shell_view; + /** * EShellWindow:active-view * @@ -779,39 +860,13 @@ shell_window_class_init (EShellWindowClass *class) } static void -shell_window_init (EShellWindow *shell_window) +e_shell_window_init (EShellWindow *shell_window) { shell_window->priv = E_SHELL_WINDOW_GET_PRIVATE (shell_window); e_shell_window_private_init (shell_window); } -GType -e_shell_window_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - const GTypeInfo type_info = { - sizeof (EShellWindowClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) shell_window_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EShellWindow), - 0, /* n_preallocs */ - (GInstanceInitFunc) shell_window_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - GTK_TYPE_WINDOW, "EShellWindow", &type_info, 0); - } - - return type; -} - /** * e_shell_window_new: * @shell: an #EShell |