[anjuta] sourceview: use GtkRevealer for sliding in the message area
- From: Carl-Anton Ingmarsson <carlantoni src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] sourceview: use GtkRevealer for sliding in the message area
- Date: Sat, 15 Jun 2013 06:11:52 +0000 (UTC)
commit 516ca8916f7da88ec8a9482e9ff6b77abc25c500
Author: Carl-Anton Ingmarsson <ca ingmarsson gmail com>
Date: Fri Jun 14 23:04:32 2013 +0200
sourceview: use GtkRevealer for sliding in the message area
If we have gtk+ version >= 3.9.0
plugins/sourceview/sourceview.c | 57 ++++++++++++++++++++++++++++----------
1 files changed, 42 insertions(+), 15 deletions(-)
---
diff --git a/plugins/sourceview/sourceview.c b/plugins/sourceview/sourceview.c
index 1f365c8..33024c4 100644
--- a/plugins/sourceview/sourceview.c
+++ b/plugins/sourceview/sourceview.c
@@ -265,28 +265,55 @@ goto_line (Sourceview* sv, gint line)
static void
on_destroy_message_area (Sourceview* sv, GObject *finalized_object)
{
- sv->priv->message_area = NULL;
+ if ((void*)finalized_object == (void*)sv->priv->message_area)
+ sv->priv->message_area = NULL;
+
g_signal_emit_by_name (G_OBJECT (sv), "update-save-ui");
}
static void
-sourceview_set_message_area (Sourceview* sv, GtkWidget *message_area)
+message_area_destroy (GtkWidget* message_area)
+{
+#if GTK_CHECK_VERSION(3, 9, 0)
+ GtkWidget* revealer;
+
+ revealer = gtk_widget_get_parent (message_area);
+ g_signal_connect (revealer, "notify::child-revealed",
+ G_CALLBACK(gtk_widget_destroy), NULL);
+ gtk_revealer_set_reveal_child (GTK_REVEALER (revealer), FALSE);
+#else
+ gtk_widget_destroy (message_area);
+#endif
+}
+
+static void
+sourceview_set_message_area (Sourceview* sv, GtkWidget *message_area)
{
if (sv->priv->message_area != NULL)
- gtk_widget_destroy (sv->priv->message_area);
+ message_area_destroy (sv->priv->message_area);
+
sv->priv->message_area = message_area;
if (sv->priv->message_area == NULL)
return;
gtk_widget_show (message_area);
- gtk_box_pack_start (GTK_BOX (sv),
- message_area,
- FALSE,
- FALSE,
- 0);
- g_object_weak_ref (G_OBJECT (sv->priv->message_area),
- (GWeakNotify)on_destroy_message_area, sv);
+
+#if GTK_CHECK_VERSION(3, 9, 0)
+ GtkWidget *revealer;
+
+ revealer = gtk_revealer_new ();
+ gtk_widget_show (revealer);
+ gtk_container_add (GTK_CONTAINER (revealer), message_area);
+ gtk_box_pack_start (GTK_BOX (sv), revealer, FALSE, FALSE, 0);
+
+ gtk_revealer_set_reveal_child (GTK_REVEALER (revealer), TRUE);
+#else
+ gtk_box_pack_start (GTK_BOX (sv), message_area, FALSE, FALSE, 0);
+#endif
+
+ g_object_weak_ref (G_OBJECT (message_area),
+ (GWeakNotify)on_destroy_message_area, sv);
g_signal_emit_by_name (G_OBJECT (sv), "update-save-ui");
}
@@ -566,7 +593,7 @@ on_reload_dialog_response (GtkWidget *message_area, gint res, Sourceview *sv)
/* Set dirty */
gtk_text_buffer_set_modified(GTK_TEXT_BUFFER(sv->priv->document), TRUE);
}
- gtk_widget_destroy (message_area);
+ message_area_destroy (message_area);
}
static void
@@ -586,7 +613,7 @@ on_close_dialog_response (GtkWidget *message_area, gint res, Sourceview *sv)
/* Set dirty */
gtk_text_buffer_set_modified(GTK_TEXT_BUFFER(sv->priv->document), TRUE);
}
- gtk_widget_destroy (message_area);
+ message_area_destroy (message_area);
}
static gboolean
@@ -674,7 +701,7 @@ on_open_failed (SourceviewIO* io, GError* err, Sourceview* sv)
gtk_info_bar_add_button (GTK_INFO_BAR (message_area),
GTK_STOCK_OK,
GTK_RESPONSE_OK);
- g_signal_connect (message_area, "response", G_CALLBACK(gtk_widget_destroy), NULL);
+ g_signal_connect (message_area, "response", G_CALLBACK(message_area_destroy), NULL);
sourceview_set_message_area (sv, message_area);
}
@@ -701,7 +728,7 @@ on_read_only_dialog_response (GtkWidget *message_area, gint res, Sourceview *sv)
TRUE);
sv->priv->read_only = FALSE;
}
- gtk_widget_destroy (message_area);
+ message_area_destroy (message_area);
}
/* Called when document is loaded completly */
@@ -784,7 +811,7 @@ static void on_save_failed (SourceviewIO* sio, GError* err, Sourceview* sv)
gtk_info_bar_add_button (GTK_INFO_BAR (message_area),
GTK_STOCK_OK,
GTK_RESPONSE_OK);
- g_signal_connect (message_area, "response", G_CALLBACK(gtk_widget_destroy), NULL);
+ g_signal_connect (message_area, "response", G_CALLBACK(message_area_destroy), NULL);
sourceview_set_message_area (sv, message_area);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]