[bijiben] mainToolbar : make share button insensitive if note has no text
- From: Pierre-Yves Luyten <pyluyten src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bijiben] mainToolbar : make share button insensitive if note has no text
- Date: Wed, 1 May 2013 06:24:42 +0000 (UTC)
commit 5be22af4f4085eefb0d7bae1e3e0f7d233e291c6
Author: Pierre-Yves Luyten <py luyten fr>
Date: Wed May 1 08:21:24 2013 +0200
mainToolbar : make share button insensitive if note has no text
Fixes 699348
src/bjb-main-toolbar.c | 29 ++++++++++++++++++++++++++---
1 files changed, 26 insertions(+), 3 deletions(-)
---
diff --git a/src/bjb-main-toolbar.c b/src/bjb-main-toolbar.c
index b5e4ced..fa9241d 100644
--- a/src/bjb-main-toolbar.c
+++ b/src/bjb-main-toolbar.c
@@ -62,6 +62,7 @@ struct _BjbMainToolbarPrivate
/* When note view */
BijiNoteObj *note;
+ GtkWidget *share;
gulong note_renamed;
gulong note_color_changed;
GtkAccelGroup *accel;
@@ -474,6 +475,21 @@ on_note_color_changed (BijiNoteObj *note, GtkColorButton *button)
}
static void
+on_note_content_changed (BjbMainToolbar *self)
+{
+ gchar *str = NULL;
+ gboolean sensitive = TRUE;
+
+ if (self->priv->note)
+ str = biji_note_get_raw_text (self->priv->note);
+
+ if (!str || g_strcmp0 (str, "") == 0 || g_strcmp0 (str, "\n") == 0)
+ sensitive = FALSE;
+
+ gtk_widget_set_sensitive (self->priv->share, sensitive);
+}
+
+static void
bjb_toggle_bullets (BijiWebkitEditor *editor)
{
biji_webkit_editor_apply_format (editor, BIJI_BULLET_LIST);
@@ -676,12 +692,19 @@ populate_bar_for_note_view (BjbMainToolbar *self)
G_CALLBACK (on_note_color_changed), button);
/* Sharing */
- button = gd_main_toolbar_add_button (bar, "send-to-symbolic",
- NULL, FALSE);
+ priv->share = gd_main_toolbar_add_button (bar, "send-to-symbolic",
+ NULL, FALSE);
- g_signal_connect (button, "clicked",
+ g_signal_connect (priv->share, "clicked",
G_CALLBACK (on_email_note_callback), priv->note);
+ g_signal_connect_swapped (biji_note_obj_get_editor (priv->note),
+ "user-changed-contents",
+ G_CALLBACK (on_note_content_changed),
+ self);
+
+ on_note_content_changed (self);
+
/* Menu */
button = gd_main_toolbar_add_menu (bar,
"emblem-system-symbolic",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]