[bijiben/popover] Popover: fix OSD



commit 2cc290661d1576aec74b90b1ed29d0ed352f4a18
Author: Pierre-Yves Luyten <py luyten fr>
Date:   Fri Mar 28 22:08:54 2014 +0100

    Popover: fix OSD
    
    Use class OSD and toolbar.

 src/bjb-editor-toolbar.c |  112 +++++++++++++++++++++-------------------------
 1 files changed, 51 insertions(+), 61 deletions(-)
---
diff --git a/src/bjb-editor-toolbar.c b/src/bjb-editor-toolbar.c
index 578b26f..c2e824b 100644
--- a/src/bjb-editor-toolbar.c
+++ b/src/bjb-editor-toolbar.c
@@ -53,11 +53,8 @@ struct _BjbEditorToolbarPrivate
   BjbNoteView        *view;
   BijiNoteObj        *note;
 
-  //ClutterActor       *actor;
   GtkWidget          *widget;
   GtkAccelGroup      *accel;
-  //ClutterActor       *parent_actor;
-  //ClutterConstraint  *width_constraint;
 
   /* If user rigth-clicks we want to keep the toolbar visible
    * untill user changes his mind */
@@ -320,8 +317,6 @@ bjb_editor_toolbar_constructed (GObject *obj)
   GtkWidget                 *window;
   GtkWidget                 *image;
   GdkPixbuf                 *pixbuf;
-  GtkStyleContext           *context;
-  GdkRGBA                    black = {0.0, 0.0, 0.0, 0.6};
   gchar                     *icons_path, *full_path;
   GError                    *error = NULL;
 
@@ -332,82 +327,78 @@ bjb_editor_toolbar_constructed (GObject *obj)
   window = bjb_note_view_get_base_window (priv->view);
   gtk_window_add_accel_group (GTK_WINDOW (window), priv->accel);
 
-  priv->widget = gtk_popover_new (GTK_WIDGET (priv->view));
-  context = gtk_widget_get_style_context (priv->widget);
-  gtk_style_context_add_class (context, "osd");
-  gtk_style_context_add_class (context, "linked");
-
-  gtk_widget_override_background_color (priv->widget,
-                                        GTK_STATE_FLAG_NORMAL,
-                                        &black);
 
-  priv->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+  /* Popover */
+  priv->widget = gtk_popover_new (GTK_WIDGET (priv->view));
+  gtk_style_context_add_class (gtk_widget_get_style_context (priv->widget),
+                               GTK_STYLE_CLASS_OSD);
+  gtk_popover_set_position (GTK_POPOVER (priv->widget),
+                            GTK_POS_TOP);
+  gtk_popover_set_modal (GTK_POPOVER (priv->widget), FALSE);
+
+
+  /* Toolbar */
+  priv->box = GTK_WIDGET (gtk_toolbar_new ());
+  gtk_toolbar_set_style (GTK_TOOLBAR (priv->box), GTK_TOOLBAR_TEXT);
+  gtk_toolbar_set_show_arrow (GTK_TOOLBAR (priv->box), FALSE);
+  gtk_widget_show (priv->box);
   gtk_container_add (GTK_CONTAINER (priv->widget), priv->box);
-  gtk_widget_set_opacity (priv->box, 0.1);
+
 
   /* Cut */
-  priv->toolbar_cut = gtk_button_new_with_label (_("Cut"));
-  gtk_container_add (GTK_CONTAINER (priv->box), priv->toolbar_cut);
-  gtk_widget_override_background_color (priv->toolbar_cut,
-                                        GTK_STATE_FLAG_NORMAL,
-                                        &black);
+  priv->toolbar_cut = gtk_tool_button_new (NULL, _("Cut"));
+  gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON (priv->toolbar_cut), TRUE);
+  gtk_widget_show (priv->toolbar_cut);
+  gtk_toolbar_insert (GTK_TOOLBAR (priv->box), priv->toolbar_cut, -1);
+
 
   /* Copy */
-  priv->toolbar_copy = gtk_button_new_with_label (_("Copy"));
-  gtk_container_add (GTK_CONTAINER (priv->box), priv->toolbar_copy);
-  gtk_widget_override_background_color (priv->toolbar_copy,
-                                        GTK_STATE_FLAG_NORMAL,
-                                        &black);
+  priv->toolbar_copy = gtk_tool_button_new (NULL, _("Copy"));
+  gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON (priv->toolbar_copy), TRUE);
+  gtk_widget_show (priv->toolbar_copy);
+  gtk_toolbar_insert (GTK_TOOLBAR (priv->box), priv->toolbar_copy, -1);
 
   /* 'n paste */
