[bijiben] Update main view color button when selection changes



commit 03fecea0d31fd9a6f6a5a934ea6619055e1f9b02
Author: Pierre-Yves Luyten <py luyten fr>
Date:   Fri Jan 18 00:54:50 2013 +0100

    Update main view color button when selection changes
    
    When notes are toggled, randomly retrieve one of the notes color to update the button and consequently the potential color dialog

 src/bjb-main-view.c         |   16 ++++++++++++++++
 src/bjb-main-view.h         |    4 ++++
 src/bjb-selection-toolbar.c |    5 +++++
 3 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/src/bjb-main-view.c b/src/bjb-main-view.c
index e1b79d1..b9f44f6 100644
--- a/src/bjb-main-view.c
+++ b/src/bjb-main-view.c
@@ -245,6 +245,22 @@ action_tag_selected_notes (GtkWidget *w, BjbMainView *view)
   g_list_free (notes);
 }
 
+gboolean
+bjb_main_view_get_selected_notes_color (BjbMainView *view, GdkRGBA *color)
+{
+  GList *paths;
+  gchar *url;
+  BijiNoteObj *note;
+
+  /*  GtkTreePath */
+  paths = get_selected_paths(view);
+  url = get_note_url_from_tree_path (paths->data, view) ;
+  note = note_book_get_note_at_path (bjb_window_base_get_book(view->priv->window), url);
+  g_list_free_full (paths, (GDestroyNotify) gtk_tree_path_free);
+
+  return biji_note_obj_get_rgba (note, color);
+}
+
 void
 action_color_selected_notes (GtkWidget *w, BjbMainView *view)
 {
diff --git a/src/bjb-main-view.h b/src/bjb-main-view.h
index fe805d1..bdefb83 100644
--- a/src/bjb-main-view.h
+++ b/src/bjb-main-view.h
@@ -43,6 +43,10 @@ GtkWidget *bjb_main_view_get_window(BjbMainView *view);
 
 void action_new_window_callback(GtkAction *action, gpointer bjb_main_view);
 
+/* Currently it simply looks for first selected note found. Maybe most common color?
+ * Or use default color when several ones including at least one default color?*/
+gboolean bjb_main_view_get_selected_notes_color (BjbMainView *view, GdkRGBA *color);
+
 void action_color_selected_notes (GtkWidget *w,BjbMainView *view);
 
 void action_tag_selected_notes (GtkWidget *w, BjbMainView *view);
diff --git a/src/bjb-selection-toolbar.c b/src/bjb-selection-toolbar.c
index bc18b08..9c2ae4d 100644
--- a/src/bjb-selection-toolbar.c
+++ b/src/bjb-selection-toolbar.c
@@ -90,8 +90,13 @@ static void
 bjb_selection_toolbar_set_item_visibility (BjbSelectionToolbar *self)
 {
   BjbSelectionToolbarPrivate *priv = self->priv;
+  GdkRGBA color;
 
   gtk_widget_set_visible (priv->toolbar_trash, TRUE);
+
+  /* Color */
+  if (bjb_main_view_get_selected_notes_color (priv->view, &color))
+    gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (priv->toolbar_color), &color);
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]