summaryrefslogtreecommitdiff
path: root/endless
diff options
context:
space:
mode:
authorFernando Farfan <fernando@endlessm.com>2013-06-11 20:11:54 -0700
committerFernando Farfan <fernando@endlessm.com>2013-06-17 14:19:35 -0700
commite3f2ffb6661cd01f40d96ae4bff992d0185ed0b4 (patch)
tree9fc797cc0304de38e1211bdd800b1ad483c69b3a /endless
parentf1fe5969468f8fb7955dc9f23bcd203cf2bcf4a6 (diff)
Corrected assertion failures.
Modified EosTopbar to remove a handful of assertion failures when adding left/center topbar widgets. [endlessm/eos-sdk#97]
Diffstat (limited to 'endless')
-rw-r--r--endless/eostopbar.c57
-rw-r--r--endless/eoswindow.c4
2 files changed, 42 insertions, 19 deletions
diff --git a/endless/eostopbar.c b/endless/eostopbar.c
index 63614f0..7783189 100644
--- a/endless/eostopbar.c
+++ b/endless/eostopbar.c
@@ -157,27 +157,50 @@ void
eos_top_bar_set_left_widget (EosTopBar *self,
GtkWidget *left_top_bar_widget)
{
- printf ("\n\nSetting Left Top Bar widget ...");
- self->priv->left_top_bar_widget = left_top_bar_widget;
+ g_return_if_fail (EOS_IS_TOP_BAR (self));
+ g_return_if_fail (left_top_bar_widget == NULL || GTK_IS_WIDGET (left_top_bar_widget));
- gtk_box_pack_start (GTK_BOX (self->priv->actions_hbox),
- self->priv->left_top_bar_widget,
- FALSE, FALSE, 0);
+ EosTopBarPrivate *priv = self->priv;
+ GtkWidget *self_widget = GTK_WIDGET (self);
+
+ if (priv->left_top_bar_widget == left_top_bar_widget)
+ return;
+
+ if (priv->left_top_bar_widget)
+ gtk_widget_unparent (priv->left_top_bar_widget);
+
+ priv->left_top_bar_widget = left_top_bar_widget;
+ if (left_top_bar_widget)
+ {
+ gtk_box_pack_start (GTK_BOX (priv->actions_hbox),
+ left_top_bar_widget,
+ FALSE, FALSE, 0);
+ }
}
void
eos_top_bar_set_center_widget (EosTopBar *self,
GtkWidget *center_top_bar_widget)
{
- printf ("\nSetting Center Top Bar widget ...");
- gtk_widget_set_halign (GTK_WIDGET (center_top_bar_widget), GTK_ALIGN_CENTER);
- gtk_widget_set_hexpand (GTK_WIDGET (center_top_bar_widget), TRUE);
-
- self->priv->center_top_bar_widget = center_top_bar_widget;
-
- gtk_box_pack_start (GTK_BOX (self->priv->actions_hbox),
- self->priv->center_top_bar_widget,
- FALSE, FALSE, 0);
-
- gtk_widget_show (self->priv->actions_hbox);
-}
+ g_return_if_fail (EOS_IS_TOP_BAR (self));
+ g_return_if_fail (center_top_bar_widget == NULL || GTK_IS_WIDGET (center_top_bar_widget));
+
+ EosTopBarPrivate *priv = self->priv;
+ GtkWidget *self_widget = GTK_WIDGET (self);
+
+ if (priv->center_top_bar_widget == center_top_bar_widget)
+ return;
+
+ if (priv->center_top_bar_widget)
+ gtk_widget_unparent (priv->center_top_bar_widget);
+
+ priv->center_top_bar_widget = center_top_bar_widget;
+ if (center_top_bar_widget)
+ {
+ gtk_widget_set_halign (GTK_WIDGET (center_top_bar_widget), GTK_ALIGN_CENTER);
+ gtk_widget_set_hexpand (GTK_WIDGET (center_top_bar_widget), TRUE);
+ gtk_box_pack_start (GTK_BOX (priv->actions_hbox),
+ center_top_bar_widget,
+ FALSE, FALSE, 0);
+ }
+} \ No newline at end of file
diff --git a/endless/eoswindow.c b/endless/eoswindow.c
index 37e12e9..571aebb 100644
--- a/endless/eoswindow.c
+++ b/endless/eoswindow.c
@@ -149,7 +149,7 @@ update_page_left_topbar (EosWindow *self)
if (page != NULL)
{
GtkWidget *left_topbar_widget =
- eos_page_manager_get_page_left_topbar_widget (pm, page);
+ GTK_WIDGET (eos_page_manager_get_page_left_topbar_widget (pm, page));
eos_top_bar_set_left_widget (tb, left_topbar_widget);
gtk_widget_show (self->priv->top_bar);
}
@@ -176,7 +176,7 @@ update_page_center_topbar (EosWindow *self)
if (page != NULL)
{
GtkWidget *center_topbar_widget =
- eos_page_manager_get_page_center_topbar_widget (pm, page);
+ GTK_WIDGET (eos_page_manager_get_page_center_topbar_widget (pm, page));
eos_top_bar_set_center_widget (tb, center_topbar_widget);
}
else