-  priv->toolbar_paste = gtk_button_new_with_label (_("Paste"));
-  gtk_container_add (GTK_CONTAINER (priv->box), priv->toolbar_paste);
-  gtk_widget_override_background_color (priv->toolbar_paste,
-                                        GTK_STATE_FLAG_NORMAL,
-                                        &black);
-
+  priv->toolbar_paste = gtk_tool_button_new (NULL, _("_Paste"));
+  gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON (priv->toolbar_paste), TRUE);
+  gtk_widget_show (priv->toolbar_copy);
+  gtk_toolbar_insert (GTK_TOOLBAR (priv->box), priv->toolbar_paste, -1);
 
   if (biji_note_obj_can_format (priv->note))
   {
 
-    /* GtkWidget         *toolbar_bold   */
-    priv->toolbar_bold = gtk_button_new ();
+    /* Bold */
     image = gtk_image_new_from_icon_name ("format-text-bold-symbolic", GTK_ICON_SIZE_INVALID);
     gtk_image_set_pixel_size (GTK_IMAGE (image), 24);
-    gtk_container_add (GTK_CONTAINER (priv->toolbar_bold), image);
+    priv->toolbar_bold = gtk_tool_button_new (image, NULL);
+    gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON (priv->toolbar_bold), TRUE);
+    gtk_widget_show (priv->toolbar_bold);
+    gtk_toolbar_insert (GTK_TOOLBAR (priv->box), priv->toolbar_bold, -1);
     gtk_widget_set_tooltip_text (GTK_WIDGET (priv->toolbar_bold), _("Bold"));
-    gtk_container_add (GTK_CONTAINER (priv->box), priv->toolbar_bold);
-    gtk_widget_override_background_color (priv->toolbar_bold,
-                                          GTK_STATE_FLAG_NORMAL,
-                                          &black);
 
-    /* GtkWidget          *toolbar_italic; */
-    priv->toolbar_italic = gtk_button_new ();
+
+    /* Italic */
     image = gtk_image_new_from_icon_name ("format-text-italic-symbolic", GTK_ICON_SIZE_INVALID);
     gtk_image_set_pixel_size (GTK_IMAGE (image), 24);
-    gtk_container_add (GTK_CONTAINER (priv->toolbar_italic), image);
+    priv->toolbar_italic = gtk_tool_button_new (image, NULL);
+    gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON (priv->toolbar_italic), TRUE);
+    gtk_widget_show (priv->toolbar_italic);
+    gtk_toolbar_insert (GTK_TOOLBAR (priv->box), priv->toolbar_italic, -1);
     gtk_widget_set_tooltip_text (GTK_WIDGET (priv->toolbar_italic), _("Italic"));
-    gtk_container_add (GTK_CONTAINER (priv->box), priv->toolbar_italic);
-    gtk_widget_override_background_color (priv->toolbar_italic,
-                                          GTK_STATE_FLAG_NORMAL,
-                                          &black);
 
-    /* GtkWidget          *toolbar_strike; */
-    priv->toolbar_strike = gtk_button_new ();
+
+    /* Strike */
     image = gtk_image_new_from_icon_name ("format-text-strikethrough-symbolic", GTK_ICON_SIZE_INVALID);
     gtk_image_set_pixel_size (GTK_IMAGE (image), 24);
-    gtk_container_add (GTK_CONTAINER (priv->toolbar_strike), image);
+    priv->toolbar_strike = gtk_tool_button_new (image, NULL);
+    gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON (priv->toolbar_strike), TRUE);
+    gtk_widget_show (priv->toolbar_strike);
+    gtk_toolbar_insert (GTK_TOOLBAR (priv->box), priv->toolbar_strike, -1);
     gtk_widget_set_tooltip_text (GTK_WIDGET (priv->toolbar_strike), _("Strike"));
-    gtk_container_add (GTK_CONTAINER (priv->box), priv->toolbar_strike);
-    gtk_widget_override_background_color (priv->toolbar_strike,
-                                          GTK_STATE_FLAG_NORMAL,
-                                          &black);
-
   }
 
-  /* GtkWidget          *toolbar_link; */
-  priv->toolbar_link = gtk_button_new ();
 
+  /* Link */
   icons_path = (gchar*) bijiben_get_bijiben_dir ();
   full_path = g_build_filename (icons_path,
                                 "bijiben",
@@ -426,14 +417,13 @@ bjb_editor_toolbar_constructed (GObject *obj)
 
   image = gtk_image_new_from_pixbuf (pixbuf);
   gtk_image_set_pixel_size (GTK_IMAGE (image), 24);
-
-  gtk_container_add (GTK_CONTAINER (priv->toolbar_link), image);
+  priv->toolbar_link = gtk_tool_button_new (image, NULL);
+  gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON (priv->toolbar_link), TRUE);
+  gtk_widget_show (priv->toolbar_link);
+  gtk_toolbar_insert (GTK_TOOLBAR (priv->box), priv->toolbar_link, -1);
   gtk_widget_set_tooltip_text (GTK_WIDGET (priv->toolbar_link),
                                _("Copy selection to a new note"));
-  gtk_container_add (GTK_CONTAINER (priv->box), priv->toolbar_link);
-  gtk_widget_override_background_color (priv->toolbar_link,
-                                        GTK_STATE_FLAG_NORMAL,
-                                        &black);
+
 
   priv->glued = FALSE;
   gtk_widget_show_all (priv->widget);


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