diff options
32 files changed, 81 insertions, 4899 deletions
diff --git a/data/css/endless-widgets.css b/data/css/endless-widgets.css index c820fbc..fe1a6fd 100644 --- a/data/css/endless-widgets.css +++ b/data/css/endless-widgets.css @@ -73,147 +73,3 @@ EosWindow { color-stop(0.95, rgb(71, 71, 71)), color-stop(0, rgb(67, 67, 67))); } - -/* Endless action button */ - -EosActionButton { - background-color: transparent; - border-style: solid; - border-image: none; - margin: 10px; - - border-radius: 40px; - border-width: 8px; -} - -EosActionButton GtkLabel { - font-weight: normal; - font-size: 13px; -} - -/* Endless action button: sizes */ - -EosActionButton.primary { - border-radius: 40px; - border-width: 8px; -} - -EosActionButton.secondary { - border-radius: 30px; - border-width: 6px; -} - -EosActionButton.tertiary { - border-radius: 23px; - border-width: 5px; -} - -EosActionButton.quaternary { - border-radius: 17px; - border-width: 4px; -} - -/* Endless action button: light background */ - -/* normal */ -EosActionButton, -EosActionButton:selected, -EosActionButton:focused { - border-color: alpha(#323232, 0.5); - box-shadow: 1px 1px 1px alpha(black, 0.8) inset, - 0px -1px 1px alpha(white, 0.65); -} - -EosActionButton GtkImage, -EosActionButton GtkImage:selected, -EosActionButton GtkImage:focused { - color: alpha(#323232, 0.5); -} - -EosActionButton GtkLabel, -EosActionButton GtkLabel:selected, -EosActionButton GtkLabel:focused { - color: alpha(#323232, 0.65); -} - -/* hover */ -EosActionButton:hover { - border-color: alpha(#323232, 0.8); - box-shadow: 1px 1px 1px alpha(black, 0.8) inset; -} - -EosActionButton GtkImage:hover { - color: alpha(#282828, 0.8); -} - -EosActionButton GtkLabel:hover { - color: alpha(#1E1E1E, 0.8); -} - -/* pressed */ -EosActionButton:active { - border-color: alpha(#323232, 0.65); - box-shadow: 1px 1px 1px alpha(black, 0.8) inset; -} - -EosActionButton GtkImage:active { - color: alpha(#282828, 0.65); -} - -EosActionButton GtkLabel:active { - color: alpha(#1E1E1E, 0.8); -} - -/* insensitive, just in case */ -EosActionButton:insensitive, -EosActionButton:inconsistent { - border-color: alpha(#888888, 0.50); - box-shadow: none; -} - -/* Endless action button: dark background */ - -/* normal */ -.dark EosActionButton, -.dark EosActionButton:selected, -.dark EosActionButton:focused { - border-color: alpha(#E6E6E6, 0.5); - box-shadow: 1px 1px 1px alpha(black, 0.95) inset, - 0px -1px 1px alpha(white, 0.5) inset; -} - -.dark EosActionButton GtkImage, -.dark EosActionButton GtkImage:selected, -.dark EosActionButton GtkImage:selected, -.dark EosActionButton GtkLabel, -.dark EosActionButton GtkLabel:selected, -.dark EosActionButton GtkLabel:focused { - color: alpha(#E6E6E6, 0.5); -} - -/* hover */ -.dark EosActionButton:hover { - border-color: alpha(white, 0.8); - box-shadow: 1px 1px 1px alpha(black, 0.95) inset, - 0px -1px 1px alpha(white, 0.85) inset; -} - -.dark EosActionButton GtkImage:hover, -.dark EosActionButton GtkLabel:hover { - color: alpha(white, 0.8); -} - -/* pressed */ -.dark EosActionButton:active { - border-color: alpha(white, 0.65); - box-shadow: 1px 1px 1px alpha(black, 0.95) inset, - 0px -1px 1px alpha(white, 0.7) inset; -} - -.dark EosActionButton GtkImage:active { - color: alpha(white, 0.65); -} - -.dark EosActionButton GtkLabel:active { - color: alpha(white, 0.8); -} diff --git a/docs/reference/endless/endless-docs.xml b/docs/reference/endless/endless-docs.xml index f946d1f..bf70d99 100644 --- a/docs/reference/endless/endless-docs.xml +++ b/docs/reference/endless/endless-docs.xml @@ -20,8 +20,6 @@ <xi:include href="xml/application.xml"/> <xi:include href="xml/window.xml"/> <xi:include href="xml/page-manager.xml"/> - <xi:include href="xml/splash-page-manager.xml"/> - <xi:include href="xml/action-button.xml"/> <xi:include href="xml/flexy-grid.xml"/> <xi:include href="xml/custom-container.xml"/> <!--<xi:include href="xml/hello.xml"/>--> diff --git a/docs/reference/endless/endless-sections.txt b/docs/reference/endless/endless-sections.txt index 9715286..e838adb 100644 --- a/docs/reference/endless/endless-sections.txt +++ b/docs/reference/endless/endless-sections.txt @@ -58,16 +58,6 @@ EosWindowPrivate <FILE>page-manager</FILE> EosPageManager eos_page_manager_new -eos_page_manager_get_visible_page -eos_page_manager_set_visible_page -eos_page_manager_get_visible_page_name -eos_page_manager_set_visible_page_name -eos_page_manager_get_page_name -eos_page_manager_set_page_name -eos_page_manager_get_page_actions -eos_page_manager_set_page_actions -eos_page_manager_get_page_custom_toolbox_widget -eos_page_manager_set_page_custom_toolbox_widget eos_page_manager_get_page_left_topbar_widget eos_page_manager_set_page_left_topbar_widget eos_page_manager_get_page_center_topbar_widget @@ -80,12 +70,7 @@ eos_page_manager_get_page_background_position eos_page_manager_set_page_background_position eos_page_manager_get_page_background_repeats eos_page_manager_set_page_background_repeats -eos_page_manager_get_transition_duration -eos_page_manager_set_transition_duration -eos_page_manager_get_transition_type -eos_page_manager_set_transition_type eos_page_manager_remove_page_by_name -EosPageManagerTransitionType <SUBSECTION Standard> EOS_IS_PAGE_MANAGER EOS_IS_PAGE_MANAGER_CLASS @@ -93,64 +78,13 @@ EOS_PAGE_MANAGER EOS_PAGE_MANAGER_CLASS EOS_PAGE_MANAGER_GET_CLASS EOS_TYPE_PAGE_MANAGER -EOS_TYPE_PAGE_MANAGER_TRANSITION_TYPE EosPageManagerClass eos_page_manager_get_type -eos_page_manager_transition_type_get_type <SUBSECTION Private> EosPageManagerPrivate </SECTION> <SECTION> -<FILE>splash-page-manager</FILE> -EosSplashPageManager -eos_splash_page_manager_new -eos_splash_page_manager_get_splash_page -eos_splash_page_manager_set_splash_page -eos_splash_page_manager_get_main_page -eos_splash_page_manager_set_main_page -eos_splash_page_manager_show_main_page -eos_splash_page_manager_show_splash_page -<SUBSECTION Standard> -EOS_IS_SPLASH_PAGE_MANAGER -EOS_IS_SPLASH_PAGE_MANAGER_CLASS -EOS_SPLASH_PAGE_MANAGER -EOS_SPLASH_PAGE_MANAGER_CLASS -EOS_SPLASH_PAGE_MANAGER_GET_CLASS -EOS_TYPE_SPLASH_PAGE_MANAGER -EosSplashPageManagerClass -eos_splash_page_manager_get_type -<SUBSECTION Private> -EosSplashPageManagerPrivate -</SECTION> - -<SECTION> -<FILE>action-button</FILE> -EosActionButton -eos_action_button_new -eos_action_button_get_icon_id -eos_action_button_set_icon_id -eos_action_button_get_label -eos_action_button_set_label -eos_action_button_get_size -eos_action_button_set_size -eos_action_button_get_label_position -eos_action_button_set_label_position -EosActionButtonSize -<SUBSECTION Standard> -EOS_ACTION_BUTTON -EOS_ACTION_BUTTON_CLASS -EOS_ACTION_BUTTON_GET_CLASS -EOS_IS_ACTION_BUTTON -EOS_IS_ACTION_BUTTON_CLASS -EOS_TYPE_ACTION_BUTTON -EosActionButtonClass -eos_action_button_get_type -<SUBSECTION Private> -EosActionButtonPrivate -</SECTION> - -<SECTION> <FILE>flexy-grid</FILE> EosFlexyGrid EosFlexyGridCell diff --git a/endless/Makefile.am b/endless/Makefile.am index 74d8b3c..35e31d0 100644 --- a/endless/Makefile.am +++ b/endless/Makefile.am @@ -26,16 +26,13 @@ endless_public_installed_headers = endless/endless.h endless_private_installed_headers = \ endless/eosversion.h \ - endless/eosactionbutton.h \ endless/eosapplication.h \ endless/eoscustomcontainer.h \ endless/eosenums.h \ endless/eosmacros.h \ endless/eospagemanager.h \ - endless/eossplashpagemanager.h \ endless/eostypes.h \ endless/eoswindow.h \ - endless/eosactionmenu-private.h \ endless/eosflexygrid.h endless_library_sources = \ @@ -43,13 +40,9 @@ endless_library_sources = \ endless/eoscustomcontainer.c \ endless/eoshello.c \ endless/eosinit.c endless/eosinit-private.h \ - endless/eospagemanager.c endless/eospagemanager-private.h \ - endless/eosmainarea.c endless/eosmainarea-private.h \ + endless/eospagemanager.c \ endless/eosresource.c endless/eosresource-private.h \ - endless/eossplashpagemanager.c \ endless/eostopbar.c endless/eostopbar-private.h \ - endless/eosactionbutton.c \ - endless/eosactionmenu.c \ endless/eoswindow.c \ endless/eosflexygrid.c endless/eosflexygridcell.c endless/eosflexygrid-private.h diff --git a/endless/endless.h b/endless/endless.h index f3f2061..c2b4f6d 100644 --- a/endless/endless.h +++ b/endless/endless.h @@ -12,11 +12,9 @@ G_BEGIN_DECLS /* Pull in other header files */ #include "eostypes.h" -#include "eosactionbutton.h" #include "eosapplication.h" #include "eosflexygrid.h" #include "eospagemanager.h" -#include "eossplashpagemanager.h" #include "eoswindow.h" #include "eoscustomcontainer.h" diff --git a/endless/eosactionbutton.c b/endless/eosactionbutton.c deleted file mode 100644 index db28312..0000000 --- a/endless/eosactionbutton.c +++ /dev/null @@ -1,770 +0,0 @@ -/* Copyright 2013 Endless Mobile, Inc. */ - -#include "config.h" -#include "eosactionbutton.h" - -#include <glib-object.h> -#include <gtk/gtk.h> -#include <math.h> - -/** - * SECTION:action-button - * @short_description: Buttons that the user recognizes as performing actions - * @title: Action buttons - * - * Any time you want to inform your user which actions are available, use an - * action button. - * For example, suppose you had a page in your application where the user could - * draw a picture. - * After finishing the picture, the user could save it or share it on Facebook. - * In that case, you would use two action buttons, labeled for example - * <quote>SAVE</quote> and <quote>SHARE</quote>, and containing icons - * representing saving and sharing. - * - * The buttons have a recognizable style and round border, so that it is - * instantly clear to the user that they represent actions. - * - * Generally, you should set the #EosPageManager:actions property on the page - * that you want to use action buttons on; this neatly arranges the actions - * in an action area on the right-hand side of the screen, placing the main - * action in a prominent place, and actions such as <quote>cancel</quote> on the - * bottom. - * However, you can also manually place action buttons anywhere on a page. - */ - -#define _EOS_STYLE_CLASS_ACTION_BUTTON "action-button" - -typedef struct { - /* properties */ - EosActionButtonSize size; - gchar *label; - gchar *icon_id; - GtkPositionType label_pos; - - /* internal */ - GtkWidget *grid; - GtkWidget *icon_image; - GtkWidget *label_widget; -} EosActionButtonPrivate; - -G_DEFINE_TYPE_WITH_PRIVATE (EosActionButton, eos_action_button, GTK_TYPE_BUTTON) - -typedef struct _EosActionButtonSizeDefinition EosActionButtonSizeDefinition; - -struct _EosActionButtonSizeDefinition -{ - EosActionButtonSize size; - gchar *name; - - gint width; - gint height; - gint icon_size; - gint border_width; -}; - -static EosActionButtonSizeDefinition *icon_sizes = NULL; - - -enum { - PROP_0, - PROP_SIZE, - PROP_LABEL, - PROP_LABEL_POS, - PROP_ICON_ID -}; - -static void -eos_action_button_dispose (GObject *object); - -static void -eos_action_button_finalize (GObject *object); - -static void -eos_action_button_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec); - -static void -eos_action_button_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec); - -static void -eos_action_button_get_preferred_width (GtkWidget *widget, - gint *minimum_size, - gint *natural_size); - -static void -eos_action_button_get_preferred_height (GtkWidget *widget, - gint *minimum_size, - gint *natural_size); - -static gboolean -eos_action_button_draw (GtkWidget *widget, - cairo_t *cr); - -/* ******* INIT ******* */ - -static void -eos_action_button_class_init (EosActionButtonClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - object_class->get_property = eos_action_button_get_property; - object_class->set_property = eos_action_button_set_property; - object_class->dispose = eos_action_button_dispose; - object_class->finalize = eos_action_button_finalize; - - widget_class->draw = eos_action_button_draw; - widget_class->get_preferred_width = eos_action_button_get_preferred_width; - widget_class->get_preferred_height = eos_action_button_get_preferred_height; - - /** - * EosActionButton:size: - * - * Size for the action button; use #EosActionButtonSize to specify that the - * button represents a primary action, secondary, tertiary, or quaternary. - * #EOS_ACTION_BUTTON_SIZE_PRIMARY is the largest, and - * #EOS_ACTION_BUTTON_SIZE_QUATERNARY is the smallest (seldom used.) - */ - g_object_class_install_property (object_class, - PROP_SIZE, - g_param_spec_int ("size", - "Size", - "Size of the button", - EOS_ACTION_BUTTON_SIZE_PRIMARY, - EOS_ACTION_BUTTON_SIZE_QUATERNARY, - EOS_ACTION_BUTTON_SIZE_SECONDARY, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - - /** - * EosActionButton:label: - * - * Text for the label that is placed below or to the side of the button. - */ - g_object_class_install_property (object_class, - PROP_LABEL, - g_param_spec_string ("label", - "Label", - "Text of the label widget beneath the button", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - - /** - * EosActionButton:label-position: - * - * Position of the label in the button. - */ - g_object_class_install_property (object_class, - PROP_LABEL_POS, - g_param_spec_enum ("label-position", - "Label position", - "Position of the label inside the button", - GTK_TYPE_POSITION_TYPE, - GTK_POS_BOTTOM, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - - /** - * EosActionButton:icon-id: - * - * Icon name for the icon that is drawn within the circular button. - */ - g_object_class_install_property (object_class, - PROP_ICON_ID, - g_param_spec_string ("icon-id", - "Icon id", - "ID used to pick an icon for the button", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - - // init icon sizes, inspired by gtkiconfactory.c - if (icon_sizes == NULL) - { - icon_sizes = g_new (EosActionButtonSizeDefinition, EOS_ACTION_BUTTON_SIZE_NUM_SIZES); - - icon_sizes[EOS_ACTION_BUTTON_SIZE_PRIMARY].size = EOS_ACTION_BUTTON_SIZE_PRIMARY; - icon_sizes[EOS_ACTION_BUTTON_SIZE_PRIMARY].name = "primary"; - icon_sizes[EOS_ACTION_BUTTON_SIZE_PRIMARY].width = 64; - icon_sizes[EOS_ACTION_BUTTON_SIZE_PRIMARY].height = 64; - icon_sizes[EOS_ACTION_BUTTON_SIZE_PRIMARY].icon_size = 36; - icon_sizes[EOS_ACTION_BUTTON_SIZE_PRIMARY].border_width = 8; - - icon_sizes[EOS_ACTION_BUTTON_SIZE_SECONDARY].size = EOS_ACTION_BUTTON_SIZE_SECONDARY; - icon_sizes[EOS_ACTION_BUTTON_SIZE_SECONDARY].name = "secondary"; - icon_sizes[EOS_ACTION_BUTTON_SIZE_SECONDARY].width = 48; - icon_sizes[EOS_ACTION_BUTTON_SIZE_SECONDARY].height = 48; - icon_sizes[EOS_ACTION_BUTTON_SIZE_SECONDARY].icon_size = 26; - icon_sizes[EOS_ACTION_BUTTON_SIZE_SECONDARY].border_width = 6; - - icon_sizes[EOS_ACTION_BUTTON_SIZE_TERTIARY].size = EOS_ACTION_BUTTON_SIZE_TERTIARY; - icon_sizes[EOS_ACTION_BUTTON_SIZE_TERTIARY].name = "tertiary"; - icon_sizes[EOS_ACTION_BUTTON_SIZE_TERTIARY].width = 36; - icon_sizes[EOS_ACTION_BUTTON_SIZE_TERTIARY].height = 36; - icon_sizes[EOS_ACTION_BUTTON_SIZE_TERTIARY].icon_size = 18; - icon_sizes[EOS_ACTION_BUTTON_SIZE_TERTIARY].border_width = 5; - - icon_sizes[EOS_ACTION_BUTTON_SIZE_QUATERNARY].size = EOS_ACTION_BUTTON_SIZE_QUATERNARY; - icon_sizes[EOS_ACTION_BUTTON_SIZE_QUATERNARY].name = "quaternary"; - icon_sizes[EOS_ACTION_BUTTON_SIZE_QUATERNARY].width = 26; - icon_sizes[EOS_ACTION_BUTTON_SIZE_QUATERNARY].height = 26; - icon_sizes[EOS_ACTION_BUTTON_SIZE_QUATERNARY].icon_size = 12; - icon_sizes[EOS_ACTION_BUTTON_SIZE_QUATERNARY].border_width = 4; - } -} - -static void -eos_action_button_init (EosActionButton *self) -{ - EosActionButtonPrivate *priv = eos_action_button_get_instance_private (self); - GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (self)); - - gtk_style_context_add_class (context, _EOS_STYLE_CLASS_ACTION_BUTTON); - - priv->icon_image = gtk_image_new(); - priv->label_widget = GTK_WIDGET (gtk_label_new ("")); - - priv->grid = gtk_grid_new (); - gtk_grid_attach(GTK_GRID (priv->grid), priv->icon_image, 0, 0, 1, 1); - - // TODO positioning is not really working right, it will be done manually in draw () - // which means that this will not work as intended: - gtk_grid_attach_next_to (GTK_GRID (priv->grid), - priv->label_widget, priv->icon_image, - priv->label_pos, 1, 1); - - gtk_container_add (GTK_CONTAINER (self), - GTK_WIDGET (priv->grid)); - - gtk_widget_set_hexpand (GTK_WIDGET(self), FALSE); - gtk_widget_set_halign (GTK_WIDGET(self), GTK_ALIGN_CENTER); - gtk_widget_set_vexpand (GTK_WIDGET(self), FALSE); - gtk_widget_set_valign (GTK_WIDGET(self), GTK_ALIGN_CENTER); -} - -/* ******* LIFECYCLE ******* */ - -/** - * eos_action_button_new: - * @size: size for the button: primary, secondary, et cetera - * @label: text to place under or beside the action button - * @icon_id: icon name for the icon inside the action button - * - * Convenience function for creating an action button with the size, label, and - * icon already set. - * - * Returns: a pointer to the newly-created widget. - */ -GtkWidget * -eos_action_button_new (EosActionButtonSize size, - const gchar *label, - const gchar *icon_id) -{ - return g_object_new (EOS_TYPE_ACTION_BUTTON, - "size", size, - "label", label, - "icon-id", icon_id, - NULL); -} - -static void -eos_action_button_dispose (GObject *object) -{ - G_OBJECT_CLASS (eos_action_button_parent_class)->dispose (object); -} - -static void -eos_action_button_finalize (GObject *object) -{ - G_OBJECT_CLASS (eos_action_button_parent_class)->finalize (object); -} - -/* ******* PROPERTIES ******* */ - -static void -eos_action_button_load_icon (EosActionButton *button) -{ - g_return_if_fail (EOS_IS_ACTION_BUTTON (button)); - - EosActionButtonPrivate *priv = eos_action_button_get_instance_private (button); - - if (priv->icon_id != NULL) - { - gtk_image_set_from_icon_name (GTK_IMAGE (priv->icon_image), - priv->icon_id, - GTK_ICON_SIZE_BUTTON); - - gtk_image_set_pixel_size (GTK_IMAGE (priv->icon_image), - icon_sizes[priv->size].icon_size); - } - else - { - gtk_image_clear (GTK_IMAGE (priv->icon_image)); - } -} - -/** - * eos_action_button_set_size: - * @button: the button - * @size: a value from #EosActionButtonSize - * - * Sets the size of the button (e.g. secondary). - * See #EosActionButton:size for more information. - */ -void -eos_action_button_set_size (EosActionButton *button, - EosActionButtonSize size) -{ - g_return_if_fail (EOS_IS_ACTION_BUTTON (button)); - - int old_size; - EosActionButtonPrivate *priv = eos_action_button_get_instance_private (button); - - old_size = priv->size; - priv->size = size; - - // remove the old style class and set the new one - GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (button)); - gtk_style_context_remove_class (context, icon_sizes[old_size].name); - gtk_style_context_add_class (context, icon_sizes[priv->size].name); - - if (old_size != priv->size) - { - eos_action_button_load_icon (button); - - g_object_notify (G_OBJECT (button), "size"); - gtk_widget_queue_resize(GTK_WIDGET (button)); - } -} - -/** - * eos_action_button_get_size: - * @button: the button - * - * Gets the size of the button (e.g. secondary). - * See #EosActionButton:size for more information. - * - * Returns: the size as a value from #EosActionButtonSize - */ -EosActionButtonSize -eos_action_button_get_size (EosActionButton *button) -{ - g_return_val_if_fail (EOS_IS_ACTION_BUTTON (button), -1); - - EosActionButtonPrivate *priv = eos_action_button_get_instance_private (button); - return priv->size; -} - -/** - * eos_action_button_set_label: - * @button: the button - * @label: text for the label - * - * Sets the text showing below or beside the button. - * See #EosActionButton:label for more information. - */ -void -eos_action_button_set_label (EosActionButton *button, const gchar *label) -{ - g_return_if_fail (EOS_IS_ACTION_BUTTON (button)); - - EosActionButtonPrivate *priv = eos_action_button_get_instance_private (button); - gchar *new_label = g_strdup (label); - g_free (priv->label); - priv->label = new_label; - - gtk_label_set_text (GTK_LABEL (priv->label_widget), priv->label); - - g_object_notify (G_OBJECT (button), "label"); -} - -/** - * eos_action_button_get_label: - * @button: the button - * - * Gets the text showing below or beside the button. - * See #EosActionButton:label for more information. - * - * Returns: the label text - */ -const gchar * -eos_action_button_get_label (EosActionButton *button) -{ - g_return_val_if_fail (EOS_IS_ACTION_BUTTON (button), NULL); - - EosActionButtonPrivate *priv = eos_action_button_get_instance_private (button); - return priv->label; -} - -/** - * eos_action_button_set_label_position: - * @button: the button - * @position: position of the label: top, bottom, left or right - * - * Changes the position of the label to be above, below, or to one side of the - * action button. - * See #EosActionButton:label-position for more information. - */ -void -eos_action_button_set_label_position (EosActionButton *button, - GtkPositionType position) -{ - g_return_if_fail (EOS_IS_ACTION_BUTTON (button)); - - EosActionButtonPrivate *priv = eos_action_button_get_instance_private (button); - - if (priv->label_pos != position) - { - g_object_ref (G_OBJECT (priv->label_widget)); - gtk_container_remove (GTK_CONTAINER (priv->grid), priv->label_widget); - gtk_grid_attach_next_to (GTK_GRID (priv->grid), - priv->label_widget, priv->icon_image, - position, 1, 1); - g_object_unref (G_OBJECT (priv->label_widget)); - - priv->label_pos = position; - - // we need to keep the buttons aligned - if (priv->label_pos == GTK_POS_LEFT) - { - gtk_widget_set_halign (GTK_WIDGET(button), GTK_ALIGN_END); - } - else if (priv->label_pos == GTK_POS_RIGHT) - { - gtk_widget_set_halign (GTK_WIDGET(button), GTK_ALIGN_START); - } - else - { - gtk_widget_set_halign (GTK_WIDGET(button), GTK_ALIGN_CENTER); - } - } -} - -/** - * eos_action_button_get_label_position: - * @button: the button - * - * Gets the position of the label respective to the button. - * See #EosActionButton:label-position for more information. - * - * Returns: the position of the label: top, bottom, left, or right - */ -GtkPositionType -eos_action_button_get_label_position (EosActionButton *button) -{ - g_return_val_if_fail (EOS_IS_ACTION_BUTTON (button), -1); - - EosActionButtonPrivate *priv = eos_action_button_get_instance_private (button); - return priv->label_pos; -} - -/** - * eos_action_button_set_icon_id: - * @button: the button - * @icon_id: an icon name - * - * Sets a new icon showing in the button, specified by icon name. - * See #EosActionButton:icon-id for more information. - */ -void -eos_action_button_set_icon_id (EosActionButton *button, - const gchar* icon_id) -{ - g_return_if_fail (EOS_IS_ACTION_BUTTON (button)); - EosActionButtonPrivate *priv = eos_action_button_get_instance_private (button); - - if (g_strcmp0 (icon_id, priv->icon_id) != 0) - { - g_free (priv->icon_id); - priv->icon_id = g_strdup (icon_id); - - eos_action_button_load_icon (button); - g_object_notify (G_OBJECT (button), "icon-id"); - } -} - -/** - * eos_action_button_get_icon_id: - * @button: the button - * - * Gets the icon name for the icon showing in the button. - * See #EosActionButton:icon-id for more information. - * - * Returns: an icon name - */ -const gchar * -eos_action_button_get_icon_id (EosActionButton *button) -{ - g_return_val_if_fail (EOS_IS_ACTION_BUTTON (button), NULL); - - EosActionButtonPrivate *priv = eos_action_button_get_instance_private (button); - return priv->icon_id; -} - -static void -eos_action_button_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - EosActionButton *button = EOS_ACTION_BUTTON (object); - EosActionButtonPrivate *priv = eos_action_button_get_instance_private (button); - - switch (property_id) - { - case PROP_SIZE: - g_value_set_int (value, priv->size); - break; - case PROP_LABEL: - g_value_set_string (value, priv->label); - break; - case PROP_LABEL_POS : - g_value_set_enum (value, priv->label_pos); - break; - case PROP_ICON_ID: - g_value_set_string (value, priv->icon_id); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - } -} - -static void -eos_action_button_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - EosActionButton *button = EOS_ACTION_BUTTON (object); - - switch (property_id) - { - case PROP_SIZE : - eos_action_button_set_size (button, g_value_get_int (value)); - break; - case PROP_LABEL : - eos_action_button_set_label (button, g_value_get_string (value)); - break; - case PROP_LABEL_POS : - eos_action_button_set_label_position (button, g_value_get_enum (value)); - break; - case PROP_ICON_ID : - eos_action_button_set_icon_id (button, g_value_get_string (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - } -} - -/* ******* EXTENDED METHODS ******* */ - -static void -eos_action_button_get_real_size (GtkWidget *widget, - GtkOrientation orientation, - gint *minimum_size, - gint *natural_size) -{ - EosActionButton *button = EOS_ACTION_BUTTON (widget); - EosActionButtonPrivate *priv = eos_action_button_get_instance_private (button); - GtkBorder margin; - GtkAllocation label_allocation; - GtkStyleContext *context = gtk_widget_get_style_context (widget); - - gtk_style_context_get_margin(context, - gtk_style_context_get_state (context), - &margin); - - gtk_widget_get_allocation (priv->label_widget, &label_allocation); - - if (orientation == GTK_ORIENTATION_HORIZONTAL) - { - gint hsize = 0; - - if (priv->label_pos == GTK_POS_LEFT || priv->label_pos == GTK_POS_RIGHT) - { - hsize = margin.left + label_allocation.width - + margin.left + icon_sizes[priv->size].width + margin.right; - } - else if (priv->label_pos == GTK_POS_TOP || priv->label_pos == GTK_POS_BOTTOM) - { - hsize = margin.left + margin.right + MAX (icon_sizes[priv->size].width, - label_allocation.width); - } - - if (minimum_size) - *minimum_size = hsize; - - if (natural_size) - *natural_size = hsize; - } - else if (orientation == GTK_ORIENTATION_VERTICAL) - { - gint vsize = 0; - - if (priv->label_pos == GTK_POS_LEFT || priv->label_pos == GTK_POS_RIGHT) - { - vsize = margin.top + margin.bottom + MAX (icon_sizes[priv->size].height, - label_allocation.height); - } - else if (priv->label_pos == GTK_POS_TOP || priv->label_pos == GTK_POS_BOTTOM) - { - vsize = margin.top + icon_sizes[priv->size].height + margin.bottom - + label_allocation.height + margin.bottom; - } - - if (minimum_size) - *minimum_size = vsize; - - if (natural_size) - *natural_size = vsize; - - } -} - -static void -eos_action_button_get_preferred_width (GtkWidget *widget, - gint *minimum_size, - gint *natural_size) -{ - eos_action_button_get_real_size (widget, GTK_ORIENTATION_HORIZONTAL, - minimum_size, natural_size); -} - -static void -eos_action_button_get_preferred_height (GtkWidget *widget, - gint *minimum_size, - gint *natural_size) -{ - eos_action_button_get_real_size (widget, GTK_ORIENTATION_VERTICAL, - minimum_size, natural_size); -} - -static gboolean -eos_action_button_draw (GtkWidget *widget, - cairo_t *cr) -{ - EosActionButton *button = EOS_ACTION_BUTTON (widget); - EosActionButtonPrivate *priv = eos_action_button_get_instance_private (button); - - gint x, y; - gint frame_x = 0, frame_y = 0, bg_x = 0, bg_y = 0, icon_x = 0, icon_y = 0, label_x = 0, label_y = 0; - gint width, height, border_width, border_height, border_thickness; - GtkBorder margin; - GtkAllocation allocation, icon_allocation, label_allocation; - GtkStyleContext *context; - GtkStateFlags state; - - context = gtk_widget_get_style_context (widget); - state = gtk_style_context_get_state (context); - - gtk_style_context_get_margin(context, state, &margin); - - gtk_widget_get_allocation (widget, &allocation); - - x = 0; - y = 0; - width = allocation.width; - height = allocation.height; - - border_width = icon_sizes[priv->size].width; - border_height = icon_sizes[priv->size].height; - border_thickness = icon_sizes[priv->size].border_width; - - // calculate the location of background frame, icon and text label - gtk_widget_get_allocation (priv->icon_image, &icon_allocation); - gtk_widget_get_allocation (priv->label_widget, &label_allocation); - - if (priv->label_pos == GTK_POS_BOTTOM) - { - frame_x = x + (width - border_width)/2; - frame_y = y + margin.top; - - bg_x = frame_x - border_thickness; - bg_y = frame_y - border_thickness; - - icon_x = x + (width - icon_allocation.width) / 2; - icon_y = frame_y + (icon_sizes[priv->size].height - icon_allocation.height) / 2; - - label_x = x + (width - label_allocation.width)/2; - label_y = frame_y + icon_sizes[priv->size].height + margin.bottom; - } - else if (priv->label_pos == GTK_POS_TOP) - { - frame_x = x + (width - border_width)/2; - frame_y = y + margin.top + label_allocation.height + margin.bottom; - - bg_x = frame_x - border_thickness; - bg_y = frame_y - border_thickness; - - icon_x = x + (width - icon_allocation.width) / 2; - icon_y = frame_y + (icon_sizes[priv->size].height - icon_allocation.height) / 2; - - label_x = x + (width - label_allocation.width)/2; - label_y = y + margin.top; - } - else if (priv->label_pos == GTK_POS_LEFT) - { - frame_x = x + margin.left + label_allocation.width + margin.left; - frame_y = y + (height - border_height)/2; - - bg_x = frame_x - border_thickness; - bg_y = frame_y - border_thickness; - - icon_x = frame_x + (icon_sizes[priv->size].width - icon_allocation.width) / 2; - icon_y = y + (height - icon_allocation.height) / 2;; - - label_x = x + margin.left; - label_y = y + (height - label_allocation.height)/2;; - } - else if (priv->label_pos == GTK_POS_RIGHT) - { - frame_x = x + margin.left; - frame_y = y + (height - border_height)/2; - - bg_x = frame_x - border_thickness; - bg_y = frame_y - border_thickness; - - icon_x = frame_x + (icon_sizes[priv->size].width - icon_allocation.width) / 2; - icon_y = y + (height - icon_allocation.height) / 2;; - - label_x = x + margin.left + icon_sizes[priv->size].width + margin.left; - label_y = y + (height - label_allocation.height)/2;; - } - - cairo_save (cr); - - gtk_render_frame (context, cr, frame_x, frame_y, border_width, border_height); - - cairo_restore (cr); - cairo_save (cr); - - // GTK+ tries to paint the background inside the border, we work around this - //because we want to draw the inset shadow over the border itself - gtk_render_background (context, cr, bg_x, bg_y, - border_width + 2*border_thickness, - border_height + 2*border_thickness); - - cairo_restore (cr); - cairo_save (cr); - - // *** image - - cairo_translate (cr, icon_x, icon_y); - - gtk_widget_draw (GTK_WIDGET (priv->icon_image), cr); - - cairo_restore (cr); - cairo_save (cr); - - // *** label - - cairo_translate (cr, label_x, label_y); - - gtk_widget_draw (GTK_WIDGET (priv->label_widget), cr); - - cairo_restore (cr); - - return FALSE; -} diff --git a/endless/eosactionbutton.h b/endless/eosactionbutton.h deleted file mode 100644 index c5276a1..0000000 --- a/endless/eosactionbutton.h +++ /dev/null @@ -1,93 +0,0 @@ -/* Copyright 2013 Endless Mobile, Inc. */ - -#ifndef EOS_ACTION_BUTTON_H -#define EOS_ACTION_BUTTON_H - -#include "eostypes.h" - -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -#define EOS_TYPE_ACTION_BUTTON eos_action_button_get_type() - -#define EOS_ACTION_BUTTON(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - EOS_TYPE_ACTION_BUTTON, EosActionButton)) - -#define EOS_ACTION_BUTTON_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), \ - EOS_TYPE_ACTION_BUTTON, EosActionButtonClass)) - -#define EOS_IS_ACTION_BUTTON(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - EOS_TYPE_ACTION_BUTTON)) - -#define EOS_IS_ACTION_BUTTON_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), \ - EOS_TYPE_ACTION_BUTTON)) - -#define EOS_ACTION_BUTTON_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - EOS_TYPE_ACTION_BUTTON, EosActionButtonClass)) - -typedef struct _EosActionButton EosActionButton; -typedef struct _EosActionButtonClass EosActionButtonClass; - -/** - * EosActionButton: - * - * This class structure contains no public members. - */ -struct _EosActionButton -{ - GtkButton parent; -}; - -struct _EosActionButtonClass -{ - GtkButtonClass parent_class; - - /* For further expansion */ - gpointer _padding[8]; -}; - -EOS_SDK_ALL_API_VERSIONS -GType eos_action_button_get_type (void) G_GNUC_CONST; - -EOS_SDK_ALL_API_VERSIONS -GtkWidget *eos_action_button_new (EosActionButtonSize size, - const gchar *label, - const gchar *icon_id); - -EOS_SDK_ALL_API_VERSIONS -void eos_action_button_set_size (EosActionButton *button, - EosActionButtonSize size); - -EOS_SDK_ALL_API_VERSIONS -EosActionButtonSize eos_action_button_get_size (EosActionButton *button); - -EOS_SDK_ALL_API_VERSIONS -void eos_action_button_set_label (EosActionButton *button, - const gchar *label); - -EOS_SDK_ALL_API_VERSIONS -const gchar *eos_action_button_get_label (EosActionButton *button); - -EOS_SDK_ALL_API_VERSIONS -void eos_action_button_set_label_position (EosActionButton *button, - GtkPositionType position); - -EOS_SDK_ALL_API_VERSIONS -GtkPositionType eos_action_button_get_label_position (EosActionButton *button); - -EOS_SDK_ALL_API_VERSIONS -void eos_action_button_set_icon_id (EosActionButton *button, - const gchar *icon_id); - -EOS_SDK_ALL_API_VERSIONS -const gchar *eos_action_button_get_icon_id (EosActionButton *button); - -G_END_DECLS - -#endif /* EOS_ACTION_BUTTON_H */ diff --git a/endless/eosactionmenu-private.h b/endless/eosactionmenu-private.h deleted file mode 100644 index f6e84d0..0000000 --- a/endless/eosactionmenu-private.h +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright 2013 Endless Mobile, Inc. */ - -#ifndef EOS_ACTION_MENU_H -#define EOS_ACTION_MENU_H - -#include "eostypes.h" - -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -#define EOS_TYPE_ACTION_MENU eos_action_menu_get_type() - -#define EOS_ACTION_MENU(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - EOS_TYPE_ACTION_MENU, EosActionMenu)) - -#define EOS_ACTION_MENU_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), \ - EOS_TYPE_ACTION_MENU, EosActionMenuClass)) - -#define EOS_IS_ACTION_MENU(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - EOS_TYPE_ACTION_MENU)) - -#define EOS_IS_ACTION_MENU_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), \ - EOS_TYPE_ACTION_MENU)) - -#define EOS_ACTION_MENU_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - EOS_TYPE_ACTION_MENU, EosActionMenuClass)) - -typedef struct _EosActionMenu EosActionMenu; -typedef struct _EosActionMenuClass EosActionMenuClass; - -struct _EosActionMenu -{ - GtkFrame parent; -}; - -struct _EosActionMenuClass -{ - GtkFrameClass parent_class; -}; - -GType eos_action_menu_get_type (void) G_GNUC_CONST; - -GtkWidget *eos_action_menu_new (); - -void eos_action_menu_add_action (EosActionMenu *menu, - GtkAction *action); - -GtkAction *eos_action_menu_get_action (EosActionMenu *menu, - const gchar *name); - -GList *eos_action_menu_list_actions (EosActionMenu *menu); - - -void eos_action_menu_remove_action (EosActionMenu *menu, - GtkAction *action); - -void eos_action_menu_remove_action_by_name (EosActionMenu *menu, - const gchar *name); - -G_END_DECLS - -#endif /* EOS_ACTION_MENU_H */ diff --git a/endless/eosactionmenu.c b/endless/eosactionmenu.c deleted file mode 100644 index e27cbc2..0000000 --- a/endless/eosactionmenu.c +++ /dev/null @@ -1,274 +0,0 @@ -/* Copyright 2013 Endless Mobile, Inc. */ - -#include "config.h" -#include "eosactionmenu-private.h" - -#include "eosactionbutton.h" -#include <glib-object.h> -#include <gtk/gtk.h> -#include <math.h> - -#define _EOS_STYLE_CLASS_ACTION_MENU "action-menu" - -/* - * SECTION:action-menu - * @short_description: Adding actions to the page - * @title: Action Menu - */ - - -typedef struct { - GtkWidget *overlay; - GtkWidget *center_grid; - GtkWidget *bottom_grid; - - GtkActionGroup *action_group; -} EosActionMenuPrivate; - -G_DEFINE_TYPE_WITH_PRIVATE (EosActionMenu, eos_action_menu, GTK_TYPE_FRAME) - -static void -eos_action_menu_dispose (GObject *object); - -static void -eos_action_menu_finalize (GObject *object); - -/* ******* INIT ******* */ - -static void -eos_action_menu_class_init (EosActionMenuClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->dispose = eos_action_menu_dispose; - object_class->finalize = eos_action_menu_finalize; -} - -static void -eos_action_menu_init (EosActionMenu *self) -{ - EosActionMenuPrivate *priv = eos_action_menu_get_instance_private (self); - GtkStyleContext *context; - - context = gtk_widget_get_style_context (GTK_WIDGET (self)); - gtk_style_context_add_class (context, _EOS_STYLE_CLASS_ACTION_MENU); - - priv->overlay = gtk_overlay_new (); - g_object_set (G_OBJECT (priv->overlay), - "halign", GTK_ALIGN_FILL, - "valign", GTK_ALIGN_FILL, - "hexpand", TRUE, - "vexpand", TRUE, - NULL); - - priv->center_grid = gtk_grid_new (); - g_object_set (G_OBJECT (priv->center_grid), - "orientation", GTK_ORIENTATION_VERTICAL, - "halign", GTK_ALIGN_CENTER, - "valign", GTK_ALIGN_CENTER, - NULL); - - priv->bottom_grid = gtk_grid_new (); - g_object_set (G_OBJECT (priv->bottom_grid), - "orientation", GTK_ORIENTATION_VERTICAL, - "halign", GTK_ALIGN_CENTER, - "valign", GTK_ALIGN_END, - NULL); - - // this is ugly, but needed so the overlay takes all the available space - GtkWidget* placeholder = gtk_event_box_new(); - gtk_widget_set_hexpand (placeholder, TRUE); - gtk_widget_set_vexpand (placeholder, TRUE); - gtk_container_add (GTK_CONTAINER (priv->overlay), placeholder); - - gtk_overlay_add_overlay (GTK_OVERLAY (priv->overlay), priv->center_grid); - gtk_overlay_add_overlay (GTK_OVERLAY (priv->overlay), priv->bottom_grid); - - gtk_container_add (GTK_CONTAINER (self), priv->overlay); - - // TODO : name? - priv->action_group = gtk_action_group_new ("EosActionMenu"); - - gtk_widget_set_hexpand (GTK_WIDGET (self), TRUE); - gtk_widget_set_vexpand (GTK_WIDGET (self), TRUE); -} - -/* ******* LIFECYCLE ******* */ - -/* - * eos_action_menu_new: - * - * Returns: a new instance - */ -GtkWidget * -eos_action_menu_new () -{ - return g_object_new (EOS_TYPE_ACTION_MENU, NULL); -} - -static void -eos_action_menu_dispose (GObject *object) -{ - G_OBJECT_CLASS (eos_action_menu_parent_class)->dispose (object); -} - -static void -eos_action_menu_finalize (GObject *object) -{ - G_OBJECT_CLASS (eos_action_menu_parent_class)->finalize (object); -} - -/* ******* ACTION GROUP MGMT ******* */ - -/* - * eos_action_menu_add_action: - * @menu: a #EosActionMenu - * @action: a #GtkAction: name, label, icon-name, is-important. - * - * Adds an action to the #EosActionMenu, using its #GtkAction:name, - * #GtkAction:label, #GtkAction:icon-name, #GtkAction:is-important and - * #GtkAction:stock-id properties. - * - * Cancel, close and delete actions are placed at the bottom of the menu. To - * indicate this, set the #GtkAction:stock-id property to one of - * #GTK_STOCK_CANCEL, #GTK_STOCK_CLOSE or #GTK_STOCK_DELETE. All other values of - * this property will be ignored. - * - */ -void -eos_action_menu_add_action (EosActionMenu *menu, - GtkAction *action) -{ - g_return_if_fail (EOS_IS_ACTION_MENU (menu)); - - EosActionMenuPrivate *priv = eos_action_menu_get_instance_private (menu); - if (action) - { - gtk_action_group_add_action (priv->action_group, action); - - EosActionButtonSize size = gtk_action_get_is_important (action) ? - EOS_ACTION_BUTTON_SIZE_PRIMARY : - EOS_ACTION_BUTTON_SIZE_SECONDARY; - - GtkWidget *action_button = eos_action_button_new (size, - gtk_action_get_label (action), - gtk_action_get_icon_name (action)); - - gtk_activatable_set_related_action (GTK_ACTIVATABLE (action_button), action); - - if (g_strcmp0 (gtk_action_get_stock_id (action), GTK_STOCK_CANCEL) == 0 || - g_strcmp0 (gtk_action_get_stock_id (action), GTK_STOCK_CLOSE) == 0 || - g_strcmp0 (gtk_action_get_stock_id (action), GTK_STOCK_DELETE) == 0) - { - gtk_container_add (GTK_CONTAINER (priv->bottom_grid), action_button); - } - else - { - gtk_container_add (GTK_CONTAINER (priv->center_grid), action_button); - } - } -} - -/* - * eos_action_menu_get_action: - * @menu: an #EosActionMenu - * @name: the name of the action to retrieve - * - * Retrieves an action. - * - * Returns: (transfer none): the #GtkAction - */ -GtkAction * -eos_action_menu_get_action (EosActionMenu *menu, - const gchar *name) -{ - g_return_val_if_fail (EOS_IS_ACTION_MENU (menu), NULL); - EosActionMenuPrivate *priv = eos_action_menu_get_instance_private (menu); - - return gtk_action_group_get_action (priv->action_group, name); -} - -/* - * eos_action_menu_list_actions: - * @menu: an #EosActionMenu - * - * Returns: (element-type GList) (transfer container): an allocated list of the action objects in the action group - */ -GList * -eos_action_menu_list_actions (EosActionMenu *menu) -{ - g_return_val_if_fail (EOS_IS_ACTION_MENU (menu), NULL); - EosActionMenuPrivate *priv = eos_action_menu_get_instance_private (menu); - - return gtk_action_group_list_actions (priv->action_group); -} - -/* - * eos_action_menu_remove_action: - * @menu: an #EosActionMenu - * @action: the action to remove - * - * Removes an action - */ -void -eos_action_menu_remove_action (EosActionMenu *menu, - GtkAction *action) -{ - g_return_if_fail (EOS_IS_ACTION_MENU (menu)); - g_return_if_fail (GTK_IS_ACTION (action)); - - EosActionMenuPrivate *priv = eos_action_menu_get_instance_private (menu); - GList *children, *i; - GtkWidget *target_child = NULL; - - gtk_action_group_remove_action(priv->action_group, action); - - children = gtk_container_get_children (GTK_CONTAINER (priv->center_grid)); - - children = g_list_concat (children, - gtk_container_get_children (GTK_CONTAINER (priv->bottom_grid))); - - for (i = children; i != NULL; i = i->next) - { - GtkWidget *child = i->data; - GtkAction *childs_action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (child)); - - if (childs_action != NULL && - g_strcmp0 (gtk_action_get_name (childs_action), gtk_action_get_name (action)) == 0) - { - target_child = child; - break; - } - } - - if (target_child != NULL) - { - gtk_widget_destroy (target_child); - } -} - -/* - * eos_action_menu_remove_action_by_name: - * @menu: an #EosActionMenu - * @name: the name of the action to remove - * - * Removes the action with the given name - */ -void -eos_action_menu_remove_action_by_name (EosActionMenu *menu, - const gchar *name) -{ - g_return_if_fail (EOS_IS_ACTION_MENU (menu)); - - GtkAction *action; - EosActionMenuPrivate *priv = eos_action_menu_get_instance_private (menu); - - action = gtk_action_group_get_action (priv->action_group, name); - if (action) - { - eos_action_menu_remove_action (menu, action); - } -} - -/* ******* LAYOUT AND VISUALS ******* */ - diff --git a/endless/eosenums.h b/endless/eosenums.h index d9b396a..fda9819 100644 --- a/endless/eosenums.h +++ b/endless/eosenums.h @@ -21,25 +21,6 @@ G_BEGIN_DECLS * Public enumerated types used throughout the Endless SDK. */ -/** - * EosActionButtonSize: - * @EOS_ACTION_BUTTON_SIZE_PRIMARY: size for primary buttons - * @EOS_ACTION_BUTTON_SIZE_SECONDARY: size for secondary buttons - * @EOS_ACTION_BUTTON_SIZE_TERTIARY: size for tertiary buttons - * @EOS_ACTION_BUTTON_SIZE_QUATERNARY: size for quaternary buttons - * @EOS_ACTION_BUTTON_SIZE_NUM_SIZES: total number of sizes - * - * Built-in sizes for internal action buttons. - */ -typedef enum -{ - EOS_ACTION_BUTTON_SIZE_PRIMARY = 0, - EOS_ACTION_BUTTON_SIZE_SECONDARY, - EOS_ACTION_BUTTON_SIZE_TERTIARY, - EOS_ACTION_BUTTON_SIZE_QUATERNARY, - EOS_ACTION_BUTTON_SIZE_NUM_SIZES -} EosActionButtonSize; - #define EOS_TYPE_FLEXY_SHAPE (eos_flexy_shape_get_type ()) /** diff --git a/endless/eosmainarea-private.h b/endless/eosmainarea-private.h deleted file mode 100644 index 9edb535..0000000 --- a/endless/eosmainarea-private.h +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright 2013 Endless Mobile, Inc. */ - -#ifndef EOS_MAIN_AREA_H -#define EOS_MAIN_AREA_H - -#include "eostypes.h" - -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -#define EOS_TYPE_MAIN_AREA eos_main_area_get_type() - -#define EOS_MAIN_AREA(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - EOS_TYPE_MAIN_AREA, EosMainArea)) - -#define EOS_MAIN_AREA_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), \ - EOS_TYPE_MAIN_AREA, EosMainAreaClass)) - -#define EOS_IS_MAIN_AREA(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - EOS_TYPE_MAIN_AREA)) - -#define EOS_IS_MAIN_AREA_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), \ - EOS_TYPE_MAIN_AREA)) - -#define EOS_MAIN_AREA_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - EOS_TYPE_MAIN_AREA, EosMainAreaClass)) - -typedef struct _EosMainArea EosMainArea; -typedef struct _EosMainAreaClass EosMainAreaClass; - -struct _EosMainArea -{ - GtkContainer parent; -}; - -struct _EosMainAreaClass -{ - GtkContainerClass parent_class; -}; - -GType eos_main_area_get_type (void) G_GNUC_CONST; - -GtkWidget *eos_main_area_new (void); - -void eos_main_area_set_toolbox (EosMainArea *self, - GtkWidget *toolbox); -GtkWidget *eos_main_area_get_toolbox (EosMainArea *self); -void eos_main_area_set_content (EosMainArea *self, - GtkWidget *content); -GtkWidget *eos_main_area_get_content (EosMainArea *self); -void eos_main_area_set_actions (EosMainArea *self, - gboolean actions_visible); -gboolean eos_main_area_get_actions (EosMainArea *self); - -G_END_DECLS - -#endif /* EOS_MAIN_AREA_H */ diff --git a/endless/eosmainarea.c b/endless/eosmainarea.c deleted file mode 100644 index 81920d8..0000000 --- a/endless/eosmainarea.c +++ /dev/null @@ -1,435 +0,0 @@ -/* Copyright 2013 Endless Mobile, Inc. */ - -#include "config.h" -#include "eosmainarea-private.h" - -#include <gtk/gtk.h> - -/* - * SECTION:main_area - * @short_description: The main area for your application, under the top bar. - * @title: EosMainArea - * - * EosMainArea has three areas it manages for you: the left toolbar area, the - * right action area, and the center content area. They can be set with the - * toolbar, actions and content properties. You will just about always want to - * set the content widget to display something, but the toolbar and action - * area will not appear unless set. - */ - -typedef struct { - GtkWidget *toolbox; - GtkWidget *content; - GtkWidget *actions_standin; - guint actions_visible : 1; -} EosMainAreaPrivate; - -G_DEFINE_TYPE_WITH_PRIVATE (EosMainArea, eos_main_area, GTK_TYPE_CONTAINER) - -static void -eos_main_area_get_preferred_width (GtkWidget *widget, - gint *minimal, - gint *natural) -{ - EosMainArea *self = EOS_MAIN_AREA (widget); - EosMainAreaPrivate *priv = eos_main_area_get_instance_private (self); - - GtkWidget *toolbox = priv->toolbox; - GtkWidget *content = priv->content; - *minimal = *natural = 0; - - if ((toolbox && gtk_widget_get_visible (toolbox)) || - priv->actions_visible) - { - gint toolbox_minimal, toolbox_natural; - gtk_widget_get_preferred_width (toolbox, - &toolbox_minimal, &toolbox_natural); - - *minimal += 2 * toolbox_minimal; - *natural += 2 * toolbox_natural; - } - - if (content && gtk_widget_get_visible (content)) - { - gint content_minimal, content_natural; - gtk_widget_get_preferred_width (content, - &content_minimal, &content_natural); - - *minimal += content_minimal; - *natural += content_natural; - } -} - -static void -eos_main_area_get_preferred_height (GtkWidget *widget, - gint *minimal, - gint *natural) -{ - EosMainArea *self = EOS_MAIN_AREA (widget); - EosMainAreaPrivate *priv = eos_main_area_get_instance_private (self); - - GtkWidget *toolbox = priv->toolbox; - GtkWidget *content = priv->content; - *minimal = *natural = 0; - - if (toolbox && gtk_widget_get_visible (toolbox)) - { - gint toolbox_minimal, toolbox_natural; - gtk_widget_get_preferred_height (toolbox, - &toolbox_minimal, &toolbox_natural); - - *minimal = MAX (*minimal, toolbox_minimal); - *natural = MAX (*natural, toolbox_natural); - } - - if (content && gtk_widget_get_visible (content)) - { - gint content_minimal, content_natural; - gtk_widget_get_preferred_height (content, - &content_minimal, &content_natural); - - *minimal = MAX (*minimal, content_minimal); - *natural = MAX (*natural, content_natural); - } -} - -/* Don't size width for height or height for width, at least for now... */ -static void -eos_main_area_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - EosMainArea *self = EOS_MAIN_AREA (widget); - EosMainAreaPrivate *priv = eos_main_area_get_instance_private (self); - - GtkWidget *toolbox = priv->toolbox; - GtkWidget *content = priv->content; - - gtk_widget_set_allocation (widget, allocation); - - gint num_sidebars = 0; - gboolean content_visible = content && gtk_widget_get_visible (content); - gboolean toolbox_visible = toolbox && gtk_widget_get_visible (toolbox); - if (toolbox_visible) - num_sidebars++; - if (priv->actions_visible) - num_sidebars++; - - gint toolbox_min_width = 0, toolbox_nat_width = 0; - gint toolbox_min_height, toolbox_nat_height; - if (toolbox_visible) - { - gtk_widget_get_preferred_width (toolbox, - &toolbox_min_width, &toolbox_nat_width); - gtk_widget_get_preferred_height (toolbox, - &toolbox_min_height, &toolbox_nat_height); - } - - gint content_min_width = 0, content_nat_width = 0; - gint content_min_height, content_nat_height; - if (content_visible) - { - gtk_widget_get_preferred_width (content, - &content_min_width, &content_nat_width); - gtk_widget_get_preferred_height (content, - &content_min_height, &content_nat_height); - } - - /* Calculate width of sidebars. We allocate space in the following order: - Sidebars min width, content min width, sidebars natural width, content - natural width. */ - gint sidebar_width = 0; - gint total_sidebars_width = allocation->width - content_min_width; - if (num_sidebars > 0) - { - if (allocation->width < toolbox_min_width * num_sidebars) - { - sidebar_width = allocation->width / num_sidebars; - } - else if (content_visible && - total_sidebars_width < toolbox_nat_width * num_sidebars) - { - sidebar_width = total_sidebars_width / num_sidebars; - } - else - { - sidebar_width = toolbox_nat_width; - } - } - - /* Allocate size */ - gint x = allocation->x; - gint y = allocation->y; - if (toolbox_visible) - { - GtkAllocation toolbox_allocation; - toolbox_allocation.x = x; - toolbox_allocation.y = y; - toolbox_allocation.width = sidebar_width; - toolbox_allocation.height = MIN (toolbox_nat_height, allocation->height); - gtk_widget_size_allocate (toolbox, &toolbox_allocation); - x += toolbox_allocation.width; - } - if (priv->actions_visible) - { - GtkAllocation actions_allocation; - actions_allocation.x = allocation->x + allocation->width - sidebar_width; - actions_allocation.y = y; - actions_allocation.width = sidebar_width; - actions_allocation.height = allocation->height; - gtk_widget_size_allocate (priv->actions_standin, - &actions_allocation); - } - if (content_visible) - { - GtkAllocation content_allocation; - content_allocation.x = x; - content_allocation.y = y; - content_allocation.width = MAX (0, - allocation->width - num_sidebars * sidebar_width); - content_allocation.height = allocation->height; - gtk_widget_size_allocate (content, &content_allocation); - } -} - -static void -eos_main_area_add (GtkContainer *container, - GtkWidget *widget) -{ - EosMainArea *self = EOS_MAIN_AREA (container); - - /* Print out warning message?? */ - - eos_main_area_set_content(self, widget); -} - -static void -eos_main_area_remove (GtkContainer *container, - GtkWidget *widget) -{ - EosMainArea *self = EOS_MAIN_AREA(container); - EosMainAreaPrivate *priv = eos_main_area_get_instance_private (self); - - if (priv->content == widget) - eos_main_area_set_content (self, NULL); - else if (priv->toolbox == widget) - eos_main_area_set_toolbox (self, NULL); -} - -static void -eos_main_area_forall(GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data) -{ - EosMainArea *self = EOS_MAIN_AREA (container); - EosMainAreaPrivate *priv = eos_main_area_get_instance_private (self); - - if (priv->toolbox) - (*callback) (priv->toolbox, callback_data); - - if (priv->content) - (*callback) (priv->content, callback_data); - - if (include_internals && priv->actions_visible) - (*callback) (priv->actions_standin, callback_data); -} - -static void -eos_main_area_destroy (GtkWidget *widget) -{ - EosMainArea *self = EOS_MAIN_AREA (widget); - EosMainAreaPrivate *priv = eos_main_area_get_instance_private (self); - - gtk_widget_destroy (priv->actions_standin); - - GTK_WIDGET_CLASS (eos_main_area_parent_class)->destroy (widget); -} - -static void -eos_main_area_class_init (EosMainAreaClass *klass) -{ - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass); - - widget_class->get_preferred_width = eos_main_area_get_preferred_width; - widget_class->get_preferred_height = eos_main_area_get_preferred_height; - widget_class->size_allocate = eos_main_area_size_allocate; - widget_class->destroy = eos_main_area_destroy; - - container_class->forall = eos_main_area_forall; - container_class->add = eos_main_area_add; - container_class->remove = eos_main_area_remove; -} - -static void -eos_main_area_init (EosMainArea *self) -{ - EosMainAreaPrivate *priv = eos_main_area_get_instance_private (self); - gtk_widget_set_has_window(GTK_WIDGET(self), FALSE); - - priv->actions_standin = gtk_event_box_new (); - g_object_ref_sink (priv->actions_standin); - GdkRGBA red = { 1.0, 0.0, 0.0, 1.0 }; - gtk_widget_override_background_color (priv->actions_standin, - GTK_STATE_FLAG_NORMAL, - &red); - gtk_widget_show (priv->actions_standin); -} - -/* Internal Public API */ - -/* - * eos_main_area_new: - * - * Creates a main area. It is invisible by default. - * - * Returns: a pointer to the main area widget. - */ -GtkWidget * -eos_main_area_new (void) -{ - return GTK_WIDGET (g_object_new (EOS_TYPE_MAIN_AREA, NULL)); -} - - -/* - * eos_main_area_set_toolbox: - * @self: a #EosMainArea - * @toolbox: the toolbox widget to be displayed on left of content. - * - * Adds the toolbox widget to the main area. Passing %NULL will hide the - * toolbox area. - */ -void -eos_main_area_set_toolbox (EosMainArea *self, - GtkWidget *toolbox) -{ - g_return_if_fail (EOS_IS_MAIN_AREA (self)); - g_return_if_fail (toolbox == NULL || GTK_IS_WIDGET (toolbox)); - - EosMainAreaPrivate *priv = eos_main_area_get_instance_private (self); - GtkWidget *self_widget = GTK_WIDGET (self); - - if (priv->toolbox == toolbox) - return; - - if (priv->toolbox) - gtk_widget_unparent (priv->toolbox); - - priv->toolbox = toolbox; - if (toolbox) - { - gtk_widget_set_parent (toolbox, self_widget); - gtk_widget_show (toolbox); - } -} - -/* - * eos_main_area_get_toolbox: - * @self: a #EosMainArea - * - * Retrieves the toolbox widget for the main area. - * - * Return value: (transfer none): the toolbox widget, - * or %NULL if there is none - */ -GtkWidget * -eos_main_area_get_toolbox (EosMainArea *self) -{ - g_return_val_if_fail (EOS_IS_MAIN_AREA (self), NULL); - EosMainAreaPrivate *priv = eos_main_area_get_instance_private (self); - return priv->toolbox; -} - -/* - * eos_main_area_set_content: - * @self: a #EosMainArea - * @content: the content widget to be displayed in the center. - * - * Adds the content widget to the main area. - */ -void -eos_main_area_set_content (EosMainArea *self, - GtkWidget *content) -{ - g_return_if_fail (EOS_IS_MAIN_AREA (self)); - g_return_if_fail (content == NULL || GTK_IS_WIDGET (content)); - g_return_if_fail (content == NULL || gtk_widget_get_parent (content) == NULL); - - EosMainAreaPrivate *priv = eos_main_area_get_instance_private (self); - GtkWidget *self_widget = GTK_WIDGET (self); - - if (priv->content == content) - return; - - if (priv->content) - gtk_widget_unparent (priv->content); - - priv->content = content; - if (content) - gtk_widget_set_parent (content, self_widget); -} - -/* - * eos_main_area_get_content: - * @self: a #EosMainArea - * - * Retrieves the content widget for the main area. - * - * Return value: (transfer none): the content widget, - * or %NULL if there is none - */ -GtkWidget * -eos_main_area_get_content (EosMainArea *self) -{ - g_return_val_if_fail (EOS_IS_MAIN_AREA (self), NULL); - EosMainAreaPrivate *priv = eos_main_area_get_instance_private (self); - return priv->content; -} - -/* - * eos_main_area_set_actions: - * @self: a #EosMainArea - * @actions: %TRUE if there will be actions area on right of content. - * - * Sets whether an actions area should be displayed on the right of the - * content. For now just a boolean eventually a widget/list of actions or - * something. - */ -void -eos_main_area_set_actions (EosMainArea *self, - gboolean actions_visible) -{ - g_return_if_fail (EOS_IS_MAIN_AREA (self)); - - EosMainAreaPrivate *priv = eos_main_area_get_instance_private (self); - GtkWidget *self_widget = GTK_WIDGET (self); - - actions_visible = actions_visible != FALSE; - - if (priv->actions_visible == actions_visible) - return; - - priv->actions_visible = actions_visible; - - if (priv->actions_visible) - gtk_widget_set_parent (priv->actions_standin, self_widget); - else - gtk_widget_unparent (priv->actions_standin); -} - -/* - * eos_main_area_get_actions: - * @self: a #EosMainArea - * - * Retrieves the actions boolean value. See set_actions. - * - * Return value: stand in actions boolean, for now. - */ -gboolean -eos_main_area_get_actions (EosMainArea *self) -{ - g_return_val_if_fail (EOS_IS_MAIN_AREA (self), FALSE); - EosMainAreaPrivate *priv = eos_main_area_get_instance_private (self); - return priv->actions_visible; -} diff --git a/endless/eospagemanager-private.h b/endless/eospagemanager-private.h deleted file mode 100644 index c39a118..0000000 --- a/endless/eospagemanager-private.h +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright 2013 Endless Mobile, Inc. */ - -#ifndef EOS_PAGE_MANAGER_PRIVATE_H -#define EOS_PAGE_MANAGER_PRIVATE_H - -#include "eostypes.h" - -#include "eospagemanager.h" - -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -GtkStackTransitionType eos_page_manager_get_gtk_stack_transition_type (EosPageManager *self); - -G_END_DECLS - -#endif /* EOS_PAGE_MANAGER_PRIVATE_H */ diff --git a/endless/eospagemanager.c b/endless/eospagemanager.c index f1812da..78d5b56 100644 --- a/endless/eospagemanager.c +++ b/endless/eospagemanager.c @@ -2,7 +2,6 @@ #include "config.h" #include "eospagemanager.h" -#include "eospagemanager-private.h" #include <gtk/gtk.h> @@ -73,16 +72,10 @@ * If the removed page was the only page, then the page manager will display * nothing. * If there are multiple pages still in the page manager, you should never - * remove the visible-page. Always set a new visible page before removing the + * remove the visible-child. Always set a new visible child before removing the * current one. A critical warning will be emitted if you remove the visible- * page when there are still other pages in the page manager. * - * <warning> - * <para>Removing pages with gtk_container_remove() is currently broken due to - * a bug in GTK. Use eos_page_manager_remove_page_by_name() for the time - * being.</para> - * </warning> - * * In general, it is convenient to refer to a page by its name when dealing with * the page manager, so you should make a point of giving all your pages names. */ @@ -92,9 +85,6 @@ typedef struct { GtkWidget *page; - gchar *name; - gboolean fake_page_actions_visible; - GtkWidget *custom_toolbox_widget; GtkWidget *left_topbar_widget; GtkWidget *center_topbar_widget; gchar *background_uri; @@ -104,51 +94,15 @@ typedef struct { } EosPageManagerPageInfo; typedef struct { - GtkWidget *stack; GList *page_info; /* GList<EosPageManagerPageInfo> */ - GHashTable *pages_by_name; /* GHashTable<gchar *, EosPageManagerPageInfo *> */ GHashTable *pages_by_widget; /* GHashTable<GtkWidget *, EosPageManagerPageInfo *> */ - EosPageManagerPageInfo *visible_page_info; - EosPageManagerTransitionType transition_type; } EosPageManagerPrivate; -G_DEFINE_TYPE_WITH_PRIVATE (EosPageManager, eos_page_manager, GTK_TYPE_CONTAINER) - -GType -eos_page_manager_transition_type_get_type (void) -{ - static GType etype = 0; - if (G_UNLIKELY(etype == 0)) { - static const GEnumValue values[] = { - { EOS_PAGE_MANAGER_TRANSITION_TYPE_NONE, "EOS_PAGE_MANAGER_TRANSITION_TYPE_NONE", "none" }, - { EOS_PAGE_MANAGER_TRANSITION_TYPE_CROSSFADE, "EOS_PAGE_MANAGER_TRANSITION_TYPE_CROSSFADE", "crossfade" }, - { EOS_PAGE_MANAGER_TRANSITION_TYPE_SLIDE_RIGHT, "EOS_PAGE_MANAGER_TRANSITION_TYPE_SLIDE_RIGHT", "slide_right" }, - { EOS_PAGE_MANAGER_TRANSITION_TYPE_SLIDE_LEFT, "EOS_PAGE_MANAGER_TRANSITION_TYPE_SLIDE_LEFT", "slide_left" }, - { EOS_PAGE_MANAGER_TRANSITION_TYPE_SLIDE_UP, "EOS_PAGE_MANAGER_TRANSITION_TYPE_SLIDE_UP", "slide_up" }, - { EOS_PAGE_MANAGER_TRANSITION_TYPE_SLIDE_DOWN, "EOS_PAGE_MANAGER_TRANSITION_TYPE_SLIDE_DOWN", "slide_down" }, - { 0, NULL, NULL } - }; - etype = g_enum_register_static (g_intern_static_string ("EosPageManagerTransitionType"), values); - } - return etype; -} - -enum -{ - PROP_0, - PROP_VISIBLE_PAGE, - PROP_VISIBLE_PAGE_NAME, - PROP_TRANSITION_DURATION, - PROP_TRANSITION_TYPE, - NPROPS -}; +G_DEFINE_TYPE_WITH_PRIVATE (EosPageManager, eos_page_manager, GTK_TYPE_STACK) enum { CHILD_PROP_0, - CHILD_PROP_NAME, - CHILD_PROP_PAGE_ACTIONS, - CHILD_PROP_CUSTOM_TOOLBOX_WIDGET, CHILD_PROP_LEFT_TOPBAR_WIDGET, CHILD_PROP_CENTER_TOPBAR_WIDGET, CHILD_PROP_BACKGROUND_URI, @@ -158,13 +112,11 @@ enum NCHILDPROPS }; -static GParamSpec *eos_page_manager_props[NPROPS] = { NULL, }; static GParamSpec *eos_page_manager_child_props[NCHILDPROPS] = { NULL, }; static void page_info_free (EosPageManagerPageInfo *info) { - g_free (info->name); g_free (info->background_uri); g_free (info->background_size); g_free (info->background_position); @@ -196,24 +148,6 @@ find_page_info_by_widget (EosPageManager *self, return g_hash_table_lookup (priv->pages_by_widget, page); } -/* - * find_page_info_by_name: - * @self: the page manager - * @name: the name to look for - * - * Searches for the page info corresponding to the child with name @name. - * - * Returns: the #EosPageManagerPageInfo for @name, or %NULL if @name is not the - * name of a child of @self. - */ -static EosPageManagerPageInfo * -find_page_info_by_name (EosPageManager *self, - const gchar *name) -{ - EosPageManagerPrivate *priv = eos_page_manager_get_instance_private (self); - return g_hash_table_lookup (priv->pages_by_name, name); -} - /* Convenience function, since this warning occurs at several places */ static void warn_page_widget_not_found (EosPageManager *self, @@ -225,16 +159,6 @@ warn_page_widget_not_found (EosPageManager *self, self); } -/* Convenience function, since this warning occurs at several places */ -static void -warn_page_name_not_found (EosPageManager *self, - const gchar *name) -{ - g_critical ("EosPageManager %p has no page named %s", - self, - name); -} - /* Invariants: number of pages in list and number of pages in pages_by_widget hash table must be equal; and number of pages in pages_by_name hash table must be equal or less. This check is expensive, should only be enabled for debugging. @@ -248,95 +172,14 @@ assert_internal_state (EosPageManager *self) g_assert_cmpuint (list_length, ==, g_hash_table_size (priv->pages_by_widget)); - g_assert_cmpuint (list_length, - >=, - g_hash_table_size (priv->pages_by_name)); #endif } static void -set_visible_page_from_info (EosPageManager *self, - EosPageManagerPageInfo *info) -{ - EosPageManagerPrivate *priv = eos_page_manager_get_instance_private (self); - GtkStack *stack = GTK_STACK (priv->stack); - gtk_stack_set_visible_child (stack, info->page); - - priv->visible_page_info = info; - - GObject *self_object = G_OBJECT (self); - g_object_notify(self_object, "visible-page"); - g_object_notify(self_object, "visible-page-name"); -} - -static void -eos_page_manager_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - EosPageManager *self = EOS_PAGE_MANAGER (object); - - switch (property_id) - { - case PROP_VISIBLE_PAGE: - g_value_set_object (value, eos_page_manager_get_visible_page (self)); - break; - - case PROP_VISIBLE_PAGE_NAME: - g_value_set_string (value, eos_page_manager_get_visible_page_name (self)); - break; - - case PROP_TRANSITION_DURATION: - g_value_set_uint (value, eos_page_manager_get_transition_duration (self)); - break; - - case PROP_TRANSITION_TYPE: - g_value_set_enum (value, eos_page_manager_get_transition_type (self)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - } -} - -static void -eos_page_manager_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - EosPageManager *self = EOS_PAGE_MANAGER (object); - - switch (property_id) - { - case PROP_VISIBLE_PAGE: - eos_page_manager_set_visible_page (self, g_value_get_object (value)); - break; - - case PROP_VISIBLE_PAGE_NAME: - eos_page_manager_set_visible_page_name (self, g_value_get_string (value)); - break; - - case PROP_TRANSITION_DURATION: - eos_page_manager_set_transition_duration (self, g_value_get_uint (value)); - break; - - case PROP_TRANSITION_TYPE: - eos_page_manager_set_transition_type (self, g_value_get_enum (value)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - } -} - -static void eos_page_manager_dispose (GObject *object) { EosPageManager *self = EOS_PAGE_MANAGER (object); EosPageManagerPrivate *priv = eos_page_manager_get_instance_private (self); - g_list_foreach (priv->page_info, (GFunc)top_bars_unref, NULL); G_OBJECT_CLASS (eos_page_manager_parent_class)->dispose (object); @@ -348,125 +191,10 @@ eos_page_manager_finalize (GObject *object) EosPageManager *self = EOS_PAGE_MANAGER (object); EosPageManagerPrivate *priv = eos_page_manager_get_instance_private (self); - g_list_foreach (priv->page_info, (GFunc)page_info_free, NULL); - g_hash_table_destroy(priv->pages_by_widget); - g_hash_table_destroy(priv->pages_by_name); - G_OBJECT_CLASS (eos_page_manager_parent_class)->finalize (object); -} - -static GtkSizeRequestMode -eos_page_manager_get_request_mode (GtkWidget *widget) -{ - EosPageManager *self = EOS_PAGE_MANAGER (widget); - EosPageManagerPrivate *priv = eos_page_manager_get_instance_private (self); - - return gtk_widget_get_request_mode (priv->stack); -} - -static void -eos_page_manager_get_preferred_height (GtkWidget *widget, - gint *minimum, - gint *natural) -{ - EosPageManager *self = EOS_PAGE_MANAGER (widget); - EosPageManagerPrivate *priv = eos_page_manager_get_instance_private (self); - - gtk_widget_get_preferred_height (priv->stack, minimum, natural); -} -static void -eos_page_manager_get_preferred_width_for_height (GtkWidget *widget, - gint height, - gint *minimum, - gint *natural) -{ - EosPageManager *self = EOS_PAGE_MANAGER (widget); - EosPageManagerPrivate *priv = eos_page_manager_get_instance_private (self); - - gtk_widget_get_preferred_height_for_width (priv->stack, height, - minimum, natural); -} - -static void -eos_page_manager_get_preferred_width (GtkWidget *widget, - gint *minimum, - gint *natural) -{ - EosPageManager *self = EOS_PAGE_MANAGER (widget); - EosPageManagerPrivate *priv = eos_page_manager_get_instance_private (self); - - gtk_widget_get_preferred_width (priv->stack, minimum, natural); -} - -static void -eos_page_manager_get_preferred_height_for_width (GtkWidget *widget, - gint width, - gint *minimum, - gint *natural) -{ - EosPageManager *self = EOS_PAGE_MANAGER (widget); - EosPageManagerPrivate *priv = eos_page_manager_get_instance_private (self); - - gtk_widget_get_preferred_height_for_width (priv->stack, width, - minimum, natural); -} - -static void -eos_page_manager_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - EosPageManager *self = EOS_PAGE_MANAGER (widget); - EosPageManagerPrivate *priv = eos_page_manager_get_instance_private (self); - - gtk_widget_set_allocation (widget, allocation); - gtk_widget_size_allocate (priv->stack, allocation); -} - -static void -eos_page_manager_show_all (GtkWidget *widget) -{ - EosPageManager *self = EOS_PAGE_MANAGER (widget); - EosPageManagerPrivate *priv = eos_page_manager_get_instance_private (self); - - GTK_WIDGET_CLASS (eos_page_manager_parent_class)->show (widget); - if (priv->stack != NULL) - gtk_widget_show_all (priv->stack); -} - -static void -eos_page_manager_map (GtkWidget *widget) -{ - EosPageManager *self = EOS_PAGE_MANAGER (widget); - EosPageManagerPrivate *priv = eos_page_manager_get_instance_private (self); - - if (priv->stack != NULL && gtk_widget_get_visible (priv->stack)) - gtk_widget_map (priv->stack); - GTK_WIDGET_CLASS (eos_page_manager_parent_class)->map (widget); -} - -static void -eos_page_manager_unmap (GtkWidget *widget) -{ - EosPageManager *self = EOS_PAGE_MANAGER (widget); - EosPageManagerPrivate *priv = eos_page_manager_get_instance_private (self); - - if (priv->stack != NULL) - gtk_widget_unmap (priv->stack); - GTK_WIDGET_CLASS (eos_page_manager_parent_class)->unmap (widget); -} - -static gboolean -eos_page_manager_draw (GtkWidget *widget, - cairo_t *cr) -{ - EosPageManager *self = EOS_PAGE_MANAGER (widget); - EosPageManagerPrivate *priv = eos_page_manager_get_instance_private (self); - - if (priv->stack != NULL) - gtk_widget_draw (priv->stack, cr); - - return FALSE; + g_list_foreach (priv->page_info, (GFunc)page_info_free, NULL); + g_hash_table_destroy(priv->pages_by_widget); } static void @@ -476,7 +204,6 @@ eos_page_manager_add (GtkContainer *container, EosPageManager *self = EOS_PAGE_MANAGER (container); EosPageManagerPrivate *priv = eos_page_manager_get_instance_private (self); - gtk_container_add (GTK_CONTAINER (priv->stack), new_page); EosPageManagerPageInfo *info = g_slice_new0 (EosPageManagerPageInfo); info->background_size = g_strdup (DEFAULT_BACKGROUND_SIZE); info->background_position = g_strdup (DEFAULT_BACKGROUND_POSITION); @@ -485,10 +212,7 @@ eos_page_manager_add (GtkContainer *container, priv->page_info = g_list_prepend (priv->page_info, info); g_hash_table_insert (priv->pages_by_widget, new_page, info); - /* If there were no pages yet, then this one must become the visible one */ - if (priv->visible_page_info == NULL) - eos_page_manager_set_visible_page (self, new_page); - + GTK_CONTAINER_CLASS (eos_page_manager_parent_class)->add (container, new_page); assert_internal_state (self); } @@ -499,7 +223,7 @@ eos_page_manager_remove (GtkContainer *container, EosPageManager *self = EOS_PAGE_MANAGER (container); EosPageManagerPrivate *priv = eos_page_manager_get_instance_private (self); - gtk_container_remove (GTK_CONTAINER (priv->stack), page); + GTK_CONTAINER_CLASS (eos_page_manager_parent_class)->remove (container, page); EosPageManagerPageInfo *info = find_page_info_by_widget (self, page); if (info == NULL) { @@ -508,26 +232,6 @@ eos_page_manager_remove (GtkContainer *container, } priv->page_info = g_list_remove (priv->page_info, info); g_hash_table_remove (priv->pages_by_widget, page); - if (info->name != NULL) - g_hash_table_remove (priv->pages_by_name, info->name); - - if (priv->visible_page_info == info) - { - /* If this was the only page */ - if (priv->page_info == NULL) - { - priv->visible_page_info = NULL; - } - /* Otherwise set visible page as the first in our list. */ - else - { - g_critical ("Removing the currently visible page %p from the page manager.", - page); - EosPageManagerPageInfo *visible_info = g_list_first (priv->page_info)->data; - set_visible_page_from_info (self, visible_info); - } - - } page_info_free (info); @@ -535,27 +239,6 @@ eos_page_manager_remove (GtkContainer *container, } static void -eos_page_manager_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data) -{ - EosPageManager *self = EOS_PAGE_MANAGER (container); - EosPageManagerPrivate *priv = eos_page_manager_get_instance_private (self); - - if (priv->stack == NULL) - return; - - GtkContainerClass *stack_class = GTK_CONTAINER_GET_CLASS (priv->stack); - stack_class->forall (GTK_CONTAINER (priv->stack), - include_internals, - callback, - callback_data); - if (include_internals) - callback (priv->stack, callback_data); -} - -static void eos_page_manager_get_child_property (GtkContainer *container, GtkWidget *child, guint property_id, @@ -566,10 +249,6 @@ eos_page_manager_get_child_property (GtkContainer *container, switch (property_id) { - case CHILD_PROP_NAME: - g_value_set_string (value, eos_page_manager_get_page_name (self, child)); - break; - case CHILD_PROP_BACKGROUND_URI: g_value_set_string (value, eos_page_manager_get_page_background_uri (self, @@ -594,17 +273,6 @@ eos_page_manager_get_child_property (GtkContainer *container, child)); break; - case CHILD_PROP_PAGE_ACTIONS: - g_value_set_boolean (value, - eos_page_manager_get_page_actions (self, child)); - break; - - case CHILD_PROP_CUSTOM_TOOLBOX_WIDGET: - g_value_set_object (value, - eos_page_manager_get_page_custom_toolbox_widget (self, - child)); - break; - case CHILD_PROP_LEFT_TOPBAR_WIDGET: g_value_set_object (value, eos_page_manager_get_page_left_topbar_widget (self, @@ -634,10 +302,6 @@ eos_page_manager_set_child_property (GtkContainer *container, switch (property_id) { - case CHILD_PROP_NAME: - eos_page_manager_set_page_name (self, child, g_value_get_string (value)); - break; - case CHILD_PROP_BACKGROUND_URI: eos_page_manager_set_page_background_uri (self, child, g_value_get_string (value)); @@ -658,16 +322,6 @@ eos_page_manager_set_child_property (GtkContainer *container, g_value_get_boolean (value)); break; - case CHILD_PROP_PAGE_ACTIONS: - eos_page_manager_set_page_actions (self, child, - g_value_get_boolean (value)); - break; - - case CHILD_PROP_CUSTOM_TOOLBOX_WIDGET: - eos_page_manager_set_page_custom_toolbox_widget (self, child, - g_value_get_object (value)); - break; - case CHILD_PROP_LEFT_TOPBAR_WIDGET: eos_page_manager_set_page_left_topbar_widget (self, child, g_value_get_object (value)); @@ -688,135 +342,17 @@ static void eos_page_manager_class_init (EosPageManagerClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass); - object_class->get_property = eos_page_manager_get_property; - object_class->set_property = eos_page_manager_set_property; object_class->dispose = eos_page_manager_dispose; object_class->finalize = eos_page_manager_finalize; - /* Pass all size requesting and allocation on to the stack */ - widget_class->get_request_mode = eos_page_manager_get_request_mode; - widget_class->get_preferred_height = eos_page_manager_get_preferred_height; - widget_class->get_preferred_height_for_width = - eos_page_manager_get_preferred_height_for_width; - widget_class->get_preferred_width = eos_page_manager_get_preferred_width; - widget_class->get_preferred_width_for_height = - eos_page_manager_get_preferred_width_for_height; - widget_class->size_allocate = eos_page_manager_size_allocate; - widget_class->show_all = eos_page_manager_show_all; - widget_class->map = eos_page_manager_map; - widget_class->unmap = eos_page_manager_unmap; - widget_class->draw = eos_page_manager_draw; - container_class->add = eos_page_manager_add; container_class->remove = eos_page_manager_remove; - container_class->forall = eos_page_manager_forall; container_class->get_child_property = eos_page_manager_get_child_property; container_class->set_child_property = eos_page_manager_set_child_property; /** - * EosPageManager:visible-page: - * - * A reference to the page widget that is currently being displayed by the - * page manager. - * If the page manager has no pages, then this is %NULL. - */ - eos_page_manager_props[PROP_VISIBLE_PAGE] = - g_param_spec_object ("visible-page", "Visible page", - "Page widget currently displaying in the page manager", - GTK_TYPE_WIDGET, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - /** - * EosPageManager:visible-page-name: - * - * The name of the page that is currently being displayed by the page manager. - * If the page manager has no pages, or if there is a page currently being - * displayed but it has no name, then this is %NULL. - */ - eos_page_manager_props[PROP_VISIBLE_PAGE_NAME] = - g_param_spec_string ("visible-page-name", "Visible page name", - "Name of page currently displaying in the page " - "manager", - "", - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - - /** - * EosPageManager:transition-duration: - * - * The time it will take to animate between pages in the page managers, in - * milliseconds. - */ - eos_page_manager_props[PROP_TRANSITION_DURATION] = - g_param_spec_uint ("transition-duration", "Transition duration", - "The animation duration, in milliseconds", - 0, G_MAXUINT, - 200, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT); - - - /** - * EosPageManager:transition-type: - * - * The type of animation to use when switching between pages in the page - * manager. The pages can crossfade from one to the next, or slide in from - * any direction. - */ - eos_page_manager_props[PROP_TRANSITION_TYPE] = - g_param_spec_enum ("transition-type", "Transition type", - "The type of animation used to transition", - EOS_TYPE_PAGE_MANAGER_TRANSITION_TYPE, - EOS_PAGE_MANAGER_TRANSITION_TYPE_NONE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT); - - g_object_class_install_properties (object_class, NPROPS, - eos_page_manager_props); - - /** - * EosPageManager:name: - * - * The name of this page. Make sure to choose a unique name. - */ - eos_page_manager_child_props[CHILD_PROP_NAME] = - g_param_spec_string ("name", "Name", "Unique ID for the page", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - - /** - * EosPageManager:page-actions: - * - * The actions exported by this page, to be displayed in the action area on - * the right of the window. - * - * <warning><para>Currently, this property is a boolean value. %TRUE means - * to display a fake action area, and %FALSE means don't display. - * </para></warning> - */ - eos_page_manager_child_props[CHILD_PROP_PAGE_ACTIONS] = - g_param_spec_boolean ("page-actions", "Page Actions", - "Actions the page exports into the action area", - FALSE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - - /** - * EosPageManager:custom-toolbox-widget: - * - * The custom toolbox widget belonging to this page, to be displayed on the - * left of the window when the page is displaying. Setting this to %NULL - * indicates that there should be no toolbox widget. - * - * <warning><para>Currently, there is no such thing as a - * <emphasis>non-</emphasis>custom toolbox widget. - * </para></warning> - */ - eos_page_manager_child_props[CHILD_PROP_CUSTOM_TOOLBOX_WIDGET] = - g_param_spec_object ("custom-toolbox-widget", "Custom toolbox widget", - "Custom toolbox widget displayed left of the page", - GTK_TYPE_WIDGET, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - - /** * EosPageManager:left-topbar-widget: * * The left topbar widget belonging to this page, to be displayed on the @@ -895,7 +431,7 @@ eos_page_manager_class_init (EosPageManagerClass *klass) /* Install child properties all at once, because there is no gtk_container_class_install_child_properties() function */ int count; - for (count = PROP_0 + 1; count < NCHILDPROPS; count++) + for (count = CHILD_PROP_0 + 1; count < NCHILDPROPS; count++) gtk_container_class_install_child_property (container_class, count, eos_page_manager_child_props[count]); } @@ -904,19 +440,8 @@ static void eos_page_manager_init (EosPageManager *self) { EosPageManagerPrivate *priv = eos_page_manager_get_instance_private (self); - GtkWidget *self_widget = GTK_WIDGET (self); priv->pages_by_widget = g_hash_table_new (g_direct_hash, g_direct_equal); - priv->pages_by_name = g_hash_table_new_full (g_str_hash, - g_str_equal, - g_free, - NULL); - - gtk_widget_set_has_window (self_widget, FALSE); - - priv->stack = gtk_stack_new (); - gtk_widget_show (priv->stack); - gtk_widget_set_parent (priv->stack, self_widget); } /* Public API */ @@ -935,314 +460,6 @@ eos_page_manager_new (void) } /** - * eos_page_manager_get_visible_page: - * @self: the page manager - * - * Gets the page widget that @self is currently displaying. - * See #EosPageManager:visible-page for more information. - * - * Returns: (transfer none): the page #GtkWidget, or %NULL if @self does not - * have any pages. - */ -GtkWidget * -eos_page_manager_get_visible_page (EosPageManager *self) -{ - g_return_val_if_fail (EOS_IS_PAGE_MANAGER (self), NULL); - - EosPageManagerPrivate *priv = eos_page_manager_get_instance_private (self); - if (priv->visible_page_info == NULL) - return NULL; - - return priv->visible_page_info->page; -} - -/** - * eos_page_manager_set_visible_page: - * @self: the page manager - * @page: the page to switch to - * - * Switches the page manager @self to display @page. - * The @page widget must previously have been added to the page manager. - * See #EosPageManager:visible-page for more information. - */ -void -eos_page_manager_set_visible_page (EosPageManager *self, - GtkWidget *page) -{ - g_return_if_fail (EOS_IS_PAGE_MANAGER (self)); - - EosPageManagerPageInfo *info = find_page_info_by_widget (self, page); - if (info == NULL) - { - warn_page_widget_not_found (self, page); - return; - } - - set_visible_page_from_info (self, info); -} - -/** - * eos_page_manager_get_visible_page_name: - * @self: the page manager - * - * Gets the name of the page widget that @self is currently displaying. - * See #EosPageManager:visible-page for more information. - * - * Returns: (allow-none): the name of the page, or %NULL if @self does not have - * any pages or if the visible page does not have a name. - */ -const gchar * -eos_page_manager_get_visible_page_name (EosPageManager *self) -{ - g_return_val_if_fail (EOS_IS_PAGE_MANAGER (self), NULL); - - EosPageManagerPrivate *priv = eos_page_manager_get_instance_private (self); - if (priv->visible_page_info == NULL) - return NULL; - - return priv->visible_page_info->name; -} - -/** - * eos_page_manager_set_visible_page_name: - * @self: the page manager - * @page_name: the name of the page to switch to - * - * Switches the page manager @self to display the page called @page_name. - * This page must previously have been added to the page manager. - * See #EosPageManager:visible-page for more information. - */ -void -eos_page_manager_set_visible_page_name (EosPageManager *self, - const gchar *page_name) -{ - g_return_if_fail (EOS_IS_PAGE_MANAGER (self)); - g_return_if_fail (page_name != NULL); - - EosPageManagerPageInfo *info = find_page_info_by_name (self, page_name); - if (info == NULL) - { - warn_page_name_not_found (self, page_name); - return; - } - - set_visible_page_from_info (self, info); -} - -/** - * eos_page_manager_get_page_name: - * @self: the page manager - * @page: the page to be queried - * - * Gets the name of @page, which must previously have been added to the - * page manager. - * See #EosPageManager:name for more information. - * - * Returns: (allow-none): the name of @page, or %NULL if @page does not have a - * name. - */ -const gchar * -eos_page_manager_get_page_name (EosPageManager *self, - GtkWidget *page) -{ - g_return_val_if_fail (EOS_IS_PAGE_MANAGER (self), NULL); - g_return_val_if_fail (GTK_IS_WIDGET (page), NULL); - - EosPageManagerPageInfo *info = find_page_info_by_widget (self, page); - if (info == NULL) - { - warn_page_widget_not_found (self, page); - return NULL; - } - - return info->name; -} - -/** - * eos_page_manager_set_page_name: - * @self: the page manager - * @page: the page to be renamed - * @name: (allow-none): the new name for @page - * - * Changes the name of @page, which must previously have been added to the - * page manager. - * To remove @page's name, pass %NULL for @name. - * See #EosPageManager:name for more information. - */ -void -eos_page_manager_set_page_name (EosPageManager *self, - GtkWidget *page, - const gchar *name) -{ - g_return_if_fail (EOS_IS_PAGE_MANAGER (self)); - g_return_if_fail (GTK_IS_WIDGET (page)); - - EosPageManagerPrivate *priv = eos_page_manager_get_instance_private (self); - EosPageManagerPageInfo *info; - - /* Two pages with the same name are not allowed */ - if (name != NULL) - { - info = find_page_info_by_name (self, name); - if (info != NULL && info->page != page) - { - g_critical ("Not setting page name to \"%s\", because page manager " - "already contains a page by that name", - name); - return; - } - } - - info = find_page_info_by_widget (self, page); - if (info == NULL) - { - warn_page_widget_not_found (self, page); - return; - } - - if (g_strcmp0(info->name, name) == 0) - return; - - if (info->name != NULL) - g_hash_table_remove (priv->pages_by_name, info->name); - g_free (info->name); - info->name = g_strdup (name); - if (name != NULL) - g_hash_table_insert (priv->pages_by_name, g_strdup (name), info); - - gtk_container_child_notify (GTK_CONTAINER (self), page, "name"); - - assert_internal_state (self); -} - -/** - * eos_page_manager_get_page_actions: - * @self: the page manager - * @page: the page to be queried - * - * Gets whether to display a fake actions area when displaying @page. - * See #EosPageManager:page-actions for more information. - * - * <warning><para>This function is a temporary implementation, do not expect - * this API to remain stable. - * </para></warning> - * - * Returns: %TRUE if the fake actions area should be visible when displaying - * @page, or %FALSE if it should not. - */ -gboolean -eos_page_manager_get_page_actions (EosPageManager *self, - GtkWidget *page) -{ - g_return_val_if_fail (self != NULL && EOS_IS_PAGE_MANAGER (self), FALSE); - g_return_val_if_fail (page != NULL && GTK_IS_WIDGET (page), FALSE); - - EosPageManagerPageInfo *info = find_page_info_by_widget (self, page); - g_return_val_if_fail (info != NULL, FALSE); - - return info->fake_page_actions_visible; -} - -/** - * eos_page_manager_set_page_actions: - * @self: the page manager - * @page: the page - * @actions_visible: whether to display an action area beside @page - * - * Sets whether to display a fake actions area when displaying @page. - * See #EosPageManager:page-actions for more information. - * - * <warning><para>This function is a temporary implementation, do not expect - * this API to remain stable. - * </para></warning> - */ -void -eos_page_manager_set_page_actions (EosPageManager *self, - GtkWidget *page, - gboolean actions_visible) -{ - g_return_if_fail (self != NULL && EOS_IS_PAGE_MANAGER (self)); - g_return_if_fail (page != NULL && GTK_IS_WIDGET (page)); - - EosPageManagerPageInfo *info = find_page_info_by_widget (self, page); - g_return_if_fail (info != NULL); - - if (info->fake_page_actions_visible == actions_visible) - return; - - info->fake_page_actions_visible = actions_visible; - - gtk_container_child_notify (GTK_CONTAINER (self), page, "page-actions"); -} - -/** - * eos_page_manager_get_page_custom_toolbox_widget: - * @self: the page manager - * @page: the page to be queried - * - * Retrieves @page's custom toolbox widget, if it has one. - * See #EosPageManager:custom-toolbox-widget for more information. - * - * <note><para> - * Currently, there is no possible way to have a non-custom toolbox widget. - * </para></note> - * - * Returns: (transfer none): the custom toolbox #GtkWidget of @page, or %NULL if - * there is none. - */ -GtkWidget * -eos_page_manager_get_page_custom_toolbox_widget (EosPageManager *self, - GtkWidget *page) -{ - g_return_val_if_fail (self != NULL && EOS_IS_PAGE_MANAGER (self), NULL); - g_return_val_if_fail (page != NULL && GTK_IS_WIDGET (page), NULL); - - EosPageManagerPageInfo *info = find_page_info_by_widget (self, page); - g_return_val_if_fail (info != NULL, NULL); - - return info->custom_toolbox_widget; -} - -/** - * eos_page_manager_set_page_custom_toolbox_widget: - * @self: the page manager - * @page: the page - * @custom_toolbox_widget: (allow-none): custom toolbox widget for @page - * - * Sets the custom toolbox widget to display to the left of @page. - * See #EosPageManager:custom-toolbox-widget for more information. - * - * <note><para> - * Currently, there is no possible way to have a non-custom toolbox widget. - * </para></note> - */ -void -eos_page_manager_set_page_custom_toolbox_widget (EosPageManager *self, - GtkWidget *page, - GtkWidget *custom_toolbox_widget) -{ - g_return_if_fail (self != NULL && EOS_IS_PAGE_MANAGER (self)); - g_return_if_fail (page != NULL && GTK_IS_WIDGET (page)); - g_return_if_fail (custom_toolbox_widget == NULL || - GTK_IS_WIDGET (custom_toolbox_widget)); - - EosPageManagerPageInfo *info = find_page_info_by_widget (self, page); - g_return_if_fail (info != NULL); - - if (info->custom_toolbox_widget == custom_toolbox_widget) - return; - - if (info->custom_toolbox_widget) - g_object_unref (info->custom_toolbox_widget); - - g_object_ref (custom_toolbox_widget); - info->custom_toolbox_widget = custom_toolbox_widget; - - gtk_container_child_notify (GTK_CONTAINER (self), page, - "custom-toolbox-widget"); -} - -/** * eos_page_manager_get_page_left_topbar_widget: * @self: the page manager * @page: the page to be queried @@ -1585,123 +802,16 @@ eos_page_manager_remove_page_by_name (EosPageManager *self, { g_return_if_fail (EOS_IS_PAGE_MANAGER (self)); g_return_if_fail (name != NULL); + GtkContainer *container = GTK_CONTAINER (self); - EosPageManagerPageInfo *info = find_page_info_by_name (self, name); - if (info == NULL) + GList *l; + for (l = gtk_container_get_children (container); l != NULL; l = l->next) { - warn_page_name_not_found (self, name); - return; + GtkWidget *child = l->data; + gchar *child_name = NULL; + gtk_container_child_get (container, child, "name", &child_name, NULL); + if (child_name != NULL && g_strcmp0 (child_name, name) == 0) + gtk_container_remove (container, child); + g_free (child_name); } - - /* FIXME: Can't use gtk_container_remove() directly because that asserts - gtk_widget_get_parent(child) == self || GTK_IS_ASSISTANT(self) - See https://bugzilla.gnome.org/show_bug.cgi?id=699756 [endlessm/eos-sdk#67] */ - g_signal_emit_by_name (self, "remove", info->page); - - assert_internal_state (self); -} - -/** - * eos_page_manager_get_transition_duration: - * @self: the page manager - * - * Gets the animation duration of page transitions, in milliseconds. See - * #EosPageManager:transition-duration for more information. - * - * Returns: the current transition time of the page manager. - */ -guint -eos_page_manager_get_transition_duration (EosPageManager *self) -{ - g_return_val_if_fail (EOS_IS_PAGE_MANAGER (self), 0); - - EosPageManagerPrivate *priv = eos_page_manager_get_instance_private (self); - return gtk_stack_get_transition_duration (GTK_STACK (priv->stack)); -} - -/** - * eos_page_manager_set_transition_duration: - * @self: the page manager - * @duration: the duration of page transitions, in milliseconds - * - * Sets the animation duration of page transitions, in milliseconds. See - * #EosPageManager:transition-duration for more information. - */ -void -eos_page_manager_set_transition_duration (EosPageManager *self, - guint duration) -{ - g_return_if_fail (EOS_IS_PAGE_MANAGER (self)); - - EosPageManagerPrivate *priv = eos_page_manager_get_instance_private (self); - gtk_stack_set_transition_duration (GTK_STACK (priv->stack), duration); - g_object_notify (G_OBJECT (self), "transition-duration"); -} - -/** - * eos_page_manager_get_transition_type: - * @self: the page manager - * - * Gets the animation type of page transitions. See - * #EosPageManager:transition-type for more information. - * - * Returns: the current transition type of the page manager. - */ -EosPageManagerTransitionType -eos_page_manager_get_transition_type (EosPageManager *self) -{ - g_return_val_if_fail (EOS_IS_PAGE_MANAGER (self), EOS_PAGE_MANAGER_TRANSITION_TYPE_NONE); - - EosPageManagerPrivate *priv = eos_page_manager_get_instance_private (self); - return priv->transition_type; -} - - -/** - * eos_page_manager_set_transition_type: - * @self: the page manager - * @transition_type: the type of page transitions - * - * Sets the animation type of page transitions. See - * #EosPageManager:transition-type for more information. - */ -void -eos_page_manager_set_transition_type (EosPageManager *self, - EosPageManagerTransitionType transition_type) -{ - g_return_if_fail (EOS_IS_PAGE_MANAGER (self)); - - EosPageManagerPrivate *priv = eos_page_manager_get_instance_private (self); - priv->transition_type = transition_type; - GtkStackTransitionType gtk_stack_transition; - switch (transition_type) - { - case EOS_PAGE_MANAGER_TRANSITION_TYPE_NONE: - case EOS_PAGE_MANAGER_TRANSITION_TYPE_CROSSFADE: - case EOS_PAGE_MANAGER_TRANSITION_TYPE_SLIDE_RIGHT: - case EOS_PAGE_MANAGER_TRANSITION_TYPE_SLIDE_LEFT: - case EOS_PAGE_MANAGER_TRANSITION_TYPE_SLIDE_UP: - case EOS_PAGE_MANAGER_TRANSITION_TYPE_SLIDE_DOWN: - gtk_stack_transition = (GtkStackTransitionType)priv->transition_type; - break; - default: - gtk_stack_transition = GTK_STACK_TRANSITION_TYPE_NONE; - break; - } - gtk_stack_set_transition_type (GTK_STACK (priv->stack), - gtk_stack_transition); - g_object_notify (G_OBJECT (self), "transition-type"); -} - -/* - * eos_page_manager_get_gtk_stack_transition_type: - * @self: the page manager - * - * Gets the internal gtk_stack transition type used to animate the page manager. - */ -GtkStackTransitionType -eos_page_manager_get_gtk_stack_transition_type (EosPageManager *self) -{ - EosPageManagerPrivate *priv = eos_page_manager_get_instance_private (self); - return gtk_stack_get_transition_type (GTK_STACK (priv->stack)); } diff --git a/endless/eospagemanager.h b/endless/eospagemanager.h index 7ec4d97..38e0ac0 100644 --- a/endless/eospagemanager.h +++ b/endless/eospagemanager.h @@ -38,29 +38,6 @@ G_BEGIN_DECLS typedef struct _EosPageManager EosPageManager; typedef struct _EosPageManagerClass EosPageManagerClass; -#define EOS_TYPE_PAGE_MANAGER_TRANSITION_TYPE (eos_page_manager_transition_type_get_type ()) - -/** - * EosPageManagerTransitionType: - * @EOS_PAGE_MANAGER_TRANSITION_TYPE_NONE: No animation, regardless of duration. - * @EOS_PAGE_MANAGER_TRANSITION_TYPE_CROSSFADE: Pages will not move, but fade into one another. - * @EOS_PAGE_MANAGER_TRANSITION_TYPE_SLIDE_RIGHT: The old page will slide off to the right. - * @EOS_PAGE_MANAGER_TRANSITION_TYPE_SLIDE_LEFT: The old page will slide off to the left. - * @EOS_PAGE_MANAGER_TRANSITION_TYPE_SLIDE_UP: The old page will slide up the screen. - * @EOS_PAGE_MANAGER_TRANSITION_TYPE_SLIDE_DOWN: The old page will slide down the screen. - * - * Enum values to specify the type of animation to use when transitioning - * between pages. - **/ -typedef enum { - EOS_PAGE_MANAGER_TRANSITION_TYPE_NONE, - EOS_PAGE_MANAGER_TRANSITION_TYPE_CROSSFADE, - EOS_PAGE_MANAGER_TRANSITION_TYPE_SLIDE_RIGHT, - EOS_PAGE_MANAGER_TRANSITION_TYPE_SLIDE_LEFT, - EOS_PAGE_MANAGER_TRANSITION_TYPE_SLIDE_UP, - EOS_PAGE_MANAGER_TRANSITION_TYPE_SLIDE_DOWN -} EosPageManagerTransitionType; - /** * EosPageManager: * @@ -68,12 +45,12 @@ typedef enum { */ struct _EosPageManager { - GtkContainer parent; + GtkStack parent; }; struct _EosPageManagerClass { - GtkContainerClass parent_class; + GtkStackClass parent_class; /* For further expansion */ gpointer _padding[8]; @@ -83,53 +60,9 @@ EOS_SDK_ALL_API_VERSIONS GType eos_page_manager_get_type (void) G_GNUC_CONST; EOS_SDK_ALL_API_VERSIONS -GType eos_page_manager_transition_type_get_type (void) G_GNUC_CONST; - -EOS_SDK_ALL_API_VERSIONS GtkWidget *eos_page_manager_new (void); EOS_SDK_ALL_API_VERSIONS -GtkWidget *eos_page_manager_get_visible_page (EosPageManager *self); - -EOS_SDK_ALL_API_VERSIONS -void eos_page_manager_set_visible_page (EosPageManager *self, - GtkWidget *page); - -EOS_SDK_ALL_API_VERSIONS -const gchar *eos_page_manager_get_visible_page_name (EosPageManager *self); - -EOS_SDK_ALL_API_VERSIONS -void eos_page_manager_set_visible_page_name (EosPageManager *self, - const gchar *page_name); - -EOS_SDK_ALL_API_VERSIONS -const gchar *eos_page_manager_get_page_name (EosPageManager *self, - GtkWidget *page); - -EOS_SDK_ALL_API_VERSIONS -void eos_page_manager_set_page_name (EosPageManager *self, - GtkWidget *page, - const gchar *name); - -EOS_SDK_ALL_API_VERSIONS -gboolean eos_page_manager_get_page_actions (EosPageManager *self, - GtkWidget *page); - -EOS_SDK_ALL_API_VERSIONS -void eos_page_manager_set_page_actions (EosPageManager *self, - GtkWidget *page, - gboolean actions_visible); - -EOS_SDK_ALL_API_VERSIONS -GtkWidget *eos_page_manager_get_page_custom_toolbox_widget (EosPageManager *self, - GtkWidget *page); - -EOS_SDK_ALL_API_VERSIONS -void eos_page_manager_set_page_custom_toolbox_widget (EosPageManager *self, - GtkWidget *page, - GtkWidget *custom_toolbox_widget); - -EOS_SDK_ALL_API_VERSIONS GtkWidget *eos_page_manager_get_page_left_topbar_widget (EosPageManager *self, GtkWidget *page); @@ -148,20 +81,6 @@ void eos_page_manager_set_page_center_topbar_widget (EosPageManage GtkWidget *center_topbar_widget); EOS_SDK_ALL_API_VERSIONS -void eos_page_manager_set_transition_duration (EosPageManager *self, - guint duration); - -EOS_SDK_ALL_API_VERSIONS -guint eos_page_manager_get_transition_duration (EosPageManager *self); - -EOS_SDK_ALL_API_VERSIONS -void eos_page_manager_set_transition_type (EosPageManager *self, - EosPageManagerTransitionType transition_type); - -EOS_SDK_ALL_API_VERSIONS -EosPageManagerTransitionType eos_page_manager_get_transition_type (EosPageManager *self); - -EOS_SDK_ALL_API_VERSIONS const gchar *eos_page_manager_get_page_background_uri (EosPageManager *self, GtkWidget *page); diff --git a/endless/eossplashpagemanager.c b/endless/eossplashpagemanager.c deleted file mode 100644 index bd13645..0000000 --- a/endless/eossplashpagemanager.c +++ /dev/null @@ -1,349 +0,0 @@ -/* Copyright 2013 Endless Mobile, Inc. */ - -#include "config.h" -#include "eossplashpagemanager.h" - -#include <gtk/gtk.h> - -#include <string.h> - -/** - * SECTION:splash-page-manager - * @short_description: Add splash screen to application - * @title: Splash Page Manager - * - * Builds on the #EosPageManager to provide an application with two pages. - * The first page is called the splash page and is the first page to be - * presented to the user. This is generally a simple page with a minimal - * interface that acts as a gateway to the rest of the application. - * - * The second page, called the main page, is generally where the main work of - * the application will get done. This can be shown instead of the splash page - * at any time by calling eos_splash_page_manager_show_main_page(). - * - * Unlike the generic page manager, the splash page manager can only contain - * two pages. However, the main page can be a second page manager (such as a - * tabbed notebook view), for applications with more complex page flow. - * - * The splash screen and main page can contain any widget. Call - * eos_splash_page_manager_show_main_page() and - * eos_splash_page_manager_show_splash_page() to toggle between the two views. - * The splash screen will be shown by default until a call to - * eos_splash_page_manager_show_main_page() is made. - * - * Javascript example usage: - * |[ - * splash_page_manager = new SplashPageManager({ - * "splash-page": page0, - * "main-page": page1 - * }); - * // After splash page actions completed - * splash_page_manager.show_main_page(); - * ]| - */ - -typedef struct { - GtkWidget *splash_page; - GtkWidget *main_page; - gboolean main_page_shown; -} EosSplashPageManagerPrivate; - -G_DEFINE_TYPE_WITH_PRIVATE (EosSplashPageManager, eos_splash_page_manager, EOS_TYPE_PAGE_MANAGER) - -enum -{ - PROP_0, - PROP_SPLASH_PAGE, - PROP_MAIN_PAGE, - NPROPS -}; - -static GParamSpec *eos_splash_page_manager_props[NPROPS] = { NULL, }; - -static void -eos_splash_page_manager_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - EosSplashPageManager *self = EOS_SPLASH_PAGE_MANAGER (object); - - switch (property_id) - { - case PROP_SPLASH_PAGE: - g_value_set_object (value, eos_splash_page_manager_get_splash_page (self)); - break; - - case PROP_MAIN_PAGE: - g_value_set_object (value, eos_splash_page_manager_get_main_page (self)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - } -} - -static void -eos_splash_page_manager_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - EosSplashPageManager *self = EOS_SPLASH_PAGE_MANAGER (object); - - switch (property_id) - { - case PROP_SPLASH_PAGE: - eos_splash_page_manager_set_splash_page (self, g_value_get_object (value)); - break; - - case PROP_MAIN_PAGE: - eos_splash_page_manager_set_main_page (self, g_value_get_object (value)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - } -} - -static void -eos_splash_page_manager_add (GtkContainer *container, - GtkWidget *new_page) -{ - EosSplashPageManager *self = EOS_SPLASH_PAGE_MANAGER (container); - EosSplashPageManagerPrivate *priv = eos_splash_page_manager_get_instance_private (self); - if (priv->splash_page != NULL) - { - g_critical ("Not adding page %p to splash page manager. You already added" - "a splash page.", new_page); - } - else - { - eos_splash_page_manager_set_splash_page (self, new_page); - } -} - -static void -eos_splash_page_manager_remove (GtkContainer *container, - GtkWidget *page) -{ - EosSplashPageManager *self = EOS_SPLASH_PAGE_MANAGER (container); - EosSplashPageManagerPrivate *priv = eos_splash_page_manager_get_instance_private (self); - if (page == priv->splash_page) - { - eos_splash_page_manager_set_splash_page (self, NULL); - } - if (page == priv->main_page) - { - eos_splash_page_manager_set_main_page (self, NULL); - } -} - -static void -eos_splash_page_manager_class_init (EosSplashPageManagerClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass); - - object_class->get_property = eos_splash_page_manager_get_property; - object_class->set_property = eos_splash_page_manager_set_property; - - container_class->add = eos_splash_page_manager_add; - container_class->remove = eos_splash_page_manager_remove; - - /** - * EosSplashPageManager:splash-page: - * - * A reference to the splash page widget of the splash page manager. If no - * page has been set, points to null. - */ - eos_splash_page_manager_props[PROP_SPLASH_PAGE] = - g_param_spec_object ("splash-page", "Splash page", - "Splash page of the splash page manager", - GTK_TYPE_WIDGET, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - - /** - * EosSplashPageManager:main-page: - * - * A reference to the main page widget of the splash page manager. If no - * page has been set, points to null. - */ - eos_splash_page_manager_props[PROP_MAIN_PAGE] = - g_param_spec_object ("main-page", "Main page", - "Main page of the splash page manager", - GTK_TYPE_WIDGET, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - - g_object_class_install_properties (object_class, NPROPS, - eos_splash_page_manager_props); -} - -static void -eos_splash_page_manager_init (EosSplashPageManager *self) -{ -} - -/* Public API */ - -/** - * eos_splash_page_manager_new: - * - * Creates a new default splash page manager. - * - * Returns: the new page manager. - */ -GtkWidget * -eos_splash_page_manager_new (void) -{ - return g_object_new (EOS_TYPE_SPLASH_PAGE_MANAGER, NULL); -} - -/** - * eos_splash_page_manager_get_splash_page: - * @self: the splash page manager - * - * Gets a pointer to the splash page widget. See #EosSplashPageManager:splash-page - * for more information. - * - * Returns: (transfer none): the page #GtkWidget, or %NULL if the splash page - * has not been set. - */ -GtkWidget * -eos_splash_page_manager_get_splash_page (EosSplashPageManager *self) -{ - g_return_val_if_fail (EOS_IS_SPLASH_PAGE_MANAGER (self), NULL); - - EosSplashPageManagerPrivate *priv = eos_splash_page_manager_get_instance_private (self); - return priv->splash_page; -} - -/** - * eos_splash_page_manager_set_splash_page: - * @self: the splash page manager - * @page: the splash page widget - * - * Sets the widget for the splash page. See #EosSplashPageManager:splash-page - * for more information. Setting this widget will add it to the splash page - * manager as a child, any widget previously set as the splash page will be - * removed. - */ -void -eos_splash_page_manager_set_splash_page (EosSplashPageManager *self, - GtkWidget *page) -{ - g_return_if_fail (EOS_IS_SPLASH_PAGE_MANAGER (self)); - g_return_if_fail (page == NULL || GTK_IS_WIDGET (page)); - g_return_if_fail (page == NULL || gtk_widget_get_parent (page) == NULL); - - EosSplashPageManagerPrivate *priv = eos_splash_page_manager_get_instance_private (self); - - if (priv->splash_page != page) - { - if (priv->splash_page != NULL) - gtk_container_remove (GTK_CONTAINER (self), priv->splash_page); - if (page != NULL) - { - GTK_CONTAINER_CLASS (eos_splash_page_manager_parent_class)->add (GTK_CONTAINER (self), page); - if (!priv->main_page_shown) - eos_page_manager_set_visible_page (EOS_PAGE_MANAGER (self), page); - } - priv->splash_page = page; - g_object_notify( G_OBJECT (self), "splash-page"); - } -} - - -/** - * eos_splash_page_manager_get_main_page: - * @self: the splash page manager - * - * Gets a pointer to the main page widget. See #EosSplashPageManager:main-page - * for more information. - * - * Returns: (transfer none): the page #GtkWidget, or %NULL if the main page - * has not been set. - */ -GtkWidget * -eos_splash_page_manager_get_main_page (EosSplashPageManager *self) -{ - g_return_val_if_fail (EOS_IS_SPLASH_PAGE_MANAGER (self), NULL); - - EosSplashPageManagerPrivate *priv = eos_splash_page_manager_get_instance_private (self); - return priv->main_page; -} - -/** - * eos_splash_page_manager_set_main_page: - * @self: the splash page manager - * @page: the main page widget - * - * Sets the widget for the main page. See #EosSplashPageManager:main-page for - * more information. Setting this widget will add it to the splash page - * manager as a child, any widget previously set as the main page will be - * removed. - */ -void -eos_splash_page_manager_set_main_page (EosSplashPageManager *self, - GtkWidget *page) -{ - g_return_if_fail (EOS_IS_SPLASH_PAGE_MANAGER (self)); - g_return_if_fail (page == NULL || GTK_IS_WIDGET (page)); - g_return_if_fail (page == NULL || gtk_widget_get_parent (page) == NULL); - - EosSplashPageManagerPrivate *priv = eos_splash_page_manager_get_instance_private (self); - if (priv->main_page != page) - { - if (priv->main_page != NULL) - gtk_container_remove (GTK_CONTAINER (self), priv->main_page); - // Call page manager add not our own. - if (page != NULL) - GTK_CONTAINER_CLASS (eos_splash_page_manager_parent_class)->add (GTK_CONTAINER (self), page); - priv->main_page = page; - g_object_notify( G_OBJECT (self), "main-page"); - } -} - -/** - * eos_splash_page_manager_show_main_page: - * @self: the splash page manager - * - * Shows the main page of the splash page manager. - */ -void -eos_splash_page_manager_show_main_page (EosSplashPageManager *self) -{ - g_return_if_fail (EOS_IS_SPLASH_PAGE_MANAGER (self)); - - EosSplashPageManagerPrivate *priv = eos_splash_page_manager_get_instance_private (self); - if (priv->main_page == NULL) - { - g_critical ("Main page is null, have you set it?"); - return; - } - priv->main_page_shown = TRUE; - eos_page_manager_set_visible_page (EOS_PAGE_MANAGER (self), priv->main_page); -} - -/** - * eos_splash_page_manager_show_splash_page: - * @self: the splash page manager - * - * Shows the splash page. This page is shown first by default, so this only - * has effect if you want to "reshow" the page after calling - * eos_splash_page_manager_show_main_page(). - */ -void -eos_splash_page_manager_show_splash_page (EosSplashPageManager *self) -{ - g_return_if_fail (EOS_IS_SPLASH_PAGE_MANAGER (self)); - - EosSplashPageManagerPrivate *priv = eos_splash_page_manager_get_instance_private (self); - if (priv->splash_page == NULL) - { - g_critical ("Splash page is null, have you set it?"); - return; - } - priv->main_page_shown = FALSE; - eos_page_manager_set_visible_page (EOS_PAGE_MANAGER (self), priv->splash_page); -} diff --git a/endless/eossplashpagemanager.h b/endless/eossplashpagemanager.h deleted file mode 100644 index 061176e..0000000 --- a/endless/eossplashpagemanager.h +++ /dev/null @@ -1,89 +0,0 @@ -/* Copyright 2013 Endless Mobile, Inc. */ - -#ifndef EOS_SPLASH_PAGE_MANAGER_H -#define EOS_SPLASH_PAGE_MANAGER_H - -#if !(defined(_EOS_SDK_INSIDE_ENDLESS_H) || defined(COMPILING_EOS_SDK)) -#error "Please do not include this header file directly." -#endif - -#include "eostypes.h" - -#include "eospagemanager.h" - -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -#define EOS_TYPE_SPLASH_PAGE_MANAGER eos_splash_page_manager_get_type() - -#define EOS_SPLASH_PAGE_MANAGER(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - EOS_TYPE_SPLASH_PAGE_MANAGER, EosSplashPageManager)) - -#define EOS_SPLASH_PAGE_MANAGER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), \ - EOS_TYPE_SPLASH_PAGE_MANAGER, EosSplashPageManagerClass)) - -#define EOS_IS_SPLASH_PAGE_MANAGER(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - EOS_TYPE_SPLASH_PAGE_MANAGER)) - -#define EOS_IS_SPLASH_PAGE_MANAGER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), \ - EOS_TYPE_SPLASH_PAGE_MANAGER)) - -#define EOS_SPLASH_PAGE_MANAGER_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - EOS_TYPE_SPLASH_PAGE_MANAGER, EosSplashPageManagerClass)) - -typedef struct _EosSplashPageManager EosSplashPageManager; -typedef struct _EosSplashPageManagerClass EosSplashPageManagerClass; - -/** - * EosSplashPageManager: - * - * This structure contains no public members. - */ -struct _EosSplashPageManager -{ - EosPageManager parent; -}; - -struct _EosSplashPageManagerClass -{ - EosPageManagerClass parent_class; - - /* For further expansion */ - gpointer _padding[8]; -}; - -EOS_SDK_ALL_API_VERSIONS -GType eos_splash_page_manager_get_type (void) G_GNUC_CONST; - -EOS_SDK_ALL_API_VERSIONS -GtkWidget *eos_splash_page_manager_new (void); - -EOS_SDK_ALL_API_VERSIONS -GtkWidget *eos_splash_page_manager_get_splash_page (EosSplashPageManager *self); - -EOS_SDK_ALL_API_VERSIONS -void eos_splash_page_manager_set_splash_page (EosSplashPageManager *self, - GtkWidget *page); - -EOS_SDK_ALL_API_VERSIONS -GtkWidget *eos_splash_page_manager_get_main_page (EosSplashPageManager *self); - -EOS_SDK_ALL_API_VERSIONS -void eos_splash_page_manager_set_main_page (EosSplashPageManager *self, - GtkWidget *page); - -EOS_SDK_ALL_API_VERSIONS -void eos_splash_page_manager_show_main_page (EosSplashPageManager *self); - -EOS_SDK_ALL_API_VERSIONS -void eos_splash_page_manager_show_splash_page (EosSplashPageManager *self); - -G_END_DECLS - -#endif /* EOS_SPLASH_PAGE_MANAGER_H */ diff --git a/endless/eoswindow.c b/endless/eoswindow.c index ce95ae8..b6bd192 100644 --- a/endless/eoswindow.c +++ b/endless/eoswindow.c @@ -6,9 +6,7 @@ #include "eosapplication.h" #include "eospagemanager.h" -#include "eospagemanager-private.h" #include "eostopbar-private.h" -#include "eosmainarea-private.h" #include <gtk/gtk.h> @@ -89,7 +87,6 @@ typedef struct { EosApplication *application; GtkWidget *top_bar; - GtkWidget *main_area; GtkWidget *overlay; GtkSizeGroup *overlay_size_group; GtkWidget *edge_finishing; @@ -111,7 +108,7 @@ typedef struct { /* For keeping track of what to display alongside the current page */ GtkWidget *current_page; - gulong visible_page_property_handler; + gulong visible_child_property_handler; GtkCssProvider *background_provider; gchar *current_background_css_props; } EosWindowPrivate; @@ -149,59 +146,6 @@ override_background_css(EosWindow *self, gchar *background_css) GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); } -/* - * update_page_actions: - * @self: the window - * - * Ensures that the currently shown state of the action area is in line with - * the child properties of the currently showing page. - */ -static void -update_page_actions (EosWindow *self) -{ - EosWindowPrivate *priv = eos_window_get_instance_private (self); - EosPageManager *pm = EOS_PAGE_MANAGER (priv->page_manager); - EosMainArea *ma = EOS_MAIN_AREA (priv->main_area); - GtkWidget *page = priv->current_page; - - if (page != NULL) - { - gboolean fake_action_area = eos_page_manager_get_page_actions (pm, page); - eos_main_area_set_actions (ma, fake_action_area); - } - else - { - eos_main_area_set_actions (ma, FALSE); - } -} - -/* - * update_page_toolbox: - * @self: the window - * - * Ensures that the currently shown state of the toolbox is in line with - * the child properties of the currently showing page. - */ -static void -update_page_toolbox (EosWindow *self) -{ - EosWindowPrivate *priv = eos_window_get_instance_private (self); - EosPageManager *pm = EOS_PAGE_MANAGER (priv->page_manager); - EosMainArea *ma = EOS_MAIN_AREA (priv->main_area); - GtkWidget *page = priv->current_page; - - if (page != NULL) - { - GtkWidget *custom_toolbox_widget = - eos_page_manager_get_page_custom_toolbox_widget (pm, page); - eos_main_area_set_toolbox (ma, custom_toolbox_widget); - } - else - { - eos_main_area_set_toolbox (ma, NULL); - } -} - /** * update_page_left_topbar: * @self: the window @@ -262,9 +206,9 @@ sync_stack_animation (EosWindow *self) EosWindowPrivate *priv = eos_window_get_instance_private (self); EosPageManager *pm = EOS_PAGE_MANAGER (priv->page_manager); gtk_stack_set_transition_type (GTK_STACK (priv->background_stack), - eos_page_manager_get_gtk_stack_transition_type (pm)); + gtk_stack_get_transition_type (GTK_STACK (pm))); gtk_stack_set_transition_duration (GTK_STACK (priv->background_stack), - eos_page_manager_get_transition_duration (pm)); + gtk_stack_get_transition_duration (GTK_STACK (pm))); } // Helper to generate frame css override @@ -331,7 +275,7 @@ update_page_background (EosWindow *self) } /* - * update_visible_page_properties: + * update_visible_child_properties: * @widget: the page * @child_property: the property that changed * @user_data: pointer to the window @@ -340,17 +284,13 @@ update_page_background (EosWindow *self) * changes. */ static void -update_visible_page_properties (GtkWidget *widget, +update_visible_child_properties (GtkWidget *widget, GParamSpec *child_property, gpointer data) { EosWindow *self = (EosWindow *)data; const gchar *property_name = child_property->name; - if (g_strcmp0 (property_name, "page-actions") == 0) - update_page_actions (self); - else if (g_strcmp0 (property_name, "custom-toolbox-widget") == 0) - update_page_toolbox (self); - else if (g_strcmp0 (property_name, "left-topbar-widget") == 0) + if (g_strcmp0 (property_name, "left-topbar-widget") == 0) update_page_left_topbar (self); else if (g_strcmp0 (property_name, "center-topbar-widget") == 0) update_page_center_topbar (self); @@ -365,24 +305,25 @@ update_visible_page_properties (GtkWidget *widget, * update_page: * @self: the window * - * Ensures that the state of the window, the window's main area and top bar are - * in line with the currently showing page and its child properties. + * Ensures that the state of the window and top bar are in line with the + * currently showing page and its child properties. */ static void update_page (EosWindow *self) { + if (gtk_widget_in_destruction (GTK_WIDGET (self))) + return; + EosWindowPrivate *priv = eos_window_get_instance_private (self); EosPageManager *pm = EOS_PAGE_MANAGER (priv->page_manager); if (priv->current_page) { g_signal_handler_disconnect (priv->current_page, - priv->visible_page_property_handler); + priv->visible_child_property_handler); } - priv->current_page = eos_page_manager_get_visible_page (pm); + priv->current_page = gtk_stack_get_visible_child (GTK_STACK (pm)); - update_page_actions (self); - update_page_toolbox (self); sync_stack_animation (self); update_page_left_topbar (self); update_page_center_topbar (self); @@ -392,10 +333,10 @@ update_page (EosWindow *self) if (priv->current_page) { - priv->visible_page_property_handler = + priv->visible_child_property_handler = g_signal_connect (priv->current_page, "child-notify", - G_CALLBACK (update_visible_page_properties), + G_CALLBACK (update_visible_child_properties), self); } } @@ -505,6 +446,7 @@ eos_window_finalize (GObject *object) EosWindow *self = EOS_WINDOW (object); EosWindowPrivate *priv = eos_window_get_instance_private (self); + g_object_unref (priv->edge_finishing); g_object_unref (priv->background_provider); g_object_unref (priv->font_size_provider); g_free (priv->current_background_css_props); @@ -848,15 +790,11 @@ eos_window_init (EosWindow *self) override_background_css (self, background_css); g_free (background_css); - priv->main_area = eos_main_area_new (); - gtk_overlay_add_overlay (GTK_OVERLAY (priv->overlay), priv->main_area); - - // We want the overlay to size to the main area, the widget on top. The + // We want the overlay to size to the page manager, the widget on top. The // overlay gets its size request from the widget on the bottom, the // background frame with no minimum size. So we use a size group. priv->overlay_size_group = gtk_size_group_new (GTK_SIZE_GROUP_BOTH); gtk_size_group_add_widget (priv->overlay_size_group, priv->background_stack); - gtk_size_group_add_widget (priv->overlay_size_group, priv->main_area); priv->edge_finishing = gtk_drawing_area_new (); gtk_widget_set_vexpand (priv->edge_finishing, FALSE); @@ -869,8 +807,8 @@ eos_window_init (EosWindow *self) G_CALLBACK (after_edge_finishing_realize_cb), NULL); g_signal_connect (priv->edge_finishing, "draw", G_CALLBACK (on_edge_finishing_draw_cb), NULL); - gtk_overlay_add_overlay (GTK_OVERLAY (priv->overlay), - priv->edge_finishing); + // We ref the edge finishing as it gets reparented when page managers change + g_object_ref(priv->edge_finishing); gtk_window_maximize (GTK_WINDOW (self)); gtk_window_set_default_size (GTK_WINDOW (self), DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT); @@ -940,16 +878,29 @@ eos_window_set_page_manager (EosWindow *self, g_return_if_fail (page_manager != NULL && EOS_IS_PAGE_MANAGER (page_manager)); EosWindowPrivate *priv = eos_window_get_instance_private (self); - EosMainArea *main_area = EOS_MAIN_AREA (priv->main_area); + if (priv->page_manager != NULL) + { + // We need to remove the edge finishing and add it again so it always + // appears over the page manager + gtk_container_remove (GTK_CONTAINER (priv->overlay), + priv->edge_finishing); + gtk_size_group_remove_widget (priv->overlay_size_group, + GTK_WIDGET (priv->page_manager)); + gtk_container_remove (GTK_CONTAINER (priv->overlay), + GTK_WIDGET (priv->page_manager)); + } priv->page_manager = page_manager; - - eos_main_area_set_content (main_area, + gtk_overlay_add_overlay (GTK_OVERLAY (priv->overlay), + GTK_WIDGET (priv->page_manager)); + gtk_overlay_add_overlay (GTK_OVERLAY (priv->overlay), + priv->edge_finishing); + gtk_size_group_add_widget (priv->overlay_size_group, GTK_WIDGET (priv->page_manager)); update_page (self); - g_signal_connect_swapped (priv->page_manager, "notify::visible-page", + g_signal_connect_swapped (priv->page_manager, "notify::visible-child", G_CALLBACK (update_page), self); } diff --git a/overrides/Endless.js b/overrides/Endless.js index 02eed50..1ed3312 100644 --- a/overrides/Endless.js +++ b/overrides/Endless.js @@ -42,16 +42,4 @@ function _init() { } } } - - // Override Endless.ActionMenu.add_action() so that we hide the use of - // GtkAction from the developer, as that will be deprecated in the future. - Endless.ActionMenu.prototype._add_action_real = Endless.ActionMenu.prototype.add_action; - Endless.ActionMenu.prototype.add_action = function(dict, callback) { - let action = new Gtk.Action(dict); - this._add_action_real(action); - - if (typeof callback === "function") { - action.connect('activate', callback); - } - } } diff --git a/test/endless/Makefile.am.inc b/test/endless/Makefile.am.inc index ac030a3..536a878 100644 --- a/test/endless/Makefile.am.inc +++ b/test/endless/Makefile.am.inc @@ -7,10 +7,7 @@ test_endless_run_tests_SOURCES = \ $(ENDLESS_TESTS_DIRECTORY)/endless/test-hello.c \ $(ENDLESS_TESTS_DIRECTORY)/endless/test-application.c \ $(ENDLESS_TESTS_DIRECTORY)/endless/test-page-manager.c \ - $(ENDLESS_TESTS_DIRECTORY)/endless/test-splash-page-manager.c \ $(ENDLESS_TESTS_DIRECTORY)/endless/test-window.c \ - $(ENDLESS_TESTS_DIRECTORY)/endless/test-action-menu.c \ - $(ENDLESS_TESTS_DIRECTORY)/endless/test-action-button.c \ $(ENDLESS_TESTS_DIRECTORY)/endless/test-flexy-grid.c \ $(ENDLESS_TESTS_DIRECTORY)/endless/test-custom-container.c \ $(NULL) diff --git a/test/endless/run-tests.c b/test/endless/run-tests.c index 4bc4006..09b466a 100644 --- a/test/endless/run-tests.c +++ b/test/endless/run-tests.c @@ -107,9 +107,6 @@ main (int argc, add_application_tests (); add_window_tests (); add_page_manager_tests (); - add_splash_page_manager_tests (); - add_action_menu_tests (); - add_action_button_tests (); add_flexy_grid_test (); add_custom_container_tests (); diff --git a/test/endless/run-tests.h b/test/endless/run-tests.h index cb52ab7..b43ef53 100644 --- a/test/endless/run-tests.h +++ b/test/endless/run-tests.h @@ -37,7 +37,6 @@ void add_hello_tests (void); void add_application_tests (void); void add_window_tests (void); void add_page_manager_tests (void); -void add_splash_page_manager_tests (void); void add_action_menu_tests (void); void add_action_button_tests (void); void add_flexy_grid_test (void); diff --git a/test/endless/test-action-button.c b/test/endless/test-action-button.c deleted file mode 100644 index 7e4ad15..0000000 --- a/test/endless/test-action-button.c +++ /dev/null @@ -1,225 +0,0 @@ -#include <gtk/gtk.h> -#include <endless/endless.h> - -#include "run-tests.h" - -#define ADD_ACTION_BUTTON_TEST(path, test_func) \ - g_test_add ((path), ActionButtonFixture, NULL, \ - ab_fixture_setup, (test_func), ab_fixture_teardown) - -#define EXPECTED_DEFAULT_SIZE EOS_ACTION_BUTTON_SIZE_SECONDARY -#define EXPECTED_DEFAULT_LABEL NULL -#define EXPECTED_DEFAULT_ICON_NAME NULL - -#define INITIAL_SIZE EOS_ACTION_BUTTON_SIZE_PRIMARY -#define INITIAL_LABEL "add" -#define INITIAL_ICON_NAME "list-add-symbolic" - -/* When testing setters and getters, set values to these; should be different -from INITIAL_x */ -#define EXPECTED_SIZE EOS_ACTION_BUTTON_SIZE_SECONDARY -#define EXPECTED_LABEL "remove" -#define EXPECTED_ICON_NAME "list-remove-symbolic" - -typedef struct -{ - GtkWidget *window; - EosActionButton *button; -} ActionButtonFixture; - -static void -ab_fixture_setup (ActionButtonFixture *fixture, - gconstpointer unused) -{ - fixture->button = EOS_ACTION_BUTTON (eos_action_button_new (INITIAL_SIZE, - INITIAL_LABEL, - INITIAL_ICON_NAME)); - - /* Place it in an offscreen window so that we can test the size */ - fixture->window = gtk_offscreen_window_new (); - gtk_container_add (GTK_CONTAINER (fixture->window), - GTK_WIDGET (fixture->button)); - - gtk_widget_show_all (GTK_WIDGET (fixture->window)); -} - -static void -ab_fixture_teardown (ActionButtonFixture *fixture, - gconstpointer unused) -{ - gtk_widget_destroy (GTK_WIDGET (fixture->window)); -} - -/* TESTS */ - -static void -test_ab_default_properties (void) -{ - /* Create it using g_object_new() so that the properties are not explicitly - set */ - EosActionButton *button = EOS_ACTION_BUTTON (g_object_new (EOS_TYPE_ACTION_BUTTON, - NULL)); - EosActionButtonSize size = eos_action_button_get_size (button); - const gchar *label = eos_action_button_get_label (button); - const gchar *icon_name = eos_action_button_get_icon_id (button); - - g_assert_cmpint (size, ==, EXPECTED_DEFAULT_SIZE); - g_assert_cmpstr (label, ==, EXPECTED_DEFAULT_LABEL); - g_assert_cmpstr (icon_name, ==, EXPECTED_DEFAULT_ICON_NAME); -} - -static void -test_ab_get_set_size (ActionButtonFixture *fixture, - gconstpointer unused) -{ - EosActionButtonSize size; - - size = eos_action_button_get_size (fixture->button); - g_assert_cmpint (size, ==, INITIAL_SIZE); - - eos_action_button_set_size (fixture->button, EXPECTED_SIZE); - size = eos_action_button_get_size (fixture->button); - g_assert_cmpint (size, ==, EXPECTED_SIZE); -} - -static void -test_ab_prop_size (ActionButtonFixture *fixture, - gconstpointer unused) -{ - EosActionButtonSize size; - - g_object_get (fixture->button, "size", &size, NULL); - g_assert_cmpint (size, ==, INITIAL_SIZE); - - g_object_set (fixture->button, "size", EXPECTED_SIZE, NULL); - g_object_get (fixture->button, "size", &size, NULL); - g_assert_cmpint (size, ==, EXPECTED_SIZE); -} - -static void -test_ab_get_set_label (ActionButtonFixture *fixture, - gconstpointer unused) -{ - const gchar *label; - - label = eos_action_button_get_label (fixture->button); - g_assert_cmpstr (label, ==, INITIAL_LABEL); - - eos_action_button_set_label (fixture->button, EXPECTED_LABEL); - label = eos_action_button_get_label (fixture->button); - g_assert_cmpstr (label, ==, EXPECTED_LABEL); -} - -static void -test_ab_prop_label (ActionButtonFixture *fixture, - gconstpointer unused) -{ - gchar *label; - - g_object_get (fixture->button, "label", &label, NULL); - g_assert_cmpstr (label, ==, INITIAL_LABEL); - g_free (label); - - g_object_set (fixture->button, "label", EXPECTED_LABEL, NULL); - g_object_get (fixture->button, "label", &label, NULL); - g_assert_cmpstr (label, ==, EXPECTED_LABEL); - g_free (label); -} - -static void -test_ab_get_set_icon_name (ActionButtonFixture *fixture, - gconstpointer unused) -{ - const gchar *icon_name; - - icon_name = eos_action_button_get_icon_id (fixture->button); - g_assert_cmpstr (icon_name, ==, INITIAL_ICON_NAME); - - eos_action_button_set_icon_id (fixture->button, EXPECTED_ICON_NAME); - icon_name = eos_action_button_get_icon_id (fixture->button); - g_assert_cmpstr (icon_name, ==, EXPECTED_ICON_NAME); -} - -static void -test_ab_prop_icon_name (ActionButtonFixture *fixture, - gconstpointer unused) -{ - gchar *icon_name; - - g_object_get (fixture->button, "icon-id", &icon_name, NULL); - g_assert_cmpstr (icon_name, ==, INITIAL_ICON_NAME); - g_free (icon_name); - - g_object_set (fixture->button, "icon-id", EXPECTED_ICON_NAME, NULL); - g_object_get (fixture->button, "icon-id", &icon_name, NULL); - g_assert_cmpstr (icon_name, ==, EXPECTED_ICON_NAME); - g_free (icon_name); -} - -static void -test_ab_get_set_label_position (ActionButtonFixture *fixture, - gconstpointer unused) -{ - GtkPositionType label_pos; - - label_pos = eos_action_button_get_label_position (fixture->button); - g_assert (label_pos == GTK_POS_BOTTOM); - - eos_action_button_set_label_position (fixture->button, GTK_POS_TOP); - label_pos = eos_action_button_get_label_position (fixture->button); - g_assert (label_pos == GTK_POS_TOP); -} - -static void -test_ab_prop_label_position (ActionButtonFixture *fixture, - gconstpointer unused) -{ - GtkPositionType label_pos; - - g_object_get (fixture->button, "label-position", &label_pos, NULL); - g_assert (label_pos == GTK_POS_BOTTOM); - - g_object_set (fixture->button, "label-position", GTK_POS_TOP, NULL); - g_object_get (fixture->button, "label-position", &label_pos, NULL); - g_assert (label_pos == GTK_POS_TOP); -} - -static void -test_ab_label_agrees (ActionButtonFixture *fixture, - gconstpointer unused) -{ - GtkWidget *inner_label; - const gchar *label_text; - - inner_label = container_find_descendant_with_type (GTK_CONTAINER (fixture->button), - GTK_TYPE_LABEL); - g_assert (inner_label); - - label_text = gtk_label_get_text (GTK_LABEL (inner_label)); - g_assert_cmpstr (label_text, ==, INITIAL_LABEL); - - eos_action_button_set_label (fixture->button, EXPECTED_LABEL); - label_text = gtk_label_get_text (GTK_LABEL (inner_label)); - g_assert_cmpstr (label_text, ==, EXPECTED_LABEL); -} - -void -add_action_button_tests (void) -{ - g_test_add_func ("/action-button/default-properties", - test_ab_default_properties); - ADD_ACTION_BUTTON_TEST ("/action-button/get-set-size", test_ab_get_set_size); - ADD_ACTION_BUTTON_TEST ("/action-button/prop-size", test_ab_prop_size); - ADD_ACTION_BUTTON_TEST ("/action-button/get-set-label", - test_ab_get_set_label); - ADD_ACTION_BUTTON_TEST ("/action-button/prop-label", test_ab_prop_label); - ADD_ACTION_BUTTON_TEST ("/action-button/get-set-icon-name", - test_ab_get_set_icon_name); - ADD_ACTION_BUTTON_TEST ("/action-button/prop-icon-name", - test_ab_prop_icon_name); - ADD_ACTION_BUTTON_TEST ("/action-button/get-set-label-position", - test_ab_get_set_label_position); - ADD_ACTION_BUTTON_TEST ("/action-button/prop-label-position", - test_ab_prop_label_position); - ADD_ACTION_BUTTON_TEST ("/action-button/label-agrees", test_ab_label_agrees); -} diff --git a/test/endless/test-action-menu.c b/test/endless/test-action-menu.c deleted file mode 100644 index 0450f6c..0000000 --- a/test/endless/test-action-menu.c +++ /dev/null @@ -1,217 +0,0 @@ -#include <gtk/gtk.h> -#include <endless/endless.h> - -#include <endless/eosactionmenu-private.h> - -#include "run-tests.h" - -#include "endless/eosactionmenu.c" - -#define ADD_ACTION_MENU_TEST(path, test_func) \ - g_test_add ((path), ActionMenuFixture, NULL, \ - am_fixture_setup, (test_func), am_fixture_teardown) - -typedef struct -{ - EosActionMenu *action_menu; - GtkAction *action1; - GtkAction *action2; - GtkAction *action3; -} ActionMenuFixture; - -static void -am_fixture_setup (ActionMenuFixture *fixture, - gconstpointer unused) -{ - fixture->action_menu = EOS_ACTION_MENU (eos_action_menu_new ()); - fixture->action1 = gtk_action_new ("1", "1", "1", "1"); - fixture->action2 = gtk_action_new ("2", "2", "2", "2"); - fixture->action3 = gtk_action_new ("3", "3", "3", "3"); - - g_object_ref (fixture->action1); - g_object_ref (fixture->action2); - g_object_ref (fixture->action3); -} - -static void -am_fixture_teardown (ActionMenuFixture *fixture, - gconstpointer unused) -{ - gtk_widget_destroy (GTK_WIDGET (fixture->action_menu)); - g_object_unref (fixture->action1); - g_object_unref (fixture->action2); - g_object_unref (fixture->action3); -} - -/* TESTS */ - -static void -test_am_add_action (ActionMenuFixture *fixture, - gconstpointer unused) -{ - gint size; - gchar *label, *icon_id; - - gtk_action_set_is_important (fixture->action1, TRUE); - gtk_action_set_icon_name (fixture->action1, "object-select-symbolic"); - - eos_action_menu_add_action (fixture->action_menu, fixture->action1); - - EosActionMenuPrivate *action_menu_priv = eos_action_menu_get_instance_private (fixture->action_menu); - GtkWidget *button = gtk_grid_get_child_at (GTK_GRID (action_menu_priv->center_grid), 0, 0); - - g_assert (EOS_IS_ACTION_BUTTON (button)); - - g_object_get (button, - "size", &size, - "label", &label, - "icon-id", &icon_id, - NULL); - - g_assert ( size == EOS_ACTION_BUTTON_SIZE_PRIMARY); - g_assert ( g_strcmp0 (label, gtk_action_get_label (fixture->action1)) == 0); - g_assert ( g_strcmp0 (icon_id, gtk_action_get_icon_name (fixture->action1)) == 0); - - g_free (label); - g_free (icon_id); -} - -static void -test_am_get_action (ActionMenuFixture *fixture, - gconstpointer unused) -{ - eos_action_menu_add_action (fixture->action_menu, fixture->action1); - - GtkAction *retrieved = eos_action_menu_get_action (fixture->action_menu, "1"); - - g_assert (retrieved == fixture->action1); -} - -static void -test_am_list_actions (ActionMenuFixture *fixture, - gconstpointer unused) -{ - GList *list = eos_action_menu_list_actions (fixture->action_menu); - - g_assert (list == NULL); - - eos_action_menu_add_action (fixture->action_menu, fixture->action1); - eos_action_menu_add_action (fixture->action_menu, fixture->action2); - - list = eos_action_menu_list_actions (fixture->action_menu); - - g_assert (g_list_find (list, fixture->action1) != NULL); - g_assert (g_list_find (list, fixture->action2) != NULL); - - g_assert (g_list_find (list, fixture->action3) == NULL); -} - -static gboolean -menu_contains_button_with_label (EosActionMenu *menu, const gchar* button_label) -{ - GList* children; - gboolean found = FALSE; - - EosActionMenuPrivate *action_menu_priv = eos_action_menu_get_instance_private (menu); - children = gtk_container_get_children (GTK_CONTAINER (action_menu_priv->center_grid)); - - children = g_list_concat (children, - gtk_container_get_children (GTK_CONTAINER (action_menu_priv->bottom_grid))); - - for (GList *i = children; i != NULL ; i = i->next) - { - if (EOS_IS_ACTION_BUTTON (i->data)) - { - if (g_strcmp0 (eos_action_button_get_label (EOS_ACTION_BUTTON (i->data)), - button_label) == 0) - { - found = TRUE; - break; - } - } - } - - g_list_free (children); - - return found; -} - -static void -test_am_remove_action (ActionMenuFixture *fixture, - gconstpointer unused) -{ - GList *list; - - eos_action_menu_add_action (fixture->action_menu, fixture->action1); - eos_action_menu_add_action (fixture->action_menu, fixture->action2); - eos_action_menu_add_action (fixture->action_menu, fixture->action3); - - eos_action_menu_remove_action (fixture->action_menu, fixture->action2); - - list = eos_action_menu_list_actions (fixture->action_menu); - - g_assert (g_list_find (list, fixture->action1) != NULL); - g_assert (g_list_find (list, fixture->action2) == NULL); - g_assert (g_list_find (list, fixture->action3) != NULL); - - // the buttons have been removed as well - g_assert (menu_contains_button_with_label (fixture->action_menu, - gtk_action_get_label (fixture->action1))); - g_assert (!menu_contains_button_with_label (fixture->action_menu, - gtk_action_get_label (fixture->action2))); - g_assert (menu_contains_button_with_label (fixture->action_menu, - gtk_action_get_label (fixture->action3))); - - eos_action_menu_remove_action (fixture->action_menu, fixture->action1); - eos_action_menu_remove_action (fixture->action_menu, fixture->action3); - - list = eos_action_menu_list_actions (fixture->action_menu); - - g_assert (g_list_find (list, fixture->action1) == NULL); - g_assert (g_list_find (list, fixture->action2) == NULL); - g_assert (g_list_find (list, fixture->action3) == NULL); - - // the container is empty - EosActionMenuPrivate *action_menu_priv = eos_action_menu_get_instance_private (fixture->action_menu); - g_assert (gtk_container_get_children (GTK_CONTAINER (action_menu_priv->center_grid)) == NULL); - g_assert (gtk_container_get_children (GTK_CONTAINER (action_menu_priv->bottom_grid)) == NULL); -} - -static void -test_am_remove_action_by_name (ActionMenuFixture *fixture, - gconstpointer unused) -{ - eos_action_menu_add_action (fixture->action_menu, fixture->action1); - eos_action_menu_add_action (fixture->action_menu, fixture->action2); - eos_action_menu_add_action (fixture->action_menu, fixture->action3); - - eos_action_menu_remove_action_by_name (fixture->action_menu, "2"); - - GList *list = eos_action_menu_list_actions (fixture->action_menu); - - g_assert (g_list_find (list, fixture->action1) != NULL); - g_assert (g_list_find (list, fixture->action2) == NULL); - g_assert (g_list_find (list, fixture->action3) != NULL); - - g_assert (menu_contains_button_with_label (fixture->action_menu, - gtk_action_get_label (fixture->action1))); - g_assert (!menu_contains_button_with_label (fixture->action_menu, - gtk_action_get_label (fixture->action2))); - g_assert (menu_contains_button_with_label (fixture->action_menu, - gtk_action_get_label (fixture->action3))); -} - -void -add_action_menu_tests (void) -{ - ADD_ACTION_MENU_TEST ("/action-menu/add-action", - test_am_add_action); - ADD_ACTION_MENU_TEST ("/action-menu/get-action", - test_am_get_action); - ADD_ACTION_MENU_TEST ("/action-menu/list-actions", - test_am_list_actions); - ADD_ACTION_MENU_TEST ("/action-menu/remove-action", - test_am_remove_action); - ADD_ACTION_MENU_TEST ("/action-menu/remove-action-by-name", - test_am_remove_action_by_name); -} diff --git a/test/endless/test-page-manager.c b/test/endless/test-page-manager.c index a39fb3f..98cdadc 100644 --- a/test/endless/test-page-manager.c +++ b/test/endless/test-page-manager.c @@ -9,12 +9,6 @@ #define PAGE1_PROP_STRING "prop1" #define PAGE2_PROP_STRING "prop2" #define PAGE3_PROP_STRING "prop3" -#define EXPECTED_PAGE_NAME PAGE2_NAME -#define EXPECTED_CHANGED_PAGE_NAME "changed-name" -#define DUPLICATE_PAGE_NAME "duplicate-name" -#define EXPECTED_DUPLICATE_PAGE_NAME_ERRMSG "*Not setting page name to \"" \ - DUPLICATE_PAGE_NAME "\", because page manager already contains a page by " \ - "that name*" #define EXPECTED_PAGE_PROP_STRING PAGE2_PROP_STRING #define EXPECTED_CHANGED_NAME "changed-name" #define ADD_PAGE_MANAGER_TEST(path, test_func) \ @@ -23,12 +17,6 @@ #define ADD_PAGE_MANAGER_TEST_WITH_ARGS(path, test_func, args) \ g_test_add ((path), PageManagerFixture, args, \ pm_fixture_setup, (test_func), pm_fixture_teardown) -#define ADD_EMPTY_PAGE_MANAGER_TEST(path, test_func) \ - g_test_add ((path), PageManagerFixture, NULL, \ - empty_pm_fixture_setup, (test_func), pm_fixture_teardown); -#define DURATION_DEFAULT 200 -#define DURATION_1 1 -#define DURATION_2 9999 #define BACKGROUND_SIZE_DEFAULT "100% 100%" #define BACKGROUND_POSITION_DEFAULT "0% 0%" @@ -38,7 +26,6 @@ typedef struct GtkWidget *page1; GtkWidget *page2; GtkWidget *page3; - GtkWidget *toolbox2; } PageManagerFixture; static void @@ -49,7 +36,6 @@ pm_fixture_setup (PageManagerFixture *fixture, fixture->page1 = gtk_label_new ("1"); fixture->page2 = gtk_label_new ("2"); fixture->page3 = gtk_label_new ("3"); - fixture->toolbox2 = gtk_label_new ("toolbox2"); gtk_container_add_with_properties (GTK_CONTAINER (fixture->pm), fixture->page1, "name", PAGE1_NAME, @@ -60,7 +46,6 @@ pm_fixture_setup (PageManagerFixture *fixture, gtk_container_add_with_properties (GTK_CONTAINER (fixture->pm), fixture->page2, "name", PAGE2_NAME, - "custom-toolbox-widget", fixture->toolbox2, "background-uri", PAGE2_PROP_STRING, "background-size", PAGE2_PROP_STRING, "background-position", PAGE2_PROP_STRING, @@ -68,7 +53,6 @@ pm_fixture_setup (PageManagerFixture *fixture, gtk_container_add_with_properties (GTK_CONTAINER (fixture->pm), fixture->page3, "name", PAGE3_NAME, - "page-actions", TRUE, "background-uri", PAGE3_PROP_STRING, "background-size", PAGE3_PROP_STRING, "background-position", PAGE3_PROP_STRING, @@ -77,13 +61,6 @@ pm_fixture_setup (PageManagerFixture *fixture, } static void -empty_pm_fixture_setup (PageManagerFixture *fixture, - gconstpointer unused) -{ - fixture->pm = eos_page_manager_new (); -} - -static void pm_fixture_teardown (PageManagerFixture *fixture, gconstpointer unused) { @@ -91,151 +68,6 @@ pm_fixture_teardown (PageManagerFixture *fixture, } static void -test_pm_get_set_visible_page (PageManagerFixture *fixture, - gconstpointer unused) -{ - GtkWidget *visible_page; - visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->pm)); - g_assert (visible_page != fixture->page2); - eos_page_manager_set_visible_page (EOS_PAGE_MANAGER (fixture->pm), - fixture->page2); - visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->pm)); - g_assert (visible_page == fixture->page2); -} - -static void -test_pm_prop_visible_page (PageManagerFixture *fixture, - gconstpointer unused) -{ - GtkWidget *visible_page; - g_object_get (fixture->pm, "visible-page", &visible_page, NULL); - g_assert (visible_page != fixture->page2); - g_object_set (fixture->pm, "visible-page", fixture->page2, NULL); - g_object_get (fixture->pm, "visible-page", &visible_page, NULL); - g_assert (visible_page == fixture->page2); -} - -static void -test_pm_get_set_visible_page_name (PageManagerFixture *fixture, - gconstpointer unused) -{ - const gchar *name; - name = eos_page_manager_get_visible_page_name (EOS_PAGE_MANAGER (fixture->pm)); - g_assert_cmpstr (name, !=, EXPECTED_PAGE_NAME); - eos_page_manager_set_visible_page_name (EOS_PAGE_MANAGER (fixture->pm), - EXPECTED_PAGE_NAME); - name = eos_page_manager_get_visible_page_name (EOS_PAGE_MANAGER (fixture->pm)); - g_assert_cmpstr (name, ==, EXPECTED_PAGE_NAME); -} - -static void -test_pm_prop_visible_page_name (PageManagerFixture *fixture, - gconstpointer unused) -{ - gchar *name; - g_object_get (fixture->pm, "visible-page-name", &name, NULL); - g_assert_cmpstr (name, !=, EXPECTED_PAGE_NAME); - g_free (name); - g_object_set (fixture->pm, "visible-page-name", EXPECTED_PAGE_NAME, NULL); - g_object_get (fixture->pm, "visible-page-name", &name, NULL); - g_assert_cmpstr (name, ==, EXPECTED_PAGE_NAME); - g_free (name); -} - -static void -test_pm_get_set_page_name (PageManagerFixture *fixture, - gconstpointer unused) -{ - const gchar *name; - name = eos_page_manager_get_page_name (EOS_PAGE_MANAGER (fixture->pm), - fixture->page1); - g_assert_cmpstr (name, ==, PAGE1_NAME); - name = eos_page_manager_get_page_name (EOS_PAGE_MANAGER (fixture->pm), - fixture->page2); - g_assert_cmpstr (name, ==, PAGE2_NAME); - name = eos_page_manager_get_page_name (EOS_PAGE_MANAGER (fixture->pm), - fixture->page3); - g_assert_cmpstr (name, ==, PAGE3_NAME); - eos_page_manager_set_page_name (EOS_PAGE_MANAGER (fixture->pm), - fixture->page2, - EXPECTED_CHANGED_NAME); - name = eos_page_manager_get_page_name (EOS_PAGE_MANAGER (fixture->pm), - fixture->page2); - g_assert_cmpstr (name, ==, EXPECTED_CHANGED_NAME); -} - -static void -test_pm_child_prop_name (PageManagerFixture *fixture, - gconstpointer unused) -{ - gchar *name; - gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page1, - "name", &name, - NULL); - g_assert_cmpstr (name, ==, PAGE1_NAME); - g_free (name); - gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page2, - "name", &name, - NULL); - g_assert_cmpstr (name, ==, PAGE2_NAME); - g_free (name); - gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page3, - "name", &name, - NULL); - g_assert_cmpstr (name, ==, PAGE3_NAME); - g_free (name); - gtk_container_child_set (GTK_CONTAINER (fixture->pm), fixture->page2, - "name", EXPECTED_CHANGED_NAME, - NULL); - gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page2, - "name", &name, - NULL); - g_assert_cmpstr (name, ==, EXPECTED_CHANGED_NAME); - g_free (name); -} - -static void -test_pm_get_set_page_actions (PageManagerFixture *fixture, - gconstpointer unused) -{ - gboolean actions; - actions = eos_page_manager_get_page_actions (EOS_PAGE_MANAGER (fixture->pm), - fixture->page1); - g_assert (actions == FALSE); - actions = eos_page_manager_get_page_actions (EOS_PAGE_MANAGER (fixture->pm), - fixture->page3); - g_assert (actions == TRUE); - eos_page_manager_set_page_actions (EOS_PAGE_MANAGER (fixture->pm), - fixture->page3, - FALSE); - actions = eos_page_manager_get_page_actions (EOS_PAGE_MANAGER (fixture->pm), - fixture->page3); - g_assert (actions == FALSE); -} - -static void -test_pm_child_prop_page_actions (PageManagerFixture *fixture, - gconstpointer unused) -{ - gboolean actions; - gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page1, - "page-actions", &actions, - NULL); - g_assert (actions == FALSE); - gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page3, - "page-actions", &actions, - NULL); - g_assert (actions == TRUE); - gtk_container_child_set (GTK_CONTAINER (fixture->pm), fixture->page3, - "page-actions", FALSE, - NULL); - gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page3, - "page-actions", &actions, - NULL); - g_assert (actions == FALSE); -} - -static void test_pm_get_set_background_repeats (PageManagerFixture *fixture, gconstpointer unused) { @@ -277,68 +109,6 @@ test_pm_child_prop_background_repeats (PageManagerFixture *fixture, } static void -test_pm_get_set_page_custom_toolbox (PageManagerFixture *fixture, - gconstpointer unused) -{ - GtkWidget *new_tb = gtk_label_new ("Another toolbox"); - GtkWidget *tb; - - tb = eos_page_manager_get_page_custom_toolbox_widget (EOS_PAGE_MANAGER (fixture->pm), - fixture->page1); - g_assert (tb == NULL); - tb = eos_page_manager_get_page_custom_toolbox_widget (EOS_PAGE_MANAGER (fixture->pm), - fixture->page2); - g_assert (tb == fixture->toolbox2); - - eos_page_manager_set_page_custom_toolbox_widget (EOS_PAGE_MANAGER (fixture->pm), - fixture->page1, - new_tb); - eos_page_manager_set_page_custom_toolbox_widget (EOS_PAGE_MANAGER (fixture->pm), - fixture->page2, - new_tb); - - tb = eos_page_manager_get_page_custom_toolbox_widget (EOS_PAGE_MANAGER (fixture->pm), - fixture->page1); - g_assert (tb == new_tb); - tb = eos_page_manager_get_page_custom_toolbox_widget (EOS_PAGE_MANAGER (fixture->pm), - fixture->page2); - g_assert (tb == new_tb); -} - -static void -test_pm_child_prop_custom_toolbox (PageManagerFixture *fixture, - gconstpointer unused) -{ - GtkWidget *new_tb = gtk_label_new ("Another toolbox"); - GtkWidget *tb; - - gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page1, - "custom-toolbox-widget", &tb, - NULL); - g_assert (tb == NULL); - gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page2, - "custom-toolbox-widget", &tb, - NULL); - g_assert (tb == fixture->toolbox2); - - gtk_container_child_set (GTK_CONTAINER (fixture->pm), fixture->page1, - "custom-toolbox-widget", new_tb, - NULL); - gtk_container_child_set (GTK_CONTAINER (fixture->pm), fixture->page2, - "custom-toolbox-widget", new_tb, - NULL); - - gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page1, - "custom-toolbox-widget", &tb, - NULL); - g_assert (tb == new_tb); - gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page2, - "custom-toolbox-widget", &tb, - NULL); - g_assert (tb == new_tb); -} - -static void test_pm_child_prop_string (PageManagerFixture *fixture, gconstpointer data) { @@ -370,37 +140,6 @@ test_pm_child_prop_string (PageManagerFixture *fixture, } static void -test_pm_page_no_name (PageManagerFixture *fixture, - gconstpointer unused) -{ - const gchar *name_get; - gchar *name_prop; - GtkWidget *new_page = gtk_label_new("new"); - gtk_container_add (GTK_CONTAINER (fixture->pm), new_page); - name_get = eos_page_manager_get_page_name (EOS_PAGE_MANAGER (fixture->pm), new_page); - g_assert (name_get == NULL); - gtk_container_child_get (GTK_CONTAINER (fixture->pm), new_page, - "name", &name_prop, - NULL); - g_assert (name_prop == NULL); -} - -static void -test_pm_set_page_no_name (PageManagerFixture *fixture, - gconstpointer unused) -{ - const gchar *name; - eos_page_manager_set_page_name (EOS_PAGE_MANAGER (fixture->pm), - fixture->page1, - NULL); - name = eos_page_manager_get_page_name (EOS_PAGE_MANAGER (fixture->pm), - fixture->page1); - g_assert (name == NULL); - name = eos_page_manager_get_visible_page_name (EOS_PAGE_MANAGER (fixture->pm)); - g_assert (name == NULL); -} - -static void test_pm_no_background_uri (PageManagerFixture *fixture, gconstpointer unused) { @@ -527,43 +266,6 @@ test_pm_get_set_background_position (PageManagerFixture *fixture, } static void -test_pm_remove_page_behavior (PageManagerFixture *fixture, - gconstpointer unused) -{ - GtkWidget *visible_page; - visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->pm)); - g_assert (visible_page == fixture->page1); - gtk_container_remove (GTK_CONTAINER (fixture->pm), fixture->page3); - visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->pm)); - g_assert (visible_page == fixture->page1); - gtk_container_remove (GTK_CONTAINER (fixture->pm), fixture->page2); - visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->pm)); - g_assert (visible_page == fixture->page1); - gtk_container_remove (GTK_CONTAINER (fixture->pm), fixture->page1); - visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->pm)); - g_assert (visible_page == NULL); -} - -static void -test_pm_remove_page_undefined_behavior (PageManagerFixture *fixture, - gconstpointer unused) -{ - GtkWidget *visible_page; - GtkWidget *page1 = gtk_label_new ("page1"); - GtkWidget *page2 = gtk_label_new ("page2"); - gtk_container_add (GTK_CONTAINER (fixture->pm), page1); - gtk_container_add (GTK_CONTAINER (fixture->pm), page2); - eos_page_manager_set_visible_page (EOS_PAGE_MANAGER (fixture->pm), - page1); - visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->pm)); - g_assert (visible_page == page1); - gtk_container_remove (GTK_CONTAINER (fixture->pm), page1); - // Only one page left, so it should be the visible page. - visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->pm)); - g_assert (visible_page == page2); -} - -static void test_pm_remove_page_by_name (PageManagerFixture *fixture, gconstpointer unused) { @@ -581,138 +283,9 @@ test_pm_remove_page_by_name (PageManagerFixture *fixture, g_list_free (pages); } -static void -test_pm_duplicate_page_name (PageManagerFixture *fixture, - gconstpointer unused) -{ - eos_page_manager_set_page_name (EOS_PAGE_MANAGER (fixture->pm), - fixture->page1, - DUPLICATE_PAGE_NAME); - /* Should not complain */ - eos_page_manager_set_page_name (EOS_PAGE_MANAGER (fixture->pm), - fixture->page1, - DUPLICATE_PAGE_NAME); - - g_test_expect_message (TEST_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, - EXPECTED_DUPLICATE_PAGE_NAME_ERRMSG); - eos_page_manager_set_page_name (EOS_PAGE_MANAGER (fixture->pm), - fixture->page2, - DUPLICATE_PAGE_NAME); - g_test_assert_expected_messages (); - - const gchar *name = eos_page_manager_get_page_name (EOS_PAGE_MANAGER (fixture->pm), - fixture->page2); - g_assert_cmpstr (name, !=, DUPLICATE_PAGE_NAME); -} - -static void -test_pm_prop_transition_duration (PageManagerFixture *fixture, - gconstpointer unused) -{ - guint duration; - g_object_get (fixture->pm, "transition-duration", &duration, NULL); - g_assert (duration == DURATION_DEFAULT); - g_object_set (fixture->pm, "transition-duration", DURATION_2, NULL); - g_object_get (fixture->pm, "transition-duration", &duration, NULL); - g_assert (duration == DURATION_2); -} - -static void -test_pm_get_set_transition_duration (PageManagerFixture *fixture, - gconstpointer unused) -{ - g_assert (DURATION_DEFAULT == eos_page_manager_get_transition_duration (EOS_PAGE_MANAGER (fixture->pm))); - eos_page_manager_set_transition_duration (EOS_PAGE_MANAGER (fixture->pm), DURATION_1); - g_assert (DURATION_1 == eos_page_manager_get_transition_duration (EOS_PAGE_MANAGER (fixture->pm))); - eos_page_manager_set_transition_duration (EOS_PAGE_MANAGER (fixture->pm), DURATION_2); - g_assert (DURATION_2 == eos_page_manager_get_transition_duration (EOS_PAGE_MANAGER (fixture->pm))); -} - -static void -test_pm_prop_transition_type (PageManagerFixture *fixture, - gconstpointer unused) -{ - EosPageManagerTransitionType type; - g_object_get (fixture->pm, "transition-type", &type, NULL); - g_assert (type == EOS_PAGE_MANAGER_TRANSITION_TYPE_NONE); - g_object_set (fixture->pm, "transition-type", EOS_PAGE_MANAGER_TRANSITION_TYPE_CROSSFADE, NULL); - g_object_get (fixture->pm, "transition-type", &type, NULL); - g_assert (type == EOS_PAGE_MANAGER_TRANSITION_TYPE_CROSSFADE); -} - -static void -test_pm_get_set_transition_type (PageManagerFixture *fixture, - gconstpointer unused) -{ - g_assert (EOS_PAGE_MANAGER_TRANSITION_TYPE_NONE == eos_page_manager_get_transition_type (EOS_PAGE_MANAGER (fixture->pm))); - eos_page_manager_set_transition_type (EOS_PAGE_MANAGER (fixture->pm), EOS_PAGE_MANAGER_TRANSITION_TYPE_CROSSFADE); - g_assert (EOS_PAGE_MANAGER_TRANSITION_TYPE_CROSSFADE == eos_page_manager_get_transition_type (EOS_PAGE_MANAGER (fixture->pm))); -} - -static void -test_empty_pm_visible_page (PageManagerFixture *fixture, - gconstpointer unused) -{ - GtkWidget *visible_page_get, *visible_page_prop; - visible_page_get = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->pm)); - g_assert (visible_page_get == NULL); - g_object_get (fixture->pm, "visible-page", &visible_page_prop, NULL); - g_assert (visible_page_prop == NULL); -} - -static void -test_empty_pm_visible_page_name (PageManagerFixture *fixture, - gconstpointer unused) -{ - const gchar *name_get; - gchar *name_prop; - name_get = eos_page_manager_get_visible_page_name (EOS_PAGE_MANAGER (fixture->pm)); - g_assert (name_get == NULL); - g_object_get (fixture->pm, "visible-page-name", &name_prop, NULL); - g_assert (name_prop == NULL); -} - -static void -test_empty_pm_add_page_behavior (PageManagerFixture *fixture, - gconstpointer unused) -{ - GtkWidget *visible_page; - GtkWidget *page1 = gtk_label_new ("page1"); - GtkWidget *page2 = gtk_label_new ("page2"); - gtk_container_add (GTK_CONTAINER (fixture->pm), page1); - visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->pm)); - g_assert (visible_page == page1); - gtk_container_add (GTK_CONTAINER (fixture->pm), page2); - visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->pm)); - g_assert (visible_page == page1); /* Not page2! */ -} - void add_page_manager_tests (void) { - ADD_PAGE_MANAGER_TEST ("/page-manager/get-set-visible-page", - test_pm_get_set_visible_page); - ADD_PAGE_MANAGER_TEST ("/page-manager/prop-visible-page", - test_pm_prop_visible_page); - ADD_PAGE_MANAGER_TEST ("/page-manager/get-set-visible-page-name", - test_pm_get_set_visible_page_name); - ADD_PAGE_MANAGER_TEST ("/page-manager/prop-visible-page-name", - test_pm_prop_visible_page_name); - ADD_PAGE_MANAGER_TEST ("/page-manager/get-set-page-name", - test_pm_get_set_page_name); - ADD_PAGE_MANAGER_TEST ("/page-manager/child-prop-name", - test_pm_child_prop_name); - ADD_PAGE_MANAGER_TEST ("/page-manager/get-set-page-actions", - test_pm_get_set_page_actions); - ADD_PAGE_MANAGER_TEST ("/page-manager/child-prop-page-actions", - test_pm_child_prop_page_actions); - ADD_PAGE_MANAGER_TEST ("/page-manager/get-set-page-custom-toolbox", - test_pm_get_set_page_custom_toolbox); - ADD_PAGE_MANAGER_TEST ("/page-manager/child-prop-custom-toolbox", - test_pm_child_prop_custom_toolbox); - ADD_PAGE_MANAGER_TEST ("/page-manager/page-no-name", test_pm_page_no_name); - ADD_PAGE_MANAGER_TEST ("/page-manager/set-page-no-name", - test_pm_set_page_no_name); ADD_PAGE_MANAGER_TEST_WITH_ARGS ("/page-manager/child-prop-background-uri", test_pm_child_prop_string, "background-uri"); @@ -740,30 +313,4 @@ add_page_manager_tests (void) test_pm_child_prop_background_repeats); ADD_PAGE_MANAGER_TEST ("/page-manager/remove-page-by-name", test_pm_remove_page_by_name); - ADD_PAGE_MANAGER_TEST ("/page-manager/duplicate-page-name", - test_pm_duplicate_page_name); - ADD_PAGE_MANAGER_TEST ("/page-manager/prop-transition-duration", - test_pm_prop_transition_duration); - ADD_PAGE_MANAGER_TEST ("/page-manager/get-set-transition-duration", - test_pm_get_set_transition_duration); - ADD_PAGE_MANAGER_TEST ("/page-manager/prop-transition-type", - test_pm_prop_transition_type); - ADD_PAGE_MANAGER_TEST ("/page-manager/get-set-transition-type", - test_pm_get_set_transition_type); - ADD_EMPTY_PAGE_MANAGER_TEST ("/page-manager/empty-visible-page", - test_empty_pm_visible_page); - ADD_EMPTY_PAGE_MANAGER_TEST ("/page-manager/empty-visible-page-name", - test_empty_pm_visible_page_name); - ADD_EMPTY_PAGE_MANAGER_TEST ("/page-manager/add-page-behavior", - test_empty_pm_add_page_behavior); - - /* Disabled until https://bugzilla.gnome.org/show_bug.cgi?id=699756 is fixed - [endlessm/eos-sdk#67] */ - if (FALSE) - { - ADD_PAGE_MANAGER_TEST ("/page-manager/remove-page-behavior", - test_pm_remove_page_behavior); - ADD_EMPTY_PAGE_MANAGER_TEST ("/page-manager/remove-page-undefined-behavior", - test_pm_remove_page_undefined_behavior); - } } diff --git a/test/endless/test-splash-page-manager.c b/test/endless/test-splash-page-manager.c deleted file mode 100644 index 06105aa..0000000 --- a/test/endless/test-splash-page-manager.c +++ /dev/null @@ -1,181 +0,0 @@ -#include <gtk/gtk.h> -#include <endless/endless.h> - -#include "run-tests.h" - -#define ADD_SPLASH_PAGE_MANAGER_TEST(path, test_func) \ - g_test_add ((path), SplashPageManagerFixture, NULL, \ - spm_fixture_setup, (test_func), spm_fixture_teardown) -#define ADD_EMPTY_SPLASH_PAGE_MANAGER_TEST(path, test_func) \ - g_test_add ((path), SplashPageManagerFixture, NULL, \ - empty_spm_fixture_setup, (test_func), spm_fixture_teardown); - -typedef struct -{ - GtkWidget *spm; - GtkWidget *first_splash_page; - GtkWidget *second_splash_page; - GtkWidget *first_main_page; - GtkWidget *second_main_page; -} SplashPageManagerFixture; - -static void -empty_spm_fixture_setup (SplashPageManagerFixture *fixture, - gconstpointer unused) -{ - fixture->first_splash_page = gtk_label_new ("splash"); - fixture->second_splash_page = gtk_label_new ("ham sandwich"); - fixture->first_main_page = gtk_label_new ("main"); - fixture->second_main_page = gtk_label_new ("pikachu"); - fixture->spm = eos_splash_page_manager_new (); -} - -static void -spm_fixture_setup (SplashPageManagerFixture *fixture, - gconstpointer unused) -{ - empty_spm_fixture_setup (fixture, unused); - eos_splash_page_manager_set_splash_page (EOS_SPLASH_PAGE_MANAGER (fixture->spm), - fixture->first_splash_page); - eos_splash_page_manager_set_main_page (EOS_SPLASH_PAGE_MANAGER (fixture->spm), - fixture->first_main_page); -} - -static void -spm_fixture_teardown (SplashPageManagerFixture *fixture, - gconstpointer unused) -{ - gtk_widget_destroy (fixture->spm); -} - -static void -test_spm_get_set_splash_page (SplashPageManagerFixture *fixture, - gconstpointer unused) -{ - GtkWidget *splash_page; - splash_page = eos_splash_page_manager_get_splash_page (EOS_SPLASH_PAGE_MANAGER (fixture->spm)); - g_assert (splash_page != fixture->second_splash_page); - eos_splash_page_manager_set_splash_page (EOS_SPLASH_PAGE_MANAGER (fixture->spm), - fixture->second_splash_page); - splash_page = eos_splash_page_manager_get_splash_page (EOS_SPLASH_PAGE_MANAGER (fixture->spm)); - g_assert (splash_page == fixture->second_splash_page); -} - -static void -test_spm_prop_splash_page (SplashPageManagerFixture *fixture, - gconstpointer unused) -{ - GtkWidget *splash_page; - g_object_get (fixture->spm, "splash-page", &splash_page, NULL); - g_assert (splash_page != fixture->second_splash_page); - g_object_set (fixture->spm, "splash-page", fixture->second_splash_page, NULL); - g_object_get (fixture->spm, "splash-page", &splash_page, NULL); - g_assert (splash_page == fixture->second_splash_page); -} - -static void -test_spm_get_set_main_page (SplashPageManagerFixture *fixture, - gconstpointer unused) -{ - GtkWidget *main_page; - main_page = eos_splash_page_manager_get_main_page (EOS_SPLASH_PAGE_MANAGER (fixture->spm)); - g_assert (main_page != fixture->second_main_page); - eos_splash_page_manager_set_main_page (EOS_SPLASH_PAGE_MANAGER (fixture->spm), - fixture->second_main_page); - main_page = eos_splash_page_manager_get_main_page (EOS_SPLASH_PAGE_MANAGER (fixture->spm)); - g_assert (main_page == fixture->second_main_page); -} - -static void -test_spm_prop_main_page (SplashPageManagerFixture *fixture, - gconstpointer unused) -{ - GtkWidget *main_page; - g_object_get (fixture->spm, "main-page", &main_page, NULL); - g_assert (main_page != fixture->second_main_page); - g_object_set (fixture->spm, "main-page", fixture->second_main_page, NULL); - g_object_get (fixture->spm, "main-page", &main_page, NULL); - g_assert (main_page == fixture->second_main_page); -} - -static void -test_spm_show_main_page (SplashPageManagerFixture *fixture, - gconstpointer unused) -{ - GtkWidget *visible_page; - visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->spm)); - g_assert (visible_page != fixture->first_main_page); - eos_splash_page_manager_show_main_page (EOS_SPLASH_PAGE_MANAGER (fixture->spm)); - visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->spm)); - g_assert (visible_page == fixture->first_main_page); -} - - -static void -test_spm_show_splash_page (SplashPageManagerFixture *fixture, - gconstpointer unused) -{ - GtkWidget *visible_page; - visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->spm)); - g_assert (visible_page == fixture->first_splash_page); - eos_splash_page_manager_show_main_page (EOS_SPLASH_PAGE_MANAGER (fixture->spm)); - visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->spm)); - g_assert (visible_page != fixture->first_splash_page); - eos_splash_page_manager_show_splash_page (EOS_SPLASH_PAGE_MANAGER (fixture->spm)); - visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->spm)); - g_assert (visible_page == fixture->first_splash_page); -} - -static void -test_spm_default_visible_splash (SplashPageManagerFixture *fixture, - gconstpointer unused) -{ - // Even though main page is added first splash page should be visible after it is added. - GtkWidget *visible_page; - eos_splash_page_manager_set_main_page (EOS_SPLASH_PAGE_MANAGER (fixture->spm), - fixture->first_main_page); - eos_splash_page_manager_set_splash_page (EOS_SPLASH_PAGE_MANAGER (fixture->spm), - fixture->first_splash_page); - visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->spm)); - g_assert (visible_page == fixture->first_splash_page); -} - -static void -test_spm_add_to_splash (SplashPageManagerFixture *fixture, - gconstpointer unused) -{ - // Right now container add sets the splash page by default. This tests that - // functionality. - GtkWidget *splash_page; - gtk_container_add (GTK_CONTAINER (fixture->spm), - fixture->first_splash_page); - splash_page = eos_splash_page_manager_get_splash_page (EOS_SPLASH_PAGE_MANAGER (fixture->spm)); - g_assert (splash_page == fixture->first_splash_page); -} - -void -add_splash_page_manager_tests (void) -{ - ADD_SPLASH_PAGE_MANAGER_TEST ("/splash-page-manager/show-main-page", - test_spm_show_main_page); - ADD_SPLASH_PAGE_MANAGER_TEST ("/splash-page-manager/show-splash-page", - test_spm_show_splash_page); - ADD_EMPTY_SPLASH_PAGE_MANAGER_TEST ("/splash-page-manager/default-visible-splash", - test_spm_default_visible_splash); - ADD_EMPTY_SPLASH_PAGE_MANAGER_TEST ("/splash-page-manager/add-to-splash", - test_spm_add_to_splash); - - /* Disabled until https://bugzilla.gnome.org/show_bug.cgi?id=699756 is fixed - [endlessm/eos-sdk#67] */ - if (FALSE) - { - ADD_SPLASH_PAGE_MANAGER_TEST ("/splash-page-manager/get-set-splash-page", - test_spm_get_set_splash_page); - ADD_SPLASH_PAGE_MANAGER_TEST ("/splash-page-manager/prop-splash-page", - test_spm_prop_splash_page); - ADD_SPLASH_PAGE_MANAGER_TEST ("/splash-page-manager/get-set-main-page", - test_spm_get_set_main_page); - ADD_SPLASH_PAGE_MANAGER_TEST ("/splash-page-manager/prop-main-page", - test_spm_prop_main_page); - } -} diff --git a/test/endless/test-window.c b/test/endless/test-window.c index 3e648d3..a6fc28a 100644 --- a/test/endless/test-window.c +++ b/test/endless/test-window.c @@ -4,7 +4,6 @@ #include <gtk/gtk.h> #include <endless/endless.h> #include "endless/eostopbar-private.h" -#include "endless/eosmainarea-private.h" #include "run-tests.h" @@ -53,17 +52,6 @@ test_has_top_bar (GApplication *app) } static void -test_has_main_area (GApplication *app) -{ - GtkWidget *win = eos_window_new (EOS_APPLICATION (app)); - GtkWidget *main_area = container_find_descendant_with_type (GTK_CONTAINER (win), EOS_TYPE_MAIN_AREA); - g_assert (main_area != NULL); - g_assert (EOS_IS_MAIN_AREA (main_area)); - - gtk_widget_destroy (win); -} - -static void test_has_default_page_manager (GApplication *app) { GtkWidget *win = eos_window_new (EOS_APPLICATION (app)); @@ -169,64 +157,6 @@ test_prop_page_manager (GApplication *app) } static void -test_main_area_widgets_visibility (GApplication *app) -{ - GtkWidget *win = eos_window_new (EOS_APPLICATION (app)); - EosPageManager *pm = eos_window_get_page_manager (EOS_WINDOW (win)); - GtkWidget *main_area = container_find_descendant_with_type (GTK_CONTAINER (win), EOS_TYPE_MAIN_AREA); - - GtkWidget *page0 = gtk_label_new ("no-no"); - GtkWidget *page1 = gtk_label_new ("yes-no"); - GtkWidget *page2 = gtk_label_new ("no-yes"); - GtkWidget *page3 = gtk_label_new ("yes-yes"); - - GtkWidget *toolbox1 = gtk_label_new ("toolbox1"); - GtkWidget *toolbox3 = gtk_label_new ("toolbox3"); - - gtk_container_add (GTK_CONTAINER (pm), page0); - gtk_container_add_with_properties (GTK_CONTAINER (pm), page1, - "custom-toolbox-widget", toolbox1, - NULL); - gtk_container_add_with_properties (GTK_CONTAINER (pm), page2, - "page-actions", TRUE, - NULL); - gtk_container_add_with_properties (GTK_CONTAINER (pm), page3, - "custom-toolbox-widget", toolbox3, - "page-actions", TRUE, - NULL); - - GtkWidget *tb; - gboolean actions; - EosMainArea *ma = EOS_MAIN_AREA (main_area); - - eos_page_manager_set_visible_page (pm, page0); - tb = eos_main_area_get_toolbox (ma); - actions = eos_main_area_get_actions (ma); - g_assert (tb == NULL); - g_assert (actions == FALSE); - - eos_page_manager_set_visible_page (pm, page1); - tb = eos_main_area_get_toolbox (ma); - actions = eos_main_area_get_actions (ma); - g_assert (tb == toolbox1); - g_assert (actions == FALSE); - - eos_page_manager_set_visible_page (pm, page2); - tb = eos_main_area_get_toolbox (ma); - actions = eos_main_area_get_actions (ma); - g_assert (tb == NULL); - g_assert (actions == TRUE); - - eos_page_manager_set_visible_page (pm, page3); - tb = eos_main_area_get_toolbox (ma); - actions = eos_main_area_get_actions (ma); - g_assert (tb == toolbox3); - g_assert (actions == TRUE); - - gtk_widget_destroy (win); -} - -static void test_internal_widget_visibility (GApplication *app) { GtkWidget *win = eos_window_new (EOS_APPLICATION (app)); EosPageManager *pm = eos_window_get_page_manager (EOS_WINDOW (win)); @@ -252,7 +182,6 @@ add_window_tests (void) ADD_APP_WINDOW_TEST ("/window/application-not-null", test_application_not_null); ADD_APP_WINDOW_TEST ("/window/has-top-bar", test_has_top_bar); - ADD_APP_WINDOW_TEST ("/window/has-main-area", test_has_main_area); ADD_APP_WINDOW_TEST ("/window/has-default-page-manager", test_has_default_page_manager); ADD_APP_WINDOW_TEST ("/window/get-set-page-manager", @@ -266,8 +195,6 @@ add_window_tests (void) ADD_APP_WINDOW_TEST ("/window/get-set-font-scaling-min-font-size", test_get_set_font_scaling_min_font_size); ADD_APP_WINDOW_TEST ("/window/prop-page-manager", test_prop_page_manager); - ADD_APP_WINDOW_TEST ("/window/main-area-widgets-visibility", - test_main_area_widgets_visibility); ADD_APP_WINDOW_TEST ("/window/internal-widget-visibility", test_internal_widget_visibility); } diff --git a/test/smoke-tests/action-buttons.js b/test/smoke-tests/action-buttons.js deleted file mode 100644 index 476912a..0000000 --- a/test/smoke-tests/action-buttons.js +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright 2013 Endless Mobile, Inc. - -const Lang = imports.lang; -const Endless = imports.gi.Endless; -const Gtk = imports.gi.Gtk; - -const TEST_APPLICATION_ID = 'com.endlessm.example.test-action-buttons'; - -const TestApplication = new Lang.Class ({ - Name: 'TestApplication', - Extends: Endless.Application, - - vfunc_startup: function() { - this.parent(); - - this._page = new Gtk.Grid (); - - this._content = new Gtk.Grid ({ - hexpand: true, - halign: Gtk.Align.CENTER, - vexpand: true, - valign: Gtk.Align.CENTER}); - - this._darkSwitch = new Gtk.Switch ({active: false}); - this._darkSwitch.connect ('notify::active', Lang.bind (this, function (active) { - if (this._darkSwitch.get_active()) { - this._menu.get_style_context().add_class('dark'); - } else { - this._menu.get_style_context().remove_class('dark'); - } - })); - this._content.attach(new Gtk.Label ({label: 'Dark action menu'}), 0, 0, 1, 1); - this._content.attach(this._darkSwitch, 1, 0, 1, 1); - - this._content.attach (new Endless.ActionButton({ - name: 'LEFT', - 'icon-id': 'object-select-symbolic', - label: 'LEFT', - 'label-position': Gtk.PositionType.LEFT - }), 0, 1, 1, 1); - this._content.attach (new Endless.ActionButton({ - name: 'TOP', - 'icon-id': 'object-select-symbolic', - label: 'TOP', - 'label-position': Gtk.PositionType.TOP - }), 1, 1, 1, 1); - this._content.attach (new Endless.ActionButton({ - name: 'BOTTOM', - 'icon-id': 'object-select-symbolic', - label: 'BOTTOM', - 'label-position': Gtk.PositionType.BOTTOM - }), 0, 2, 1, 1); - this._content.attach (new Endless.ActionButton({ - name: 'RIGHT', - 'icon-id': 'object-select-symbolic', - label: 'RIGHT', - 'label-position': Gtk.PositionType.RIGHT - }), 1, 2, 1, 1); - - this._menu = new Endless.ActionMenu ({name: 'menu'}); - - // the ActionMenu takes 1/6 of the width - this._page.set_column_homogeneous (true); - this._page.attach (this._content, 0, 0, 5, 1); - this._page.attach (this._menu, 5, 0, 1, 1); - - this._menu.add_action ({ - name: 'select', - 'icon-name': 'object-select-symbolic', - label: 'SELECT', - 'is-important': true }, - Lang.bind(this, function () { - var md = new Gtk.MessageDialog({modal:true, title:"Information", - message_type:Gtk.MessageType.INFO, - buttons:Gtk.ButtonsType.OK, text:"Select button pressed!"}); - md.run(); - md.destroy(); - })); - - this._menu.add_action ({ - name: 'delete', - 'icon-name': 'edit-delete-symbolic', - label: 'DELETE', - 'is-important': false, - 'stock-id': Gtk.STOCK_DELETE }); - - this._menu.add_action ({ - name: 'smile', - 'icon-name': 'face-smile-symbolic', - label: 'SMILE', - 'is-important': false }); - - this._menu.add_action ({ - name: 'sadface', - 'icon-name': 'face-sad-symbolic', - label: 'SAD FACE', - 'is-important': false }); - - this._pm = new Endless.PageManager(); - this._pm.add(this._page, { name: "page" }); - - let provider = new Gtk.CssProvider (); - provider.load_from_path ('./test/smoke-tests/eosactionbutton.css'); - - this._window = new Endless.Window({ - application: this, - border_width: 1, - page_manager: this._pm - }); - - let context = new Gtk.StyleContext(); - context.add_provider_for_screen(this._window.get_screen(), - provider, - Gtk.STYLE_PROVIDER_PRIORITY_USER); - - this._window.show_all(); - }, - - _onButtonClicked: function () { - this._window.destroy(); - }, -}); - -let app = new TestApplication({ application_id: TEST_APPLICATION_ID, - flags: 0 }); -app.run(ARGV); diff --git a/test/smoke-tests/app-window.js b/test/smoke-tests/app-window.js index d7554b9..bbfd461 100644 --- a/test/smoke-tests/app-window.js +++ b/test/smoke-tests/app-window.js @@ -32,12 +32,12 @@ const Page0 = new Lang.Class ({ // Combo box for transition type... let typeMenu = new Gtk.ComboBoxText(); let type_options = { - "Transition type: None": Endless.PageManagerTransitionType.NONE, - "Transition type: Fade": Endless.PageManagerTransitionType.CROSSFADE, - "Transition type: Slide Right": Endless.PageManagerTransitionType.SLIDE_RIGHT, - "Transition type: Slide Left": Endless.PageManagerTransitionType.SLIDE_LEFT, - "Transition type: Slide Down": Endless.PageManagerTransitionType.SLIDE_DOWN, - "Transition type: Slide Up": Endless.PageManagerTransitionType.SLIDE_UP + "Transition type: None": Gtk.StackTransitionType.NONE, + "Transition type: Fade": Gtk.StackTransitionType.CROSSFADE, + "Transition type: Slide Right": Gtk.StackTransitionType.SLIDE_RIGHT, + "Transition type: Slide Left": Gtk.StackTransitionType.SLIDE_LEFT, + "Transition type: Slide Down": Gtk.StackTransitionType.SLIDE_DOWN, + "Transition type: Slide Up": Gtk.StackTransitionType.SLIDE_UP } for (let key in type_options) { typeMenu.append_text(key); @@ -90,33 +90,6 @@ const Page1 = new Lang.Class ({ } }); -const Toolbox = new Lang.Class ({ - Name: 'Toolbox', - Extends: Gtk.Grid, - - _init: function(props) { - props = props || {}; - props.orientation = Gtk.Orientation.VERTICAL; - this.parent(props); - - this._label = new Gtk.Label({ label: 'The Toolbox' }); - this._label1 = new Gtk.Label({ label: 'Actions on page 0' }); - this._label2 = new Gtk.Label({ label: 'Actions on page 1' }); - this.switch1 = new Gtk.Switch({ active: false }); - this.switch2 = new Gtk.Switch({ active: true }); - this.button1 = new Gtk.Button({ label: 'Scale font down' }); - this.button2 = new Gtk.Button({ label: 'Scale font up' }); - - this.add(this._label); - this.add(this._label1); - this.add(this.switch1); - this.add(this._label2); - this.add(this.switch2); - this.add(this.button1); - this.add(this.button2); - } -}); - const LeftTopbar = new Lang.Class ({ Name: 'LeftTopBar', Extends: Gtk.Grid, @@ -159,19 +132,19 @@ const TestApplication = new Lang.Class ({ // First page this._page0 = new Page0(this._pm); this._page0.button1.connect('clicked', Lang.bind(this, function () { - this._pm.visible_page = this._page1; + this._pm.visible_child = this._page1; })); this._page0.button2.connect('clicked', Lang.bind(this, function () { - this._pm.visible_page_name = "page1"; + this._pm.visible_child_name = "page1"; })); // Second page this._page1 = new Page1(); this._page1.button1.connect('clicked', Lang.bind(this, function () { - this._pm.visible_page = this._page0; + this._pm.visible_child = this._page0; })); this._page1.button2.connect('clicked', Lang.bind(this, function () { - this._pm.visible_page_name = "page0"; + this._pm.visible_child_name = "page0"; })); this._page1.button3.connect('clicked', Lang.bind(this, function () { this._setupDogBackground(this._page1); @@ -183,17 +156,6 @@ const TestApplication = new Lang.Class ({ this._setupCatBackground(this._page1); })); - - this._toolbox = new Toolbox(); - this._toolbox.switch1.connect('notify::active', Lang.bind(this, function () { - this._pm.set_page_actions(this._page0, - this._toolbox.switch1.active); - })); - this._toolbox.switch2.connect('notify::active', Lang.bind(this, function () { - this._pm.set_page_actions(this._page1, - this._toolbox.switch2.active); - })); - this._left_topbar = new LeftTopbar(); this._center_topbar = new CenterTopbar(); @@ -201,17 +163,14 @@ const TestApplication = new Lang.Class ({ this._pm.add(this._page0, { name: "page0", background_uri: CAT_BACKGROUND_PATH, - custom_toolbox_widget: this._toolbox, left_topbar_widget: this._left_topbar, center_topbar_widget: this._center_topbar }); this._pm.add(this._page1, { name: "page1", - custom_toolbox_widget: this._toolbox, left_topbar_widget: this._left_topbar, - center_topbar_widget: this._center_topbar, - page_actions: true + center_topbar_widget: this._center_topbar }); this._setupDogBackground(this._page0); @@ -224,15 +183,6 @@ const TestApplication = new Lang.Class ({ 'font-scaling-default-size': 16 }); - this._toolbox.button1.connect('clicked', Lang.bind(this, function () { - let current_font_size = this._window.get_font_scaling_default_size(); - this._window.set_font_scaling_default_size(current_font_size - 1); - })); - this._toolbox.button2.connect('clicked', Lang.bind(this, function () { - let current_font_size = this._window.get_font_scaling_default_size(); - this._window.set_font_scaling_default_size(current_font_size + 1); - })); - let provider = new Gtk.CssProvider(); provider.load_from_data("EosWindow { font-size: 1em; }"); Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), provider, diff --git a/test/smoke-tests/splash-page.js b/test/smoke-tests/splash-page.js deleted file mode 100644 index ff52a9f..0000000 --- a/test/smoke-tests/splash-page.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2013 Endless Mobile, Inc. - -const Lang = imports.lang; -const Endless = imports.gi.Endless; -const Gtk = imports.gi.Gtk; - -const TEST_APPLICATION_ID = 'com.endlessm.example.test'; - -const TestApplication = new Lang.Class ({ - Name: 'TestApplication', - Extends: Endless.Application, - - vfunc_startup: function() { - this.parent(); - - // First page - this._splash_page = new Gtk.Grid({ orientation: Gtk.Orientation.VERTICAL }); - let splash_label = new Gtk.Label({ label: 'The Splash Page' }); - this._splash_page.add(splash_label); - let splash_button = new Gtk.Button({ label: 'Show main page' }); - splash_button.connect('clicked', Lang.bind(this, function () { - this._pm.show_main_page(); - })); - this._splash_page.add(splash_button); - - // Second page - this._main_page = new Gtk.Grid({ orientation: Gtk.Orientation.HORIZONTAL }); - let main_label = new Gtk.Label({ label: 'The Main Page' }); - this._main_page.add(main_label); - let main_button = new Gtk.Button({ label: 'Go back to splash page' }); - main_button.connect('clicked', Lang.bind(this, function () { - this._pm.show_splash_page(); - })); - this._main_page.add(main_button); - - this._pm = new Endless.SplashPageManager(); - this._pm.set_splash_page(this._splash_page); - this._pm.set_main_page(this._main_page); - - this._window = new Endless.Window({ - application: this, - border_width: 16, - page_manager: this._pm - }); - this._window.show_all(); - }, - - _onButtonClicked: function () { - this._window.destroy(); - }, -}); - -let app = new TestApplication({ application_id: TEST_APPLICATION_ID, - flags: 0 }); -app.run(ARGV); diff --git a/test/smoke-tests/webhelper/webview.js b/test/smoke-tests/webhelper/webview.js index a3b91e5..a1dba65 100644 --- a/test/smoke-tests/webhelper/webview.js +++ b/test/smoke-tests/webhelper/webview.js @@ -64,7 +64,7 @@ const TestApplication = new Lang.Class({ /* dict['name'] is the name of the page to move to */ moveToPage: function(dict) { - this._pm.visible_page_name = dict['name']; + this._pm.visible_child_name = dict['name']; }, /* dict['msg'] is the message to display */ @@ -134,7 +134,7 @@ const TestApplication = new Lang.Class({ this._page2 = new Gtk.Grid(); let back_button = new Gtk.Button({ label:"Go back to page 1" }); back_button.connect('clicked', Lang.bind(this, function() { - this._pm.visible_page_name = 'page1'; + this._pm.visible_child_name = 'page1'; })); this._page2.add(back_button); @@ -144,10 +144,10 @@ const TestApplication = new Lang.Class({ }); this._pm = this._window.page_manager; - this._pm.set_transition_type(Endless.PageManagerTransitionType.CROSSFADE); + this._pm.set_transition_type(Gtk.StackTransitionType.CROSSFADE); this._pm.add(this._page1, { name: 'page1' }); this._pm.add(this._page2, { name: 'page2' }); - this._pm.visible_page = this._page1; + this._pm.visible_child = this._page1; this._window.show_all(); } diff --git a/wikipedia/views/domain_wiki_view.js b/wikipedia/views/domain_wiki_view.js index a2f7419..06a936d 100644 --- a/wikipedia/views/domain_wiki_view.js +++ b/wikipedia/views/domain_wiki_view.js @@ -196,10 +196,10 @@ const DomainWikiView = new Lang.Class({ * Transition to the front page of the view */ show_front_page: function () { - if (this._window.page_manager.visible_page_name === "front") + if (this._window.page_manager.visible_child_name === "front") return; - this._window.page_manager.transition_type = Endless.PageManagerTransitionType.SLIDE_RIGHT; - this._window.page_manager.visible_page_name = "front"; + this._window.page_manager.transition_type = Gtk.StackTransitionType.SLIDE_RIGHT; + this._window.page_manager.visible_child_name = "front"; }, /** @@ -207,14 +207,14 @@ const DomainWikiView = new Lang.Class({ * Transition to the category page of the view */ show_category_page: function () { - if (this._window.page_manager.visible_page_name === "category") + if (this._window.page_manager.visible_child_name === "category") return; this._category_article_list.scrollToTop(); - if (this._window.page_manager.visible_page_name === "front") - this._window.page_manager.transition_type = Endless.PageManagerTransitionType.SLIDE_LEFT; + if (this._window.page_manager.visible_child_name === "front") + this._window.page_manager.transition_type = Gtk.StackTransitionType.SLIDE_LEFT; else - this._window.page_manager.transition_type = Endless.PageManagerTransitionType.SLIDE_RIGHT; - this._window.page_manager.visible_page_name = "category"; + this._window.page_manager.transition_type = Gtk.StackTransitionType.SLIDE_RIGHT; + this._window.page_manager.visible_child_name = "category"; }, /** @@ -222,11 +222,11 @@ const DomainWikiView = new Lang.Class({ * Transition to the article page of the view */ show_article_page: function () { - if (this._window.page_manager.visible_page_name === "article") + if (this._window.page_manager.visible_child_name === "article") return; this._article_list.scrollToTop(); - this._window.page_manager.transition_type = Endless.PageManagerTransitionType.SLIDE_LEFT; - this._window.page_manager.visible_page_name = "article"; + this._window.page_manager.transition_type = Gtk.StackTransitionType.SLIDE_LEFT; + this._window.page_manager.visible_child_name = "article"; }, set_categories: function(categories){ |