From a75ac70bbe7c1100c9905ff0baa990f9a64f4253 Mon Sep 17 00:00:00 2001 From: Jussi Kukkonen Date: Thu, 25 Mar 2010 11:50:24 +0200 Subject: [PATCH] gtk-ui: start using GtkToolbar for Meego window This gets rid of MuxWindow (and the related icon code and images) for good: Now a specially named GtkToolbar and buttons inside it get a special treatment from meego gtk theme engine, and end up looking like Mx window title bar The meego build will look a bit odd with other gtk themes, though --- src/gtk-ui/Makefile.am | 3 +- src/gtk-ui/close.png | Bin 631 -> 0 bytes src/gtk-ui/close_hover.png | Bin 767 -> 0 bytes src/gtk-ui/mux-icon-button.c | 283 ------------ src/gtk-ui/mux-icon-button.h | 71 --- src/gtk-ui/mux-window.c | 641 --------------------------- src/gtk-ui/mux-window.h | 92 ---- src/gtk-ui/settings.png | Bin 1094 -> 0 bytes src/gtk-ui/settings_hover.png | Bin 1389 -> 0 bytes src/gtk-ui/sync-ui.c | 284 ++++++++---- src/gtk-ui/sync-ui.rc | 12 +- src/gtk-ui/ui.glade | 794 ++++++++++++++++++---------------- 12 files changed, 634 insertions(+), 1546 deletions(-) delete mode 100644 src/gtk-ui/close.png delete mode 100644 src/gtk-ui/close_hover.png delete mode 100644 src/gtk-ui/mux-icon-button.c delete mode 100644 src/gtk-ui/mux-icon-button.h delete mode 100644 src/gtk-ui/mux-window.c delete mode 100644 src/gtk-ui/mux-window.h delete mode 100644 src/gtk-ui/settings.png delete mode 100644 src/gtk-ui/settings_hover.png diff --git a/src/gtk-ui/Makefile.am b/src/gtk-ui/Makefile.am index e791b8a2..a6cc77f8 100644 --- a/src/gtk-ui/Makefile.am +++ b/src/gtk-ui/Makefile.am @@ -22,7 +22,6 @@ dist_icon_DATA = sync.png themercdir = $(datadir)/syncevolution/ themerc_DATA = \ - close.png close_hover.png settings.png settings_hover.png \ sync-generic.png \ sync-spinner.gif \ sync-ui.rc @@ -51,7 +50,7 @@ bin_PROGRAMS = $(GUI_PROGRAMS) sync_ui_SOURCES = \ main.c sync-ui.c sync-ui.h sync-ui-config.c sync-ui-config.h \ - mux-frame.c mux-frame.h mux-window.c mux-window.h mux-icon-button.c mux-icon-button.h \ + mux-frame.c mux-frame.h \ sync-config-widget.c sync-config-widget.h \ gtkinfobar.c gtkinfobar.h diff --git a/src/gtk-ui/close.png b/src/gtk-ui/close.png deleted file mode 100644 index 18a4cdc0e3cd10d78134df5477e946675a9d0f01..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 631 zcmV--0*L*IP)BKo|yKlLZw;EVK~s ztFTY!ZDC>S54E(?N)eAApeTq(VIiKNh*$RA9SEZ9?&1Uz;hV|{qdvU(=9{P>Ns{4B zhG=-7K~}Pom8@hXD_O}(RvlU`7E2rWGkll7t;5e-Ch7E*Fy4ofXh@Ivoy&S;s|5u#4GjRz0+A6WN^0WVs8POOeV4Sann%%I6|AvCUV6w0V3OK=n1RU3XM!lE1-CG zL87?zcnxT))lxdcWHRx1JVv7t0izQ5xm;ES$`Wn2+jor&tpHr43og=Kuh%@>*XtF} zO-KtMmT0Hbd0eyK?<8LT8G0io6WTBS^t4z9FIp%DE&4hD_O}(RFS ziBk4rseA`1d^^%f`khuw}(oDJd~|f1UAM&Xjb?xybz#8jbe*{o!yZR2QH~pZR<~kx01RZm-wd zYPFE)C43$3jC5TgDp2qN>8DsM27|#L>fS(Ou^4}5Fc`?mpVC>e_;R`2Xf%3=D+Fye zo3&a^P6U<3iY1#$rG&T-LCfVbF2T;^J)VU<#Y0>%P?;MLG9Hi1v_0Sgx>~K`>EZ8w zuh$EOLdt^9=W_*Sflyt=L6w|aJT6T1-ab2>4m?#UP{mkr-@%&6WbVfj)D4Hj{MKGA ztiq=r+)sS>ZLAONDVa=)`R?0T#e7uEci+bP#PG#@S0=7>R)mRr&_<(iZ%?nlmB@-P z>TTFk_`p6#aK`9A~rHew}J)LmvON^R@m8!Tz&N{@ZMx{Fir>enyddcDc%)XVmHMS+80NZOaZIOE)#75A&So=+di}2h(i+RM xlgY$twIXQB$?b|SP-J=BcHq%84bFc83;^f*$-oR-8Ik}1002ovPDHLkV1galcGv&_ diff --git a/src/gtk-ui/mux-icon-button.c b/src/gtk-ui/mux-icon-button.c deleted file mode 100644 index 54961e47..00000000 --- a/src/gtk-ui/mux-icon-button.c +++ /dev/null @@ -1,283 +0,0 @@ -/* - * Copyright (C) 2009 Intel Corporation - * - * 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) version 3. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -/* TODO: should probably ensure specific icon size? */ - -#include "mux-icon-button.h" - -enum { - PROP_0, - PROP_TOGGLEABLE, - PROP_PIXBUF_NORMAL, - PROP_PIXBUF_ACTIVE, - PROP_PIXBUF_PRELIGHT, - PROP_PIXBUF_SELECTED, - PROP_PIXBUF_INSENSITIVE -}; - -G_DEFINE_TYPE (MuxIconButton, mux_icon_button, GTK_TYPE_BUTTON) - - -static void -mux_icon_button_get_property (GObject *object, guint property_id, - GValue *value, GParamSpec *pspec) -{ - MuxIconButton *btn = MUX_ICON_BUTTON (object); - - switch (property_id) { - case PROP_TOGGLEABLE: - g_value_set_boolean (value, btn->toggleable); - break; - case PROP_PIXBUF_NORMAL: - g_value_set_object (value, mux_icon_button_get_pixbuf (btn, GTK_STATE_NORMAL)); - break; - case PROP_PIXBUF_ACTIVE: - g_value_set_object (value, mux_icon_button_get_pixbuf (btn, GTK_STATE_ACTIVE)); - break; - case PROP_PIXBUF_PRELIGHT: - g_value_set_object (value, mux_icon_button_get_pixbuf (btn, GTK_STATE_PRELIGHT)); - break; - case PROP_PIXBUF_SELECTED: - g_value_set_object (value, mux_icon_button_get_pixbuf (btn, GTK_STATE_SELECTED)); - break; - case PROP_PIXBUF_INSENSITIVE: - g_value_set_object (value, mux_icon_button_get_pixbuf (btn, GTK_STATE_INSENSITIVE)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - } -} - -static void -mux_icon_button_set_property (GObject *object, guint property_id, - const GValue *value, GParamSpec *pspec) -{ - MuxIconButton *btn = MUX_ICON_BUTTON (object); - GdkPixbuf *pixbuf; - - switch (property_id) { - case PROP_TOGGLEABLE: - btn->toggleable = g_value_get_boolean (value); - break; - case PROP_PIXBUF_NORMAL: - pixbuf = GDK_PIXBUF (g_value_get_object (value)); - mux_icon_button_set_pixbuf (btn, GTK_STATE_NORMAL, pixbuf); - break; - case PROP_PIXBUF_ACTIVE: - pixbuf = GDK_PIXBUF (g_value_get_object (value)); - mux_icon_button_set_pixbuf (btn, GTK_STATE_ACTIVE, pixbuf); - break; - case PROP_PIXBUF_PRELIGHT: - pixbuf = GDK_PIXBUF (g_value_get_object (value)); - mux_icon_button_set_pixbuf (btn, GTK_STATE_PRELIGHT, pixbuf); - break; - case PROP_PIXBUF_SELECTED: - pixbuf = GDK_PIXBUF (g_value_get_object (value)); - mux_icon_button_set_pixbuf (btn, GTK_STATE_SELECTED, pixbuf); - break; - case PROP_PIXBUF_INSENSITIVE: - pixbuf = GDK_PIXBUF (g_value_get_object (value)); - mux_icon_button_set_pixbuf (btn, GTK_STATE_INSENSITIVE, pixbuf); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - } -} - -static void -mux_icon_button_dispose (GObject *object) -{ - int i; - MuxIconButton *btn = MUX_ICON_BUTTON (object); - - for (i = 0; i < 5; i++) { - if (btn->pixbufs[i]) { - g_object_unref (btn->pixbufs[i]); - btn->pixbufs[i] = NULL; - } - } - G_OBJECT_CLASS (mux_icon_button_parent_class)->dispose (object); -} - -static void -mux_icon_button_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - MuxIconButton *btn = MUX_ICON_BUTTON (widget); - - if (btn->pixbufs[GTK_STATE_NORMAL]) { - requisition->width = gdk_pixbuf_get_width (btn->pixbufs[GTK_STATE_NORMAL]); - requisition->height = gdk_pixbuf_get_height (btn->pixbufs[GTK_STATE_NORMAL]); - } -} - -static gboolean -mux_icon_button_expose (GtkWidget *widget, - GdkEventExpose *event) -{ - GdkRectangle dirty_area, btn_area; - MuxIconButton *btn = MUX_ICON_BUTTON (widget); - GdkPixbuf *pixbuf; - GtkStateType state; - - if (btn->active) { - /* this is a active toggle button */ - state = GTK_STATE_ACTIVE; - } else { - state = GTK_WIDGET_STATE (widget); - } - - if (btn->pixbufs[state]) { - pixbuf = btn->pixbufs[state]; - } else { - pixbuf = btn->pixbufs[GTK_STATE_NORMAL]; - } - - if (!pixbuf) - return FALSE; - - btn_area.width = gdk_pixbuf_get_width (pixbuf); - btn_area.height = gdk_pixbuf_get_height (pixbuf); - btn_area.x = widget->allocation.x + (widget->allocation.width - btn_area.width) / 2; - btn_area.y = widget->allocation.y + (widget->allocation.height - btn_area.height) / 2; - - if (gdk_rectangle_intersect (&event->area, &widget->allocation, &dirty_area) && - gdk_rectangle_intersect (&btn_area, &dirty_area, &dirty_area)) { - - gdk_draw_pixbuf (widget->window, NULL, pixbuf, - dirty_area.x - btn_area.x, dirty_area.y - btn_area.y, - dirty_area.x, dirty_area.y, - dirty_area.width, dirty_area.height, - GDK_RGB_DITHER_NORMAL, 0, 0); - } - return FALSE; -} - -static void -mux_icon_button_clicked (GtkButton *button) -{ - MuxIconButton *icon_button = MUX_ICON_BUTTON (button); - - if (icon_button->toggleable) { - icon_button->active = !icon_button->active; - } -} - -static void -mux_icon_button_class_init (MuxIconButtonClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - GtkButtonClass *button_class = GTK_BUTTON_CLASS (klass); - GParamSpec *pspec; - - object_class->get_property = mux_icon_button_get_property; - object_class->set_property = mux_icon_button_set_property; - object_class->dispose = mux_icon_button_dispose; - - widget_class->size_request = mux_icon_button_size_request; - widget_class->expose_event = mux_icon_button_expose; - - button_class->clicked = mux_icon_button_clicked; - - pspec = g_param_spec_boolean ("toggleable", - "Toggleable", - "Is icon button button a toggle or normal", - FALSE, - G_PARAM_READWRITE); - g_object_class_install_property (object_class, PROP_TOGGLEABLE, pspec); - pspec = g_param_spec_object ("normal-state-pixbuf", - "Normal state pixbuf", - "GdkPixbuf for GTK_STATE_NORMAL", - GDK_TYPE_PIXBUF, - G_PARAM_READWRITE); - g_object_class_install_property (object_class, PROP_PIXBUF_NORMAL, pspec); - pspec = g_param_spec_object ("active-state-pixbuf", - "Active state pixbuf", - "GdkPixbuf for GTK_STATE_ACTIVE", - GDK_TYPE_PIXBUF, - G_PARAM_READWRITE); - g_object_class_install_property (object_class, PROP_PIXBUF_ACTIVE, pspec); - pspec = g_param_spec_object ("prelight-state-pixbuf", - "Prelight state pixbuf", - "GdkPixbuf for GTK_STATE_PRELIGHT", - GDK_TYPE_PIXBUF, - G_PARAM_READWRITE); - g_object_class_install_property (object_class, PROP_PIXBUF_PRELIGHT, pspec); - pspec = g_param_spec_object ("selected-state-pixbuf", - "Selected state pixbuf", - "GdkPixbuf for GTK_STATE_SELECTED", - GDK_TYPE_PIXBUF, - G_PARAM_READWRITE); - g_object_class_install_property (object_class, PROP_PIXBUF_SELECTED, pspec); - pspec = g_param_spec_object ("insensitive-state-pixbuf", - "Insensitive state pixbuf", - "GdkPixbuf for GTK_STATE_INSENSITIVE", - GDK_TYPE_PIXBUF, - G_PARAM_READWRITE); - g_object_class_install_property (object_class, PROP_PIXBUF_INSENSITIVE, pspec); -} - -static void -mux_icon_button_init (MuxIconButton *self) -{ -} - -GtkWidget* -mux_icon_button_new (GdkPixbuf *normal_pixbuf, gboolean toggleable) -{ - return g_object_new (MUX_TYPE_ICON_BUTTON, - "normal-state-pixbuf", normal_pixbuf, - "toggleable", toggleable, - NULL); -} - -void -mux_icon_button_set_pixbuf (MuxIconButton *button, GtkStateType state, GdkPixbuf *pixbuf) -{ - if (button->pixbufs[state]) { - g_object_unref (button->pixbufs[state]); - } - button->pixbufs[state] = g_object_ref (pixbuf); - - if (state == GTK_STATE_NORMAL) { - gtk_widget_queue_resize (GTK_WIDGET (button)); - } else if (state == GTK_WIDGET_STATE (GTK_WIDGET (button))) { - gtk_widget_queue_draw (GTK_WIDGET (button)); - } -} - -GdkPixbuf* -mux_icon_button_get_pixbuf (MuxIconButton *button, GtkStateType state) -{ - return button->pixbufs[state]; -} - -void -mux_icon_button_set_active (MuxIconButton *button, gboolean active) -{ - button->active = active; - gtk_widget_queue_draw (GTK_WIDGET (button)); -} - -gboolean -mux_icon_button_get_active (MuxIconButton *button) -{ - return button->active; -} diff --git a/src/gtk-ui/mux-icon-button.h b/src/gtk-ui/mux-icon-button.h deleted file mode 100644 index a6e01309..00000000 --- a/src/gtk-ui/mux-icon-button.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2009 Intel Corporation - * - * 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) version 3. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -#ifndef _MUX_ICON_BUTTON -#define _MUX_ICON_BUTTON - -#include - -G_BEGIN_DECLS - -#define MUX_TYPE_ICON_BUTTON mux_icon_button_get_type() - -#define MUX_ICON_BUTTON(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), MUX_TYPE_ICON_BUTTON, MuxIconButton)) - -#define MUX_ICON_BUTTON_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), MUX_TYPE_ICON_BUTTON, MuxIconButtonClass)) - -#define MUX_IS_ICON_BUTTON(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MUX_TYPE_ICON_BUTTON)) - -#define MUX_IS_ICON_BUTTON_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), MUX_TYPE_ICON_BUTTON)) - -#define MUX_ICON_BUTTON_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), MUX_TYPE_ICON_BUTTON, MuxIconButtonClass)) - -typedef struct { - GtkButton parent; - GdkPixbuf *pixbufs[5]; - - gboolean toggleable; - gboolean active; -} MuxIconButton; - -typedef struct { - GtkButtonClass parent_class; -} MuxIconButtonClass; - -GType mux_icon_button_get_type (void); - -GtkWidget* mux_icon_button_new (GdkPixbuf *normal_pixbuf, gboolean toggleable); - -void mux_icon_button_set_pixbuf (MuxIconButton *button, GtkStateType state, GdkPixbuf *pixbuf); - -GdkPixbuf* mux_icon_button_get_pixbuf (MuxIconButton *button, GtkStateType state); - -/* for togglebuttons */ -void mux_icon_button_set_active (MuxIconButton *button, gboolean active); - -gboolean mux_icon_button_get_active (MuxIconButton *button); - -G_END_DECLS - -#endif diff --git a/src/gtk-ui/mux-window.c b/src/gtk-ui/mux-window.c deleted file mode 100644 index ae24d22a..00000000 --- a/src/gtk-ui/mux-window.c +++ /dev/null @@ -1,641 +0,0 @@ -/* - * Copyright (C) 2009 Intel Corporation - * - * 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) version 3. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -#include "mux-window.h" -#include "mux-icon-button.h" - -static GdkColor mux_window_default_title_bar_bg = { 0, 0x3300, 0x3300, 0x3300 }; - -#define MUX_WINDOW_DEFAULT_TITLE_BAR_HEIGHT 63 - -GType -mux_decorations_get_type (void) -{ - static GType etype = 0; - if (etype == 0) { - static const GFlagsValue values[] = { - { MUX_DECOR_CLOSE, "MUX_CLOSE", "close" }, - { MUX_DECOR_SETTINGS, "MUX_SETTINGS", "settings" }, - { 0, NULL, NULL } - }; - etype = g_flags_register_static (g_intern_static_string ("MuxDecorations"), values); - } - return etype; -} - - -enum { - PROP_0, - PROP_DECORATIONS, - PROP_BACK_TITLE, -}; - -enum { - SETTINGS_VISIBILITY_CHANGED, - LAST_SIGNAL -}; - -static guint mux_window_signals[LAST_SIGNAL] = { 0 }; - -G_DEFINE_TYPE (MuxWindow, mux_window, GTK_TYPE_WINDOW) - -#define GET_PRIVATE(o) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((o), MUX_TYPE_WINDOW, MuxWindowPrivate)) - -typedef struct _MuxWindowPrivate MuxWindowPrivate; - -struct _MuxWindowPrivate { - int dummy; -}; - -static void -mux_window_get_property (GObject *object, guint property_id, - GValue *value, GParamSpec *pspec) -{ - MuxWindow *win = MUX_WINDOW (object); - - switch (property_id) { - case PROP_DECORATIONS: - g_value_set_uint (value, win->decorations); - break; - case PROP_BACK_TITLE: - g_value_set_string (value, - gtk_button_get_label (GTK_BUTTON (win->back_btn))); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - } -} - -static void -mux_window_set_property (GObject *object, guint property_id, - const GValue *value, GParamSpec *pspec) -{ - MuxWindow *win = MUX_WINDOW (object); - - switch (property_id) { - case PROP_DECORATIONS: - mux_window_set_decorations (win, g_value_get_uint (value)); - break; - case PROP_BACK_TITLE: - g_free (win->back_title); - win->back_title = g_strdup (g_value_get_string (value)); - if (win->back_btn) { - gtk_button_set_label (GTK_BUTTON (win->back_btn), win->back_title); - } - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - } -} - -static void -mux_window_update_style (MuxWindow *win) -{ - GdkColor *title_bar_bg = NULL; - guint title_bar_height; - - g_return_if_fail (win->title_bar); - - gtk_widget_style_get (GTK_WIDGET (win), - "title-bar-height", &title_bar_height, - "title-bar-bg", &title_bar_bg, - NULL); - - if (title_bar_bg) { - gtk_widget_modify_bg (win->title_bar, GTK_STATE_NORMAL, title_bar_bg); - gdk_color_free (title_bar_bg); - } else { - gtk_widget_modify_bg (win->title_bar, GTK_STATE_NORMAL, - &mux_window_default_title_bar_bg); - } - - gtk_widget_set_size_request (win->title_bar, -1, title_bar_height); -} - -static void -mux_window_style_set (GtkWidget *widget, - GtkStyle *previous) -{ - MuxWindow *win = MUX_WINDOW (widget); - - mux_window_update_style (win); - - GTK_WIDGET_CLASS (mux_window_parent_class)->style_set (widget, previous); -} - -static void -mux_window_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data) -{ - MuxWindow *mux_win = MUX_WINDOW (container); - GtkBin *bin = GTK_BIN (container); - - /* FIXME: call parents forall instead ? */ - if (bin->child) - (* callback) (bin->child, callback_data); - - if (mux_win->title_bar) - (* callback) (mux_win->title_bar, callback_data); - if (mux_win->notebook) - (* callback) (mux_win->notebook, callback_data); -} - -static void -mux_window_add (GtkContainer *container, - GtkWidget *widget) -{ - MuxWindowClass *klass; - GtkContainerClass *parent_container_class; - - klass = MUX_WINDOW_GET_CLASS (container); - parent_container_class = GTK_CONTAINER_CLASS (g_type_class_peek_parent (klass)); - - parent_container_class->add (container, widget); -} - -static void -mux_window_remove (GtkContainer *container, - GtkWidget *child) -{ - MuxWindow *win = MUX_WINDOW (container); - GtkBin *bin = GTK_BIN (container); - - if (child == win->title_bar) { - gtk_widget_unparent (win->title_bar); - win->title_bar = NULL; - } else if (child == win->notebook) { - gtk_widget_unparent (win->notebook); - win->notebook = NULL; - } else if (bin->child) { - if (bin->child == child) { - /* should call parents remove... */ - gtk_widget_unparent (child); - bin->child = NULL; - } - } -} - -static void -mux_window_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - GtkBin *bin = GTK_BIN (widget); - MuxWindow *mux_win = MUX_WINDOW (widget); - GtkRequisition req; - - /* we will always be maximized so none of this should be necessary - * (requisition will never be used), but some widgets to assume - * size_request is called */ - if (mux_win->title_bar && GTK_WIDGET_VISIBLE (mux_win->title_bar)) - gtk_widget_size_request (mux_win->title_bar, &req); - if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) - gtk_widget_size_request (bin->child, &req); - if (mux_win->notebook && GTK_WIDGET_VISIBLE (mux_win->notebook)) - gtk_widget_size_request (mux_win->notebook, &req); - - requisition->width = 1024; - requisition->height = 600; -} - -static void -mux_window_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GtkBin *bin = GTK_BIN (widget); - MuxWindow *mux_win = MUX_WINDOW (widget); - GtkAllocation child_allocation; - int xmargin, ymargin, title_height; - - widget->allocation = *allocation; - xmargin = GTK_CONTAINER (widget)->border_width + - widget->style->xthickness; - ymargin = GTK_CONTAINER (widget)->border_width + - widget->style->ythickness; - title_height = 0; - - if (mux_win->title_bar) { - GtkAllocation title_allocation; - GtkRequisition title_req; - gtk_widget_get_child_requisition (mux_win->title_bar, &title_req); - - title_height = title_req.height; - title_allocation.x = allocation->x; - title_allocation.y = allocation->y; - title_allocation.width = allocation->width; - title_allocation.height = title_height; - gtk_widget_size_allocate (mux_win->title_bar, &title_allocation); - - } - - child_allocation.x = allocation->x + xmargin; - child_allocation.y = allocation->y + title_height + ymargin; - child_allocation.width = allocation->width - 2 * xmargin; - child_allocation.height = allocation->height - (2 * ymargin + title_height); - - if (GTK_WIDGET_MAPPED (widget) && - (child_allocation.x != mux_win->child_allocation.x || - child_allocation.y != mux_win->child_allocation.y || - child_allocation.width != mux_win->child_allocation.width || - child_allocation.height != mux_win->child_allocation.height)) { - gdk_window_invalidate_rect (widget->window, &widget->allocation, FALSE); - } - - if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) { - gtk_widget_size_allocate (bin->child, &child_allocation); - } - - if (mux_win->notebook && GTK_WIDGET_VISIBLE (mux_win->notebook)) { - gtk_widget_size_allocate (mux_win->notebook, &child_allocation); - } - - mux_win->child_allocation = child_allocation; -} - -static void -mux_window_class_init (MuxWindowClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass); - GParamSpec *pspec; - - g_type_class_add_private (klass, sizeof (MuxWindowPrivate)); - - object_class->get_property = mux_window_get_property; - object_class->set_property = mux_window_set_property; - - widget_class->size_request = mux_window_size_request; - widget_class->size_allocate = mux_window_size_allocate; - widget_class->style_set = mux_window_style_set; - - container_class->forall = mux_window_forall; - container_class->remove = mux_window_remove; - container_class->add = mux_window_add; - - pspec = g_param_spec_uint ("title-bar-height", - "Title bar height", - "Total height of the title bar", - 0, G_MAXUINT, MUX_WINDOW_DEFAULT_TITLE_BAR_HEIGHT, - G_PARAM_READWRITE); - gtk_widget_class_install_style_property(widget_class, pspec); - pspec = g_param_spec_boxed ("title-bar-bg", - "Title bar bg color", - "Color of the title bar background", - GDK_TYPE_COLOR, - G_PARAM_READWRITE); - gtk_widget_class_install_style_property(widget_class, pspec); - - pspec = g_param_spec_flags ("decorations", - NULL, - "Bitfield of MuxDecorations defining used window decorations", - MUX_TYPE_DECORATIONS, - MUX_DECOR_CLOSE, - G_PARAM_READWRITE); - g_object_class_install_property (object_class, - PROP_DECORATIONS, - pspec); - - pspec = g_param_spec_string ("back-title", - NULL, - "title of the back button in the window decoration", - "", - G_PARAM_READWRITE); - g_object_class_install_property (object_class, - PROP_BACK_TITLE, - pspec); - - mux_window_signals[SETTINGS_VISIBILITY_CHANGED] = - g_signal_new ("settings-visibility-changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (MuxWindowClass, settings_visibility_changed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0, NULL); - -} - -static void -mux_window_settings_clicked (MuxIconButton *button, MuxWindow *window) -{ - gboolean active; - active = mux_icon_button_get_active (button); - mux_window_set_settings_visible (window, active); -} - -static void -mux_window_close_clicked (MuxWindow *window) -{ - /* this is how GtkDialog does it... */ - GdkEvent *event; - - event = gdk_event_new (GDK_DELETE); - event->any.window = g_object_ref (GTK_WIDGET (window)->window); - event->any.send_event = TRUE; - - gtk_main_do_event (event); - gdk_event_free (event); -} - -static GdkPixbuf* -load_icon (MuxWindow *window, const char *icon_name) -{ - static GtkIconTheme *theme = NULL; - GdkScreen *screen; - GdkPixbuf *pixbuf; - - if (!theme) { - screen = gtk_widget_get_screen (GTK_WIDGET (window)); - theme = gtk_icon_theme_get_for_screen (screen); - } - - pixbuf = gtk_icon_theme_load_icon (theme, icon_name, - 48, 0, NULL); - - - /* FIXME: workaround until icons are in Moblin Netbook theme */ - if (!pixbuf) { - char *str = g_strdup_printf ("%s/%s.png", THEMEDIR, icon_name); - pixbuf = gdk_pixbuf_new_from_file_at_size (str, 48, 48, NULL); - - g_free (str); - } - - if (!pixbuf) { - g_warning ("Icon '%s' not found in theme", icon_name); - pixbuf = gtk_widget_render_icon (GTK_WIDGET (window), - GTK_STOCK_MISSING_IMAGE, - GTK_ICON_SIZE_DIALOG, - NULL); - - } - return pixbuf; -} - -static void -bread_crumb_clicked_cb (GtkButton *btn, MuxWindow *window) -{ - mux_window_set_current_page (window, -1); -} - -static void -mux_window_build_title_bar (MuxWindow *window) -{ - GtkWidget *box, *button_box, *btn, *align; - GdkPixbuf *pixbuf, *pixbuf_hover; - - if (window->title_bar) { - gtk_widget_unparent (window->title_bar); - } - - window->title_bar = gtk_event_box_new (); - gtk_widget_set_name (window->title_bar, "mux_window_title_bar"); - gtk_widget_set_parent (window->title_bar, GTK_WIDGET (window)); - gtk_widget_show (window->title_bar); - - box = gtk_hbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (window->title_bar), box); - gtk_widget_show (box); - - align = gtk_alignment_new (0, 0.5, 0, 0); - gtk_box_pack_start (GTK_BOX (box), align, FALSE, FALSE, 4); - gtk_widget_show (align); - - button_box = gtk_hbox_new (FALSE, 0); - gtk_widget_set_name (window->title_bar, "mux_window_bread_crumbs"); - gtk_container_add (GTK_CONTAINER (align), button_box); - gtk_widget_show (button_box); - - window->back_btn = gtk_button_new_with_label (window->back_title); - gtk_box_pack_start (GTK_BOX (button_box), window->back_btn, - FALSE, FALSE, 4); - g_signal_connect (window->back_btn, "clicked", - G_CALLBACK (bread_crumb_clicked_cb), window); - if (mux_window_get_current_page (window) != -1) { - gtk_widget_show (window->back_btn); - } - /*window->title_label = gtk_label_new (gtk_window_get_title (GTK_WINDOW (window))); - gtk_box_pack_start (GTK_BOX (box), window->title_label, - FALSE, FALSE, 0); - gtk_widget_show (window->title_label);*/ - - button_box = gtk_hbox_new (TRUE, 0); - gtk_box_pack_end (GTK_BOX (box), button_box, FALSE, FALSE, 4); - gtk_widget_show (button_box); - - if (window->decorations & MUX_DECOR_CLOSE) { - pixbuf = load_icon (window, "close"); - pixbuf_hover = load_icon (window, "close_hover"); - btn = g_object_new (MUX_TYPE_ICON_BUTTON, - "normal-state-pixbuf", pixbuf, - "prelight-state-pixbuf", pixbuf_hover, - NULL); - gtk_widget_set_name (btn, "mux_icon_button_close"); - g_signal_connect_swapped (btn, "clicked", - G_CALLBACK (mux_window_close_clicked), window); - gtk_box_pack_end (GTK_BOX (button_box), btn, FALSE, FALSE, 0); - gtk_widget_show (btn); - } - - if (window->decorations & MUX_DECOR_SETTINGS) { - pixbuf = load_icon (window, "settings"); - pixbuf_hover = load_icon (window, "settings_hover"); - window->settings_button = g_object_new (MUX_TYPE_ICON_BUTTON, - "normal-state-pixbuf", pixbuf, - "prelight-state-pixbuf", pixbuf_hover, - "active-state-pixbuf", pixbuf_hover, - "toggleable", TRUE, - NULL); - gtk_widget_set_name (window->settings_button, "mux_icon_button_settings"); - g_signal_connect (window->settings_button, "clicked", - G_CALLBACK (mux_window_settings_clicked), window); - gtk_box_pack_end (GTK_BOX (button_box), window->settings_button, FALSE, FALSE, 0); - gtk_widget_show (window->settings_button); - } - - mux_window_update_style (window); - - gtk_widget_map (window->title_bar); /*TODO: is there a better way to do this ? */ - if (GTK_WIDGET_VISIBLE (window)) - gtk_widget_queue_resize (GTK_WIDGET (window)); - -} - -static void -mux_window_title_changed (MuxWindow *window, - GParamSpec *pspec, - gpointer user_data) -{ - mux_window_build_title_bar (window); -} - -/* For some reason metacity sometimes won't maximize but will if asked - * another time. For the record, I'm not proud of writing this */ -static gboolean -mux_window_try_maximize (MuxWindow *self) -{ - static int count = 0; - - count++; - gtk_window_maximize (GTK_WINDOW (self)); - - return (count < 10); -} - -static void -mux_window_init (MuxWindow *self) -{ - self->decorations = MUX_DECOR_CLOSE; - - gtk_window_set_decorated (GTK_WINDOW (self), FALSE); - - g_signal_connect (self, "notify::title", - G_CALLBACK (mux_window_title_changed), NULL); - - mux_window_build_title_bar (self); - - self->notebook = gtk_notebook_new (); - gtk_notebook_set_show_tabs (GTK_NOTEBOOK (self->notebook), FALSE); - gtk_notebook_set_show_border (GTK_NOTEBOOK (self->notebook), FALSE); - gtk_widget_set_parent (self->notebook, GTK_WIDGET (self)); - self->settings_index = -2; - - - gtk_window_maximize (GTK_WINDOW (self)); - g_timeout_add (10, (GSourceFunc)mux_window_try_maximize, self); -} - -GtkWidget* -mux_window_new (const char *back_title) -{ - return g_object_new (MUX_TYPE_WINDOW, - "back-title", back_title, - NULL); -} - -void -mux_window_set_decorations (MuxWindow *window, - MuxDecorations decorations) -{ - g_return_if_fail (MUX_IS_WINDOW (window)); - - if (decorations != window->decorations) { - window->decorations = decorations; - mux_window_build_title_bar (window); - } -} - -MuxDecorations -mux_window_get_decorations (MuxWindow *window) -{ - g_return_val_if_fail (MUX_IS_WINDOW (window), MUX_DECOR_NONE); - - return window->decorations; -} - -void -mux_window_set_settings_visible (MuxWindow *window, gboolean show) -{ - gboolean visible; - - visible = (mux_window_get_current_page (window) == window->settings_index); - if (visible != show) { - if (show) { - mux_window_set_current_page (window, window->settings_index); - } else { - mux_window_set_current_page (window, -1); - } - - } -} - -gboolean -mux_window_get_settings_visible (MuxWindow *window) -{ - return (mux_window_get_current_page (window) == window->settings_index); -} - -gint -mux_window_append_page (MuxWindow *window, - GtkWidget *page, - gboolean is_settings) -{ - gint index; - - index = gtk_notebook_append_page (GTK_NOTEBOOK (window->notebook), page, NULL); - - if (is_settings) { - window->settings_index = index; - } - return index; -} - -void mux_window_set_current_page (MuxWindow *window, gint index) -{ - GtkBin *bin = GTK_BIN (window); - gint old_index = mux_window_get_current_page (window); - - if (old_index == index) { - return; - } - - if (index == -1) { - gtk_widget_hide (window->notebook); - if (bin->child) { - gtk_widget_show (bin->child); - } - gtk_widget_hide (window->back_btn); - } else { - gtk_notebook_set_current_page (GTK_NOTEBOOK (window->notebook), index); - if (bin->child) { - gtk_widget_hide (bin->child); - } - gtk_widget_show (window->notebook); - gtk_widget_map (window->notebook); - - gtk_widget_show (window->back_btn); - } - - - if (window->settings_button) { - mux_icon_button_set_active (MUX_ICON_BUTTON (window->settings_button), - index == window->settings_index); - } - - if (old_index == window->settings_index || index == window->settings_index) { - g_signal_emit (window, mux_window_signals[SETTINGS_VISIBILITY_CHANGED], 0); - } - -} - -gint -mux_window_get_current_page (MuxWindow *window) -{ - GtkBin *bin = GTK_BIN (window); - - if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) { - return -1; - } else if (window->notebook) { - return gtk_notebook_get_current_page (GTK_NOTEBOOK (window->notebook)); - } - return -1; -} diff --git a/src/gtk-ui/mux-window.h b/src/gtk-ui/mux-window.h deleted file mode 100644 index fed7f1d2..00000000 --- a/src/gtk-ui/mux-window.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2009 Intel Corporation - * - * 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) version 3. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -#ifndef _MUX_WINDOW -#define _MUX_WINDOW - -#include - -G_BEGIN_DECLS - -typedef enum { - MUX_DECOR_NONE = 0, - MUX_DECOR_CLOSE = 1 << 0, - MUX_DECOR_SETTINGS = 1 << 1, -} MuxDecorations; - -GType mux_decorations_get_type (void) G_GNUC_CONST; -#define MUX_TYPE_DECORATIONS (mux_decorations_get_type()) - - -#define MUX_TYPE_WINDOW mux_window_get_type() -#define MUX_WINDOW(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), MUX_TYPE_WINDOW, MuxWindow)) -#define MUX_WINDOW_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), MUX_TYPE_WINDOW, MuxWindowClass)) -#define MUX_IS_WINDOW(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MUX_TYPE_WINDOW)) -#define MUX_IS_WINDOW_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), MUX_TYPE_WINDOW)) -#define MUX_WINDOW_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), MUX_TYPE_WINDOW, MuxWindowClass)) - -typedef struct { - GtkWindow parent; - - GtkWidget *title_bar; - GtkWidget *back_btn; - GtkWidget *settings; - GtkWidget *settings_button; - GtkWidget *notebook; - - gint settings_index; - - GtkAllocation child_allocation; - - MuxDecorations decorations; - GdkColor title_bar_color; - guint title_bar_height; - char *back_title; - -} MuxWindow; - -typedef struct { - GtkWindowClass parent_class; - - void (*settings_visibility_changed) (MuxWindow *window); -} MuxWindowClass; - -GType mux_window_get_type (void); - -GtkWidget* mux_window_new (const char *back_title); - -void mux_window_set_decorations (MuxWindow *window, MuxDecorations decorations); -MuxDecorations mux_window_get_decorations (MuxWindow *window); - -void mux_window_set_settings_visible (MuxWindow *window, gboolean visible); -gboolean mux_window_get_settings_visible (MuxWindow *window); - -gint mux_window_append_page (MuxWindow *window, GtkWidget *page, gboolean is_settings); - -void mux_window_set_current_page (MuxWindow *window, gint index); -gint mux_window_get_current_page (MuxWindow *window); - -G_END_DECLS - -#endif diff --git a/src/gtk-ui/settings.png b/src/gtk-ui/settings.png deleted file mode 100644 index 52a6d9034b23ebcb579c314c0c0c29bd95ce5c61..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1094 zcmV-M1iAZ(P)TOtcXxMw?jtlb zDJdx}Esgfc$;rjV#oODP<5+8JYwPRly-tYJ zGc()T+T!Bk)X44aEz=GU5A9-gXJustKHKB*L`6k`si2_X?Ck93=0<>mhRbugT<`Di z+uPe}esOVePfrh5Zg~O5L41CG?jT=RS66=@(e3W;?#{`{5uj?q+S;0G$Hc^N*?(J# zPfT#|UQbU?L79<}AuKE^D$2{tQ(vd2r#Ck@RTs8E0BJ8QER2qhE-o&N@MW30Pnko$dfz|tAG!#BH!9mRe?%v*>KC-;LYym2YAq|+V zj~^c&OG9@!r?A4&+}vD!q^ztA?pmf@U0wOTKcNtIeSPgLR*N%PT+KpmX=G<-H#Ro@ z_%IrDEfWGXm#um$KR>^#t4npKrl#;^L|3}_&Ct*gYA;>Xt-rrNA|k@?QgC-*VBq25 z!6_YRZ*Px|j#faCFeDuh6Mx6A30*roJ2K(<`56&KD0CMTLxu?l>Qs(kl~Bn}098^d z5lGe{XermhE-x?fdQQUY>pUJA896vOuuDIC9N>n)girX!{e*-B03972`TZ4N#lzqz zSUGJFKJ7C94}6WBP^Edv$;mwHKP@sdYS^1>gsAvLa_A(ip|W-*ebki+$&oun(D!c{V4Y&$w%|`0!H4Uu&{7=co>fA zK*z_&x3;#N(gFO2@>Srbr>F1k?&@W#Z<+^Bq(KVN*VhN3)u)Mx3Hak+EFdtdthutX zl569Yxoi>|RXOSD2=$Cg$t^(t&FRmHvAiQLtfSX+C<6W9;Gnurx$@4=PQ4}z8mMi3 z#goWKA%Jha1w^VpOHRXKND)yw1eosp{5;i8(6Jzx+=bWocszR5kE;>4RMFyVWRlR` z@4qsR=UI3d`h`M0Jw3ruTq?LU&*X##tHElp8mtDZ!D_JDvR?uW08fL;FP_Os?f?J) M07*qoM6N<$f*%A5S;kO? zWQ>#{lrfYd8A^tfS*D^WiU&Lxqj>Yc3om$3C>bJ|in_!h3OVQ)l6ktn-SrmU*6u{@9*ydfj}%4i$o$#O-%tm?Dh5a@$vEY_7={s z4^szFp-^aKWTdXHF5r`?si`4++S=OJ*VhjZ4_Fc6!$Y9d5KaRF0}Txgc}#(ww?L`s z>+8S0y$KOy0q+gbL}-Qh2)=^>u2ArO><8=r9IL!%eWSRt?yQ!UmNJKkMf+P~j$;k;8BO@bA zOG^P1e2A=?o13Hi!@|O9YisrN^b}42>!+uu`}_OKKl=Xuo?X69OiU053<3~7K0W|i zQc?nxB>g8RC+TKWQ`7wXd~%6gC4!EyJT74ahjB%=0i~;}E73tAAtC<${uF3;clY%4 zG~Jw*mges6PW*v^f%^LTp`oGY=VuQO5Atha%gf7L#TC}q*EcvgNM#!n=-Aj8bEmVj zGjUc{R)F>H!{AVStiq&Xe+As7r6uOd=;){dP?(jK6>)ZVcbV(k+uOup793Ytk)yu8 zzRZ=Fm>A@)!nVW1L*kHbMa{*Sy_L47#zBdZctWt zM@L61zdIlxpr)pV=4fYUrydekJVf_~kSpUw)#c?SS3L^~ zD>*rtIRjB2ofVx(nO8Wmv9XZq2?+^xb#s1lrQl0#@Uy51?)^ zzG`V{k@zhxE;9SqXPJjQA&!ZO2{;+QlL=H|g#67pfM@LO?GZmdK0Z7=98%EG&=8DI zCnu&J0OM0hj>@Az(cM%4%32R#RBCK&q~aBF3EGM&N{Wk%pPrtWlu=bxg?>zbE#wt* zeq?p3?D{Jz33`+Ydu9~_VnaiN0v$k+Ei5dc)1d(qMK&@rq8bsPj#bevnC^3Pb1~-A z6_grI7W(V&zJmNlV7`1S!@15vg*ki}^ngSn0ZJ8Q9$Ty`Y8NzwKR@i}o#qeLAFSUT zD+uUY{k?!H44xa*obc}Mj{iUrP;j^q#KZs4Vl0#AD?XrU-oizi%49MGRsO#Y&`OYY vQmGVLL@X8)Db14vg|@=66Xgk #endif @@ -56,6 +55,12 @@ static gboolean support_canceling = FALSE; #define STRING_VARIANT_HASHTABLE (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE)) +enum { + PAGE_MAIN, + PAGE_SETTINGS, + PAGE_EMERGENCY, +}; + typedef enum bluetooth_type { SYNC_BLUETOOTH_NONE, SYNC_BLUETOOTH_GNOME, @@ -92,8 +97,10 @@ struct _app_data { GtkWidget *services_win; /* will be NULL when USE_MOBLIN_UX is set*/ GtkWidget *emergency_win; /* will be NULL when USE_MOBLIN_UX is set*/ - - gint emergency_index; /* for use in mux_window_set_current_page() */ + GtkWidget *notebook; /* only in use with USE_MOBLIN_UX */ + GtkWidget *back_btn; /* only in use with USE_MOBLIN_UX */ + GtkWidget *settings_btn; /* only in use with USE_MOBLIN_UX */ + guint settings_id; GtkWidget *service_box; GtkWidget *info_bar; @@ -121,8 +128,8 @@ struct _app_data { GtkWidget *services_box; GtkWidget *devices_box; GtkWidget *scrolled_window; - GtkWidget *back_btn; GtkWidget *expanded_config; + GtkWidget *settings_close_btn; GtkWidget *emergency_label; GtkWidget *emergency_expander; @@ -130,6 +137,7 @@ struct _app_data { GtkWidget *refresh_from_server_btn_label; GtkWidget *refresh_from_client_btn_label; GtkWidget *emergency_backup_table; + GtkWidget *emergency_close_btn; GtkWidget *password_dialog_entry; char *password_dialog_id; @@ -744,10 +752,6 @@ set_app_state (app_data *data, app_state state) #ifdef USE_MOBLIN_UX -/* truly stupid, but glade doesn't allow custom containers. - Now glade file has dummy containers that will be replaced here. - The dummy should be a gtkbin and it's parent should be a box with just one child */ - static GtkWidget* switch_dummy_to_mux_frame (GtkWidget *dummy) { @@ -768,81 +772,205 @@ switch_dummy_to_mux_frame (GtkWidget *dummy) gtk_widget_reparent (gtk_bin_get_child (GTK_BIN (dummy)), frame); gtk_container_remove (GTK_CONTAINER (parent), dummy); - /* make sure there are no other children in box */ - g_assert (gtk_container_get_children (GTK_CONTAINER (parent)) == NULL); - gtk_box_pack_start (GTK_BOX (parent), frame, TRUE, TRUE, 0); gtk_widget_show (frame); return frame; } +static void +set_page (app_data *data, int page) +{ + int current = gtk_notebook_get_current_page (GTK_NOTEBOOK (data->notebook)); + + if (page != current) { + gtk_notebook_set_current_page (GTK_NOTEBOOK (data->notebook), + page); + if (page != PAGE_MAIN) { + gtk_widget_show (data->back_btn); + } else { + gtk_widget_hide (data->back_btn); + } + + /* make sure the toggle is correct */ + g_signal_handler_block (data->settings_btn, data->settings_id); + if (page == PAGE_SETTINGS) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->settings_btn), + TRUE); + } else if (current == PAGE_SETTINGS) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->settings_btn), + FALSE); + } + g_signal_handler_unblock (data->settings_btn, data->settings_id); + } + + gtk_window_present (GTK_WINDOW (data->sync_win)); +} + + +static void +settings_toggled (GtkToggleButton *button, app_data *data) +{ + int page = gtk_notebook_get_current_page (GTK_NOTEBOOK (data->notebook)); + + if (page == PAGE_SETTINGS) { + show_main_view (data); + } else { + show_services_list (data, NULL); + } +} static gboolean key_press_cb (GtkWidget *widget, GdkEventKey *event, app_data *data) { - if (event->keyval == GDK_Escape && - mux_window_get_current_page (MUX_WINDOW (data->sync_win)) >= 0) { + int page = gtk_notebook_get_current_page (GTK_NOTEBOOK (data->notebook)); + if (event->keyval == GDK_Escape && page != PAGE_MAIN) { show_main_view (data); } return FALSE; } -static void -settings_visibility_changed_cb (MuxWindow *win, app_data *data) +/* For some reason metacity sometimes won't maximize but will if asked + * another time. For the record, I'm not proud of writing this */ +static gboolean +try_maximize (GtkWindow *win) { - if (mux_window_get_settings_visible (MUX_WINDOW (data->sync_win))) { - update_services_list (data); - } + static int count = 0; + + count++; + gtk_window_maximize (win); + + return (count < 10); } + static void setup_windows (app_data *data, GtkWidget *main, GtkWidget *settings, GtkWidget *emergency) { - GtkWidget *mux_main; - GtkWidget *tmp; + GtkWidget *tmp, *toolbar, *close_btn; + GtkToolItem *item; g_assert (GTK_IS_WINDOW (main)); g_assert (GTK_IS_WINDOW (settings)); g_assert (GTK_IS_WINDOW (emergency)); - /* TRANSLATORS: button in the Moblin window title bar when main view is - * not visible */ - mux_main = mux_window_new (_("Back to sync")); - gtk_window_set_title (GTK_WINDOW (mux_main), - gtk_window_get_title (GTK_WINDOW (main))); - gtk_window_set_default_size (GTK_WINDOW (mux_main), 1024, 600); - gtk_widget_set_name (mux_main, gtk_widget_get_name (main)); - gtk_widget_reparent (gtk_bin_get_child (GTK_BIN (main)), mux_main); - mux_window_set_decorations (MUX_WINDOW (mux_main), MUX_DECOR_SETTINGS|MUX_DECOR_CLOSE); - g_signal_connect (mux_main, "key-press-event", - G_CALLBACK (key_press_cb), data); - g_signal_connect (mux_main, "settings-visibility-changed", - G_CALLBACK (settings_visibility_changed_cb), data); + data->sync_win = main; + data->services_win = NULL; + data->emergency_win = NULL; + /* populate the notebook with window contents */ + data->notebook = gtk_notebook_new (); + gtk_widget_show (data->notebook); + gtk_notebook_set_show_tabs (GTK_NOTEBOOK (data->notebook), FALSE); + gtk_notebook_set_show_border (GTK_NOTEBOOK (data->notebook), FALSE); + + gtk_window_maximize (GTK_WINDOW (data->sync_win)); + g_timeout_add (10, (GSourceFunc)try_maximize, data->sync_win); + gtk_window_set_decorated (GTK_WINDOW (data->sync_win), FALSE); + gtk_widget_set_name (data->sync_win, "meego_win"); + g_signal_connect (data->sync_win, "key-press-event", + G_CALLBACK (key_press_cb), data); + + tmp = g_object_ref (gtk_bin_get_child (GTK_BIN (data->sync_win))); + gtk_container_remove (GTK_CONTAINER (data->sync_win), tmp); + gtk_notebook_append_page (GTK_NOTEBOOK (data->notebook), tmp, NULL); + g_object_unref (tmp); tmp = g_object_ref (gtk_bin_get_child (GTK_BIN (settings))); gtk_container_remove (GTK_CONTAINER (settings), tmp); - mux_window_append_page (MUX_WINDOW (mux_main), tmp, TRUE); + gtk_notebook_append_page (GTK_NOTEBOOK (data->notebook), tmp, NULL); g_object_unref (tmp); tmp = g_object_ref (gtk_bin_get_child (GTK_BIN (emergency))); gtk_container_remove (GTK_CONTAINER (emergency), tmp); - data->emergency_index = - mux_window_append_page (MUX_WINDOW (mux_main), tmp, FALSE); + gtk_notebook_append_page (GTK_NOTEBOOK (data->notebook), tmp, NULL); g_object_unref (tmp); - data->sync_win = mux_main; - data->services_win = NULL; - data->emergency_win = NULL; + tmp = gtk_vbox_new (FALSE, 0); + gtk_widget_show (tmp); + gtk_container_add (GTK_CONTAINER (data->sync_win), tmp); + + gtk_box_pack_end (GTK_BOX (tmp), data->notebook, + TRUE, TRUE, 0); + + /* create the window toolbar */ + toolbar = gtk_toolbar_new (); + gtk_widget_set_name (toolbar, "MeeGoToolbar"); + gtk_box_pack_start (GTK_BOX (tmp), toolbar, + FALSE, FALSE, 0); + + data->back_btn = gtk_button_new_with_label (_("Back to sync")); + gtk_widget_set_can_focus (data->back_btn, FALSE); + gtk_widget_set_no_show_all (data->back_btn, TRUE); + g_signal_connect_swapped (data->back_btn, "clicked", + G_CALLBACK (show_main_view), data); + item = gtk_tool_item_new (); + gtk_container_add (GTK_CONTAINER (item), data->back_btn); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, 0); + + item = gtk_separator_tool_item_new (); + gtk_tool_item_set_expand (item, TRUE); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, 1); + + data->settings_btn = gtk_toggle_button_new (); + gtk_widget_set_can_focus (data->settings_btn, FALSE); + gtk_widget_set_name (data->settings_btn, "MeeGoSettingsButton"); + data->settings_id = g_signal_connect (data->settings_btn, "toggled", + G_CALLBACK (settings_toggled), data); + + gtk_container_add (GTK_CONTAINER (data->settings_btn), + gtk_image_new_from_icon_name ("preferences-other-hover", + GTK_ICON_SIZE_DIALOG)); + item = gtk_tool_item_new (); + gtk_container_add (GTK_CONTAINER (item), data->settings_btn); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1); + + close_btn = gtk_button_new (); + gtk_widget_set_can_focus (close_btn, FALSE); + gtk_widget_set_name (close_btn, "MeeGoCloseButton"); + g_signal_connect (close_btn, "clicked", + G_CALLBACK (gtk_main_quit), NULL); + gtk_container_add (GTK_CONTAINER (close_btn), + gtk_image_new_from_icon_name ("window-close-hover", + GTK_ICON_SIZE_DIALOG)); + item = gtk_tool_item_new (); + gtk_container_add (GTK_CONTAINER (item), close_btn); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1); + + gtk_widget_show_all (toolbar); + + /* no need for close buttons */ + gtk_widget_hide (data->settings_close_btn); + gtk_widget_hide (data->emergency_close_btn); } +static void +show_emergency_view (app_data *data) +{ + update_emergency_view (data); + set_page (data, PAGE_EMERGENCY); +} + +static void +show_services_list (app_data *data, const char *config_id_to_open) +{ + g_free (data->config_id_to_open); + data->config_id_to_open = g_strdup (config_id_to_open); + set_page (data, PAGE_SETTINGS); + update_services_list (data); +} + +static void +show_main_view (app_data *data) +{ + set_page (data, PAGE_MAIN); +} #else @@ -869,6 +997,34 @@ setup_windows (app_data *data, g_signal_connect (data->emergency_win, "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), NULL); } + +static void +show_emergency_view (app_data *data) +{ + update_emergency_view (data); + gtk_widget_hide (data->services_win); + gtk_window_present (GTK_WINDOW (data->emergency_win)); +} + +static void +show_services_list (app_data *data, const char *config_id_to_open) +{ + g_free (data->config_id_to_open); + data->config_id_to_open = g_strdup (config_id_to_open); + + gtk_widget_hide (data->emergency_win); + gtk_window_present (GTK_WINDOW (data->services_win)); + update_services_list (data); +} + +static void +show_main_view (app_data *data) +{ + gtk_widget_hide (data->services_win); + gtk_widget_hide (data->emergency_win); + gtk_window_present (GTK_WINDOW (data->sync_win)); +} + #endif /* This is a hacky way to achieve autoscrolling when the expanders open/close */ @@ -1146,8 +1302,7 @@ init_ui (app_data *data) G_CALLBACK (services_box_allocate_cb), data); data->devices_box = GTK_WIDGET (gtk_builder_get_object (builder, "devices_box")); - - data->back_btn = GTK_WIDGET (gtk_builder_get_object (builder, "back_btn")); + data->settings_close_btn = GTK_WIDGET (gtk_builder_get_object (builder, "settings_close_btn")); /* emergency view */ btn = GTK_WIDGET (gtk_builder_get_object (builder, "slow_sync_btn")); @@ -1164,6 +1319,7 @@ init_ui (app_data *data) data->emergency_expander = GTK_WIDGET (gtk_builder_get_object (builder, "emergency_expander")); data->emergency_source_table = GTK_WIDGET (gtk_builder_get_object (builder, "emergency_source_table")); data->emergency_backup_table = GTK_WIDGET (gtk_builder_get_object (builder, "emergency_backup_table")); + data->emergency_close_btn = GTK_WIDGET (gtk_builder_get_object (builder, "emergency_close_btn")); /* No (documented) way to add own widgets to gtkbuilder it seems... swap the all dummy widgets with Muxwidgets */ @@ -1185,6 +1341,12 @@ init_ui (app_data *data) G_CALLBACK (emergency_clicked_cb), data); g_signal_connect (data->sync_btn, "clicked", G_CALLBACK (sync_clicked_cb), data); + g_signal_connect_swapped (data->emergency_close_btn, "clicked", + G_CALLBACK (show_main_view), data); + g_signal_connect_swapped (data->settings_close_btn, "clicked", + G_CALLBACK (show_main_view), data); + g_signal_connect (data->emergency_btn, "clicked", + G_CALLBACK (emergency_clicked_cb), data); data->new_device_btn = GTK_WIDGET (gtk_builder_get_object (builder, "new_device_btn")); g_signal_connect (data->new_device_btn, "clicked", @@ -2954,46 +3116,6 @@ start_session_cb (SyncevoServer *server, g_free (path); } -static void -show_emergency_view (app_data *data) -{ - update_emergency_view (data); -#ifdef USE_MOBLIN_UX - mux_window_set_current_page (MUX_WINDOW (data->sync_win), - data->emergency_index); -#else - gtk_widget_hide (data->services_win); - gtk_window_present (GTK_WINDOW (data->emergency_win)); -#endif -} - -static void -show_services_list (app_data *data, const char *config_id_to_open) -{ - g_free (data->config_id_to_open); - data->config_id_to_open = g_strdup (config_id_to_open); - -#ifdef USE_MOBLIN_UX - mux_window_set_settings_visible (MUX_WINDOW (data->sync_win), TRUE); -#else - gtk_widget_hide (data->emergency_win); - gtk_window_present (GTK_WINDOW (data->services_win)); - update_services_list (data); -#endif -} - -static void -show_main_view (app_data *data) -{ -#ifdef USE_MOBLIN_UX - mux_window_set_current_page (MUX_WINDOW (data->sync_win), -1); -#else - gtk_widget_hide (data->services_win); - gtk_widget_hide (data->emergency_win); -#endif - gtk_window_present (GTK_WINDOW (data->sync_win)); -} - /* TODO: this function should accept source/peer name as param */ char* get_error_string_for_code (int error_code, SyncErrorResponse *response) diff --git a/src/gtk-ui/sync-ui.rc b/src/gtk-ui/sync-ui.rc index 75723637..389c7049 100644 --- a/src/gtk-ui/sync-ui.rc +++ b/src/gtk-ui/sync-ui.rc @@ -1,12 +1,5 @@ # generic rules for MuxWidgets -style "mux-win" { - bg[NORMAL] = "#4a535a" - MuxWindow::title-bar-bg = "#333333" - MuxWindow::title-bar-fg = "#c2c2c2" -} -class "MuxWindow" style "mux-win" - style "mux-frame" { bg[NORMAL] = "#ffffff" bg[INSENSITIVE] = "#ffffff" @@ -18,6 +11,11 @@ class "MuxFrame" style "mux-frame" # sync-ui specific rules +style "meego-win" { + bg[NORMAL] = "#4a535a" +} +widget "meego_win" style "meego-win" + style "data-box" { bg[NORMAL] = "#ececec" bg[INSENSITIVE] = "#ececec" diff --git a/src/gtk-ui/ui.glade b/src/gtk-ui/ui.glade index 3ed99bb2..d632895c 100644 --- a/src/gtk-ui/ui.glade +++ b/src/gtk-ui/ui.glade @@ -4,314 +4,43 @@ 1024 - 5 Sync 800 550 - + True - 5 - + True - vertical + 4 + 4 - - True - 0 - none - - - True - vertical - - - True - - - 48 - 48 - True - - - True - gtk-missing-image - 6 - - - 0 - - - - - False - 10 - 0 - - - - - True - 0 - 0.20000000298023224 - True - end - 42 - - - False - 5 - 1 - - - - - True - 6 - vertical - 4 - - - - - - - - - False - False - 8 - end - 2 - - - - - False - 16 - 0 - - - - - True - vertical - - - True - - - True - vertical - - - True - - - True - vertical - - - True - vertical - - - - - - 0 - - - - - vertical - - - True - 0 - none - - - True - 5 - 12 - - - True - vertical - - - - - - - - - - - - - - - - - - - - label_item - - - - - False - False - 0 - - - - - - - - 1 - - - - - 55 - 0 - - - - - False - False - 6 - 0 - - - - - - - False - 0 - - - - - - - - False - 1 - - - - - - - True - True - - - label_item - - - - - 0 - - - - - 0 - - - - - 250 - True - vertical - 5 - - + True vertical - + True 0 - in + none - + True vertical - - True - vertical - - - True - - - True - 0 - - - False - False - 6 - 0 - - - - - 24 - True - vertical - - - True - gtk-missing-image - - - False - 0 - - - - - False - 1 - - - - - 0 - - - - - False - 10 - 0 - - - - + True - + + 48 + 48 True - vertical - - - - + + True + gtk-missing-image + 6 0 @@ -320,126 +49,172 @@ False - 5 + 10 0 - - - False - 5 - 1 - - - - - 25 - True - - 0.029999999329447746 + + True + 0 + 0.20000000298023224 + True end + 42 + False 5 + 1 + + + + + True + 6 + vertical + 4 + + + + + + + + + False + False + 8 end - 0 + 2 False - False - 2 + 16 + 0 - + True + vertical - + True - vertical - 10 - + True - 0 - <b>Actions</b> - True - - - 0 - - - - - Sync now - True - True - True - - - False - 1 - - - - - True - True - True + vertical - + True - Change or edit -sync service - center + + + True + vertical + + + True + vertical + + + + + + 0 + + + + + vertical + + + True + 0 + none + + + True + 5 + 12 + + + True + vertical + + + + + + + + + + + + + + + + + + + + label_item + + + + + False + False + 0 + + + + + + + + 1 + + + + + 55 + 0 + + + + False + False + 6 + 0 + - - False - 2 - - - - - Fix a sync -emergency - True - True - True - - - False - False - 3 - - 30 + False 0 + + + False - 20 - 3 + 1 - - - - - - - + True True @@ -457,11 +232,244 @@ emergency 0 + + + 250 + True + vertical + 5 + + + True + vertical + + + True + 0 + in + + + True + vertical + + + True + vertical + + + True + + + True + 0 + + + False + False + 6 + 0 + + + + + 24 + True + vertical + + + True + gtk-missing-image + + + False + 0 + + + + + False + 1 + + + + + 0 + + + + + False + 10 + 0 + + + + + True + + + True + vertical + + + + + + + + 0 + + + + + False + 5 + 0 + + + + + False + 5 + 1 + + + + + 25 + True + + + 0.029999999329447746 + end + + + 5 + end + 0 + + + + + False + False + 2 + + + + + True + + + True + vertical + 10 + + + True + 0 + <b>Actions</b> + True + + + 0 + + + + + Sync now + True + True + True + + + False + 1 + + + + + True + True + True + + + True + Change or edit +sync service + center + + + + + False + 2 + + + + + Fix a sync +emergency + True + True + True + + + False + False + 3 + + + + + 30 + 0 + + + + + False + 20 + 3 + + + + + + + + + + + + + True + True + + + label_item + + + + + 0 + + + + + 0 + + + + + False + end + 1 + + - False - end - 1 + 0 @@ -479,6 +487,7 @@ emergency True + 4 vertical @@ -750,6 +759,29 @@ you can setup a service manually. 0 + + + True + + + Close + True + True + True + + + False + 12 + end + 0 + + + + + False + 1 + + @@ -765,6 +797,7 @@ you can setup a service manually. True + 4 vertical @@ -1272,6 +1305,29 @@ local information 0 + + + True + + + Close + True + True + True + + + False + 12 + end + 0 + + + + + False + 1 + +