[nautilus-actions] Display error in status bar with a timeout
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Display error in status bar with a timeout
- Date: Sun, 11 Oct 2009 19:17:10 +0000 (UTC)
commit 3d3e6d1b0d791b206243656ae6ddb4a7a2c8d695
Author: Pierre Wieser <pwieser trychlos org>
Date: Fri Oct 9 17:21:28 2009 +0200
Display error in status bar with a timeout
ChangeLog | 4 +++
src/nact/nact-main-statusbar.c | 42 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 80f14d3..cd77164 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -21,6 +21,10 @@
(on_update_sensitivities): Disable edit actions when the focus is
not in the treeview.
+ * src/nact/nact-main-statusbar.c
+ (nact_main_statusbar_display_with_timeout):
+ Actually put a timeout to pop the status message.
+
* src/nact/nact-tree-model.c (nact_tree_model_insert):
Add debug traces.
(nact_tree_model_fill): Check validity status at load time.
diff --git a/src/nact/nact-main-statusbar.c b/src/nact/nact-main-statusbar.c
index 064ebef..eaa0ce2 100644
--- a/src/nact/nact-main-statusbar.c
+++ b/src/nact/nact-main-statusbar.c
@@ -34,7 +34,16 @@
#include "nact-main-statusbar.h"
+typedef struct {
+ guint event_source_id;
+ guint context_id;
+ GtkStatusbar *bar;
+}
+ StatusbarTimeoutDisplayStruct;
+
static GtkStatusbar *get_statusbar( const NactMainWindow *window );
+static gboolean display_timeout( StatusbarTimeoutDisplayStruct *stds );
+static void display_timeout_free( StatusbarTimeoutDisplayStruct *stds );
void
nact_main_statusbar_display_status( NactMainWindow *window, const gchar *context, const gchar *status )
@@ -53,10 +62,17 @@ nact_main_statusbar_display_status( NactMainWindow *window, const gchar *context
}
}
+/*
+ * push a message
+ * automatically pop it after a timeout
+ * the timeout is not suspended when another message is pushed onto the
+ * previous one
+ */
void
nact_main_statusbar_display_with_timeout( NactMainWindow *window, const gchar *context, const gchar *status )
{
GtkStatusbar *bar;
+ StatusbarTimeoutDisplayStruct *stds;
if( !status || !g_utf8_strlen( status, -1 )){
return;
@@ -67,6 +83,16 @@ nact_main_statusbar_display_with_timeout( NactMainWindow *window, const gchar *c
if( bar ){
guint context_id = gtk_statusbar_get_context_id( bar, context );
gtk_statusbar_push( bar, context_id, status );
+
+ stds = g_new0( StatusbarTimeoutDisplayStruct, 1 );
+ stds->context_id = context_id;
+ stds->bar = bar;
+ stds->event_source_id = g_timeout_add_seconds_full(
+ G_PRIORITY_DEFAULT,
+ 10,
+ ( GSourceFunc ) display_timeout,
+ stds,
+ ( GDestroyNotify ) display_timeout_free );
}
}
@@ -95,3 +121,19 @@ get_statusbar( const NactMainWindow *window )
return( GTK_STATUSBAR( statusbar ));
}
+
+static gboolean
+display_timeout( StatusbarTimeoutDisplayStruct *stds )
+{
+ gboolean keep_source = FALSE;
+
+ gtk_statusbar_pop( stds->bar, stds->context_id );
+
+ return( keep_source );
+}
+
+static void
+display_timeout_free( StatusbarTimeoutDisplayStruct *stds )
+{
+ g_free( stds );
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]