summaryrefslogtreecommitdiff
path: root/endless/eospagemanager.c
diff options
context:
space:
mode:
authorP. F. Chimento <philip.chimento@gmail.com>2013-05-29 04:06:04 -0700
committerP. F. Chimento <philip.chimento@gmail.com>2013-05-29 04:06:04 -0700
commitc013139ca14f93b420dbc819103367e1596c0c0e (patch)
tree29266105bbc85fb2dfb66c3b9a11843ab679d775 /endless/eospagemanager.c
parent347f7036fdf8d7c1a3db1e5bbcdacaa9b24a1132 (diff)
parent709df58d1b88ec57e975254522a09da6e7463de5 (diff)
Merge pull request #87 from endlessm/issues/59
Issues/59
Diffstat (limited to 'endless/eospagemanager.c')
-rw-r--r--endless/eospagemanager.c90
1 files changed, 85 insertions, 5 deletions
diff --git a/endless/eospagemanager.c b/endless/eospagemanager.c
index 28eaa13..3919b5b 100644
--- a/endless/eospagemanager.c
+++ b/endless/eospagemanager.c
@@ -58,14 +58,14 @@
* |[
* gtk_container_add_with_properties (GTK_CONTAINER (page_manager), page,
* "name", "front-page",
- * "background", "image.jpg",
+ * "background_uri", "image.jpg",
* NULL);
* ]|
* In Javascript, this has been simplified to use JSON:
* |[
* page_manager.add(page, {
* name: 'front-page',
- * background: 'image.jpg'
+ * background_uri: 'image.jpg'
* });
* ]|
* To remove a page, use gtk_container_remove() or
@@ -97,6 +97,7 @@ struct _EosPageManagerPageInfo
gchar *name;
gboolean fake_page_actions_visible;
GtkWidget *custom_toolbox_widget;
+ gchar *background_uri;
};
struct _EosPageManagerPrivate
@@ -122,6 +123,7 @@ enum
CHILD_PROP_NAME,
CHILD_PROP_PAGE_ACTIONS,
CHILD_PROP_CUSTOM_TOOLBOX_WIDGET,
+ CHILD_PROP_BACKGROUND_URI,
NCHILDPROPS
};
@@ -132,6 +134,7 @@ static void
page_info_free (EosPageManagerPageInfo *info)
{
g_free (info->name);
+ g_free (info->background_uri);
g_slice_free (EosPageManagerPageInfo, info);
}
@@ -399,7 +402,7 @@ eos_page_manager_add (GtkContainer *container,
/* If there were no pages yet, then this one must become the visible one */
if (self->priv->visible_page_info == NULL)
- self->priv->visible_page_info = info;
+ eos_page_manager_set_visible_page (self, new_page);
assert_internal_state (self);
}
@@ -466,6 +469,12 @@ eos_page_manager_get_child_property (GtkContainer *container,
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,
+ child));
+ break;
+
case CHILD_PROP_PAGE_ACTIONS:
g_value_set_boolean (value,
eos_page_manager_get_page_actions (self, child));
@@ -498,6 +507,11 @@ eos_page_manager_set_child_property (GtkContainer *container,
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));
+ break;
+
case CHILD_PROP_PAGE_ACTIONS:
eos_page_manager_set_page_actions (self, child,
g_value_get_boolean (value));
@@ -619,6 +633,18 @@ eos_page_manager_class_init (EosPageManagerClass *klass)
GTK_TYPE_WIDGET,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+ /**
+ * EosPageManager:background-uri:
+ *
+ * The URI for the image file for the background of this page. Setting this to
+ * %NULL indicates that the window's default background should be used.
+ */
+ eos_page_manager_child_props[CHILD_PROP_BACKGROUND_URI] =
+ g_param_spec_string ("background-uri", "Background URI",
+ "URI for background of the page",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
/* Install child properties all at once, because there is no
gtk_container_class_install_child_properties() function */
int count;
@@ -678,7 +704,7 @@ eos_page_manager_get_visible_page (EosPageManager *self)
{
g_return_val_if_fail (EOS_IS_PAGE_MANAGER (self), NULL);
- if(self->priv->visible_page_info == NULL)
+ if (self->priv->visible_page_info == NULL)
return NULL;
return self->priv->visible_page_info->page;
@@ -724,7 +750,7 @@ eos_page_manager_get_visible_page_name (EosPageManager *self)
{
g_return_val_if_fail (EOS_IS_PAGE_MANAGER (self), NULL);
- if(self->priv->visible_page_info == NULL)
+ if (self->priv->visible_page_info == NULL)
return NULL;
return self->priv->visible_page_info->name;
@@ -969,6 +995,60 @@ eos_page_manager_set_page_custom_toolbox_widget (EosPageManager *self,
}
/**
+ * eos_page_manager_get_page_background_uri:
+ * @self: the page manager
+ * @page: the page to be queried
+ *
+ * Gets the URI for the background image of @page, which must previously have
+ * been added to the page manager.
+ * See #EosPageManager:background-uri for more information.
+ *
+ * Returns: the background of @page, or the %NULL if @page does not have a
+ * background.
+ */
+const gchar *
+eos_page_manager_get_page_background_uri (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->background_uri;
+}
+
+/**
+ * eos_page_manager_set_page_background_uri:
+ * @self: the page manager
+ * @page: the page to be modified
+ * @background: (allow-none): the URI for the background image of this page.
+ *
+ * Changes the background of @page, which must previously have been added to the
+ * page manager.
+ * Setting %NULL removes the background, using the window's default background.
+ * See #EosPageManager:background-uri for more information.
+ */
+void
+eos_page_manager_set_page_background_uri (EosPageManager *self,
+ GtkWidget *page,
+ const gchar *background)
+{
+ 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 (g_strcmp0 (info->background_uri, background) == 0)
+ return;
+
+ info->background_uri = g_strdup (background);
+ gtk_container_child_notify (GTK_CONTAINER (self), page, "background-uri");
+}
+
+/**
* eos_page_manager_remove_page_by_name:
* @self: the page manager
* @name: the name of the page to remove