[bijiben] Do not use GtkClutter for main view
- From: Pierre-Yves Luyten <pyluyten src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bijiben] Do not use GtkClutter for main view
- Date: Sat, 2 Mar 2013 01:53:18 +0000 (UTC)
commit 4360e1dbea9722c407a510106a702e141d4a669c
Author: Pierre-Yves Luyten <py luyten fr>
Date: Sat Mar 2 02:51:12 2013 +0100
Do not use GtkClutter for main view
Use GdRevealer for search entry and GtkOverlay to handle selection bar
Return BjbNoteView as a widget to pack
GtkClutter is still used for note view
configure.ac | 1 +
src/bjb-bijiben.c | 24 ++++----
src/bjb-main-toolbar.c | 66 +++++++------------
src/bjb-main-toolbar.h | 7 +--
src/bjb-main-view.c | 105 +++++++------------------------
src/bjb-main-view.h | 7 +--
src/bjb-note-view.c | 71 +++++++++++----------
src/bjb-note-view.h | 8 +--
src/bjb-search-toolbar.c | 106 +++++++++++--------------------
src/bjb-search-toolbar.h | 12 ++--
src/bjb-selection-toolbar.c | 117 ++++++----------------------------
src/bjb-selection-toolbar.h | 10 +--
src/bjb-window-base.c | 146 +++++++++++++++++++------------------------
src/bjb-window-base.h | 19 ++----
14 files changed, 242 insertions(+), 457 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 0730ff4..c62663e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -47,6 +47,7 @@ LIBGD_INIT([
gtk-hacks
main-view
main-toolbar
+ revealer
stack
])
diff --git a/src/bjb-bijiben.c b/src/bjb-bijiben.c
index 57d974b..a989318 100644
--- a/src/bjb-bijiben.c
+++ b/src/bjb-bijiben.c
@@ -18,7 +18,6 @@
#include <glib/gi18n.h>
#include <stdlib.h>
-#include <clutter-gtk/clutter-gtk.h>
#include <libbiji/libbiji.h>
@@ -57,11 +56,14 @@ bijiben_new_window_internal (GApplication *app,
if (note != NULL)
{
- bjb_window_base_set_frame(BJB_WINDOW_BASE(win),
- CLUTTER_ACTOR(bjb_note_view_new(GTK_WIDGET(win), note)));
-
- gtk_window_set_title(win,biji_note_obj_get_title (note));
+ bjb_window_base_switch_to_note (BJB_WINDOW_BASE (win), note);
}
+
+ else
+ {
+ bjb_window_base_switch_to (BJB_WINDOW_BASE (win), BJB_MAIN_VIEW);
+ gtk_widget_show_all (GTK_WIDGET (win)); // FIXME not here
+ }
}
void
@@ -285,10 +287,11 @@ bijiben_startup (GApplication *application)
G_APPLICATION_CLASS (bijiben_parent_class)->startup (application);
if (gtk_clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS)
- {
- g_warning ("Unable to initialize Clutter");
- return;
- }
+ {
+ g_warning ("Unable to initialize Clutter");
+ return;
+ }
+
bjb_app_menu_set(application);
@@ -355,9 +358,6 @@ bijiben_class_init (BijibenClass *klass)
Bijiben *
bijiben_new (void)
{
- #if !GLIB_CHECK_VERSION(2,35,0) /* return true if glib < 2.35.0 */
- g_type_init ();
- #endif
return g_object_new (BIJIBEN_TYPE_APPLICATION,
"application-id", "org.gnome.bijiben",
"flags", G_APPLICATION_HANDLES_OPEN,
diff --git a/src/bjb-main-toolbar.c b/src/bjb-main-toolbar.c
index 04992b8..19c31c0 100644
--- a/src/bjb-main-toolbar.c
+++ b/src/bjb-main-toolbar.c
@@ -33,10 +33,6 @@ typedef enum
struct _BjbMainToolbarPrivate
{
- /* Widget and actor */
- ClutterActor *actor;
- GdMainToolbar *toolbar;
-
/* Controllers */
GdMainView *view;
BjbToolbarType type;
@@ -69,7 +65,7 @@ static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
#define BJB_MAIN_TOOLBAR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BJB_TYPE_MAIN_TOOLBAR,
BjbMainToolbarPrivate))
-G_DEFINE_TYPE (BjbMainToolbar, bjb_main_toolbar, G_TYPE_OBJECT);
+G_DEFINE_TYPE (BjbMainToolbar, bjb_main_toolbar, GD_TYPE_MAIN_TOOLBAR);
/* Callbacks */
@@ -94,7 +90,7 @@ on_selection_mode_changed (BjbMainToolbar *self)
{
GtkStyleContext *context;
GdMainView *view = self->priv->view;
- GtkWidget *widget = GTK_WIDGET(self->priv->toolbar);
+ GtkWidget *widget = GTK_WIDGET(self);
context = gtk_widget_get_style_context (widget);
if (!gd_main_view_get_selection_mode (view))
@@ -180,7 +176,7 @@ update_selection_label (GdMainView *view, BjbMainToolbar *self)
else
label = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE, "%d selected", "%d selected", length),length);
- gd_main_toolbar_set_labels (self->priv->toolbar, NULL, label);
+ gd_main_toolbar_set_labels (GD_MAIN_TOOLBAR (self), NULL, label);
g_free (label);
return TRUE;
@@ -192,7 +188,7 @@ populate_bar_for_selection(BjbMainToolbar *self)
BjbMainToolbarPrivate *priv = self->priv;
GtkStyleContext *context;
- priv->select = gd_main_toolbar_add_button (priv->toolbar,
+ priv->select = gd_main_toolbar_add_button (GD_MAIN_TOOLBAR (self),
NULL,"Done", FALSE);
context = gtk_widget_get_style_context (priv->select);
gtk_style_context_add_class (context, "suggested-action");
@@ -222,7 +218,7 @@ update_label_for_standard (BjbMainToolbar *self)
else
label = g_strdup (_("New and Recent"));
- gd_main_toolbar_set_labels (priv->toolbar, label, NULL);
+ gd_main_toolbar_set_labels (GD_MAIN_TOOLBAR (self), label, NULL);
g_free (label);
}
@@ -238,7 +234,7 @@ populate_bar_for_standard(BjbMainToolbar *self)
"search-changed", G_CALLBACK(update_label_for_standard), self);
/* New Note button */
- priv->new = gd_main_toolbar_add_button(priv->toolbar,
+ priv->new = gd_main_toolbar_add_button(GD_MAIN_TOOLBAR (self),
NULL,
_("New"),
TRUE);
@@ -256,7 +252,7 @@ populate_bar_for_standard(BjbMainToolbar *self)
G_CALLBACK(on_new_note_clicked),priv->parent);
/* Go to selection mode */
- priv->select = gd_main_toolbar_add_button(priv->toolbar,
+ priv->select = gd_main_toolbar_add_button(GD_MAIN_TOOLBAR (self),
"object-select-symbolic",
NULL,
FALSE);
@@ -271,7 +267,7 @@ populate_bar_for_icon_view(BjbMainToolbar *self)
BjbMainToolbarPrivate *priv = self->priv;
/* Switch to list */
- priv->list= gd_main_toolbar_add_button(priv->toolbar,
+ priv->list= gd_main_toolbar_add_button(GD_MAIN_TOOLBAR (self),
"view-list-symbolic",
NULL,
FALSE);
@@ -288,7 +284,7 @@ populate_bar_for_list_view(BjbMainToolbar *self)
BjbMainToolbarPrivate *priv = self->priv;
/* Switch to icon view */
- priv->grid = gd_main_toolbar_add_button(priv->toolbar,
+ priv->grid = gd_main_toolbar_add_button(GD_MAIN_TOOLBAR (self),
"view-grid-symbolic",
NULL,
FALSE);
@@ -321,7 +317,7 @@ populate_bar_switch(BjbMainToolbar *self)
Please fill in a bug report");
}
- gtk_widget_show_all(GTK_WIDGET(self->priv->toolbar));
+ gtk_widget_show_all (GTK_WIDGET (self));
}
static void
@@ -343,7 +339,7 @@ populate_main_toolbar(BjbMainToolbar *self)
if (to_be != priv->type)
{
priv->type = to_be;
- gd_main_toolbar_clear (priv->toolbar);
+ gd_main_toolbar_clear (GD_MAIN_TOOLBAR (self));
if (priv->search_handler != 0)
{
@@ -364,18 +360,9 @@ bjb_main_toolbar_constructed (GObject *obj)
static void
bjb_main_toolbar_init (BjbMainToolbar *self)
{
- BjbMainToolbarPrivate *priv;
-
- priv = BJB_MAIN_TOOLBAR_GET_PRIVATE(self);
- self->priv = priv ;
-
- priv->type = BJB_TOOLBAR_0 ;
-
- priv->toolbar = GD_MAIN_TOOLBAR(gd_main_toolbar_new());
- g_signal_connect (priv->toolbar, "button-press-event", G_CALLBACK (on_button_press), NULL);
- priv->actor = gtk_clutter_actor_new_with_contents(GTK_WIDGET(priv->toolbar));
-
- clutter_actor_show (priv->actor);
+ self->priv = BJB_MAIN_TOOLBAR_GET_PRIVATE(self);
+ self->priv->type = BJB_TOOLBAR_0 ;
+ g_signal_connect (self, "button-press-event", G_CALLBACK (on_button_press), NULL);
}
static void
@@ -484,24 +471,21 @@ bjb_main_toolbar_new (GdMainView *view,
BjbMainView *parent,
BjbController *controller)
{
- /* View is the last one since it triggers the switch to populate bar.*/
- return g_object_new (BJB_TYPE_MAIN_TOOLBAR,
- "controller", controller,
- "parent", parent,
- "view", view,
- NULL);
+ /* Since heriting GdMainToolbar, we populate bar _after_ construct */
+ BjbMainToolbar *self;
+
+ self = BJB_MAIN_TOOLBAR (g_object_new (BJB_TYPE_MAIN_TOOLBAR,
+ "controller", controller,
+ "parent", parent,
+ "view", view,
+ NULL));
+
+ populate_main_toolbar(self);
+ return self;
}
void
bjb_main_toolbar_set_view (BjbMainToolbar *self, GdMainView *view)
{
- /* populate the toolbar */
self->priv->view = view ;
- populate_main_toolbar(self);
-}
-
-ClutterActor *
-bjb_main_toolbar_get_actor (BjbMainToolbar *self)
-{
- return self->priv->actor;
}
diff --git a/src/bjb-main-toolbar.h b/src/bjb-main-toolbar.h
index 636117c..6e892c9 100644
--- a/src/bjb-main-toolbar.h
+++ b/src/bjb-main-toolbar.h
@@ -21,7 +21,6 @@ bijiben is free software: you can redistribute it and/or modify it
#include <glib-object.h>
#include <gtk/gtk.h>
-#include <clutter-gtk/clutter-gtk.h>
#include <libgd/gd.h>
#include "bjb-main-view.h"
@@ -41,12 +40,12 @@ typedef struct _BjbMainToolbarPrivate BjbMainToolbarPrivate;
struct _BjbMainToolbarClass
{
- GObjectClass parent_class;
+ GdMainToolbarClass parent_class;
};
struct _BjbMainToolbar
{
- GObject parent_instance;
+ GdMainToolbar parent_instance;
BjbMainToolbarPrivate *priv;
};
@@ -56,8 +55,6 @@ BjbMainToolbar * bjb_main_toolbar_new (GdMainView *view,
BjbMainView *parent,
BjbController *controller);
-ClutterActor *bjb_main_toolbar_get_actor (BjbMainToolbar *self);
-
void on_selection_mode_changed (BjbMainToolbar *self);
void bjb_main_toolbar_set_view (BjbMainToolbar *self, GdMainView *view);
diff --git a/src/bjb-main-view.c b/src/bjb-main-view.c
index 89a9b83..4b23125 100644
--- a/src/bjb-main-view.c
+++ b/src/bjb-main-view.c
@@ -51,25 +51,17 @@ static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
struct _BjbMainViewPriv {
GtkWidget *window;
GtkWidget *label;
- ClutterActor *bin;
- ClutterActor *embed ;
- ClutterActor *content;
/* Toolbar */
BjbMainToolbar *main_toolbar;
- ClutterActor *toolbar_actor;
/* Selection Mode */
- ClutterActor *actions ;
BjbSelectionToolbar *select_bar;
/* Search Entry */
- ClutterActor *search_actor;
BjbSearchToolbar *search_bar;
/* View Notes , model */
- /* TODO : controller is app-wide controller.
- * add one window specific controller */
GdMainView *view ;
BjbController *controller ;
@@ -80,7 +72,7 @@ struct _BjbMainViewPriv {
gulong data;
};
-G_DEFINE_TYPE (BjbMainView, bjb_main_view, CLUTTER_TYPE_ACTOR);
+G_DEFINE_TYPE (BjbMainView, bjb_main_view, GTK_TYPE_BOX);
static void
bjb_main_view_init (BjbMainView *object)
@@ -183,7 +175,7 @@ switch_to_note_view (BjbMainView *self, BijiNoteObj *note)
{
bjb_search_toolbar_disconnect (self->priv->search_bar);
bjb_main_view_disconnect_handlers (self);
- bjb_note_view_new (self->priv->window, note);
+ bjb_window_base_switch_to_note (BJB_WINDOW_BASE (self->priv->window), note);
}
static void
@@ -482,97 +474,52 @@ static void
bjb_main_view_constructed(GObject *o)
{
BjbMainView *self;
+ GtkBox *vbox; //self, too
BjbMainViewPriv *priv;
- ClutterActor *stage, *top, *view, *selection_bar;
- ClutterLayoutManager *filler, *packer, *switcher, *overlay;
- ClutterConstraint *constraint ;
+ GtkOverlay *overlay;
+ GdRevealer *revealer;
G_OBJECT_CLASS (bjb_main_view_parent_class)->constructed(G_OBJECT(o));
self = BJB_MAIN_VIEW(o);
priv = self->priv ;
- stage = bjb_window_base_get_stage (BJB_WINDOW_BASE (priv->window), MAIN_VIEW);
+ vbox = GTK_BOX (self);
+
+ gtk_box_set_homogeneous (vbox, FALSE);
+ gtk_box_set_spacing (vbox, 0);
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_VERTICAL);
priv->view = gd_main_view_new (DEFAULT_VIEW);
bjb_controller_set_main_view (priv->controller, priv->view);
- /* Probably move this to window_base or delete this */
- filler = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
- CLUTTER_BIN_ALIGNMENT_CENTER);
- priv->bin = clutter_actor_new();
- clutter_actor_set_name (priv->bin, "main_view:bin");
- clutter_actor_set_layout_manager(priv->bin,filler);
- clutter_actor_add_child(stage,priv->bin);
-
- constraint = clutter_bind_constraint_new (stage, CLUTTER_BIND_SIZE, 0.0);
- clutter_actor_add_constraint (priv->bin, constraint);
-
- packer = clutter_box_layout_new();
- clutter_box_layout_set_orientation(CLUTTER_BOX_LAYOUT(packer),
- CLUTTER_ORIENTATION_VERTICAL);
-
- priv->embed = clutter_actor_new();
- clutter_actor_set_layout_manager (priv->embed,packer) ;
- clutter_actor_add_child (priv->bin, priv->embed) ;
- clutter_actor_set_x_expand (priv->embed, TRUE);
- clutter_actor_set_y_expand (priv->embed, TRUE);
-
- /* Top contains main toolbar and search entry */
- switcher = clutter_box_layout_new();
- clutter_box_layout_set_orientation(CLUTTER_BOX_LAYOUT(switcher),
- CLUTTER_ORIENTATION_VERTICAL);
-
- top = clutter_actor_new();
- clutter_actor_set_layout_manager(top,switcher);
-
- clutter_actor_add_child(priv->embed,top);
-
/* main Toolbar */
- priv->main_toolbar = bjb_main_toolbar_new(priv->view,self,priv->controller);
- priv->toolbar_actor = bjb_main_toolbar_get_actor(priv->main_toolbar);
-
- clutter_actor_add_child(top,priv->toolbar_actor);
- clutter_actor_set_x_expand (priv->toolbar_actor, TRUE);
+ priv->main_toolbar = bjb_main_toolbar_new (priv->view, self, priv->controller);
+ gtk_box_pack_start (vbox, GTK_WIDGET (priv->main_toolbar), FALSE, FALSE, 0);
/* Search entry toolbar */
- priv->search_bar = bjb_search_toolbar_new(priv->window,
- top,
- priv->controller);
- priv->search_actor = bjb_search_toolbar_get_actor(priv->search_bar);
-
- clutter_actor_add_child(top,priv->search_actor);
- clutter_actor_set_x_expand (priv->search_actor, TRUE);
-
- /* Overlay contains : Notes view and selection panel */
- overlay = clutter_bin_layout_new(CLUTTER_BIN_ALIGNMENT_CENTER,
- CLUTTER_BIN_ALIGNMENT_CENTER);
- priv->content = clutter_actor_new();
- clutter_actor_set_layout_manager(priv->content,overlay);
-
- clutter_actor_add_child(priv->embed,priv->content);
- clutter_actor_set_y_expand (priv->content, TRUE);
+ priv->search_bar = bjb_search_toolbar_new (priv->window, priv->controller);
+ revealer = bjb_search_toolbar_get_revealer (priv->search_bar);
+ gtk_box_pack_start (vbox, GTK_WIDGET (revealer), FALSE, FALSE, 0);
/* Main view */
- view = gtk_clutter_actor_new_with_contents(GTK_WIDGET(priv->view));
- clutter_actor_add_child(priv->content,view);
- clutter_actor_set_x_expand (view, TRUE);
- clutter_actor_set_y_expand (view, TRUE);
+ overlay = GTK_OVERLAY (gtk_overlay_new ());
gd_main_view_set_selection_mode (priv->view, FALSE);
- gd_main_view_set_model(priv->view,
- bjb_controller_get_model(priv->controller));
+ gd_main_view_set_model (priv->view, bjb_controller_get_model(priv->controller));
+
+ gtk_container_add (GTK_CONTAINER (overlay), GTK_WIDGET (priv->view));
+ gtk_box_pack_start (vbox, GTK_WIDGET (overlay), TRUE, TRUE, 0);
/* Selection Panel */
- priv->select_bar = bjb_selection_toolbar_new (priv->content,priv->view,self);
- selection_bar = bjb_selection_toolbar_get_actor (priv->select_bar);
- clutter_actor_add_child (priv->bin, selection_bar);
+ priv->select_bar = bjb_selection_toolbar_new (priv->view, self);
+ gtk_overlay_add_overlay (overlay, GTK_WIDGET (priv->select_bar));
/* Drag n drop */
gtk_drag_dest_set (GTK_WIDGET (priv->view), GTK_DEST_DEFAULT_ALL,
target_list, 1, GDK_ACTION_COPY);
bjb_main_view_connect_signals (self);
- gtk_widget_show_all (priv->window);
+ gtk_widget_show_all (GTK_WIDGET (self));
}
static void
@@ -617,12 +564,6 @@ bjb_main_view_new(GtkWidget *win,
NULL);
}
-ClutterActor *
-bjb_main_view_get_actor(BjbMainView *b)
-{
- return b->priv->embed ;
-}
-
GtkWidget *
bjb_main_view_get_window(BjbMainView *view)
{
diff --git a/src/bjb-main-view.h b/src/bjb-main-view.h
index d891bc9..b14594a 100644
--- a/src/bjb-main-view.h
+++ b/src/bjb-main-view.h
@@ -4,7 +4,6 @@
#include <glib-object.h>
#include <gtk/gtk.h>
#include <libbiji/libbiji.h>
-#include <clutter-gtk/clutter-gtk.h>
#include "bjb-controller.h"
@@ -24,12 +23,12 @@ typedef struct _BjbMainViewPriv BjbMainViewPriv;
struct _BjbMainViewClass
{
- ClutterActorClass parent_class ;
+ GtkBoxClass parent_class ;
};
struct _BjbMainView
{
- ClutterActor parent_instance ;
+ GtkBox parent_instance ;
BjbMainViewPriv *priv;
};
@@ -39,8 +38,6 @@ BjbMainView * bjb_main_view_new(GtkWidget *win, BjbController *controller);
void bjb_main_view_connect_signals (BjbMainView *self);
-ClutterActor * bjb_main_view_get_actor(BjbMainView *b) ;
-
GtkWidget *bjb_main_view_get_window(BjbMainView *view);
void action_new_window_callback(GtkAction *action, gpointer bjb_main_view);
diff --git a/src/bjb-note-view.c b/src/bjb-note-view.c
index f0261b9..2af39e9 100644
--- a/src/bjb-note-view.c
+++ b/src/bjb-note-view.c
@@ -36,13 +36,14 @@ enum
{
PROP_0,
PROP_WINDOW,
+ PROP_PARENT,
PROP_NOTE,
NUM_PROPERTIES
};
static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
-G_DEFINE_TYPE (BjbNoteView, bjb_note_view, CLUTTER_TYPE_ACTOR)
+G_DEFINE_TYPE (BjbNoteView, bjb_note_view, GTK_CLUTTER_TYPE_EMBED)
#define GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), BJB_TYPE_NOTE_VIEW, BjbNoteViewPrivate))
@@ -50,10 +51,12 @@ G_DEFINE_TYPE (BjbNoteView, bjb_note_view, CLUTTER_TYPE_ACTOR)
struct _BjbNoteViewPrivate {
/* Data */
GtkWidget *window ;
+ GtkWidget *parent;
GtkWidget *view;
BijiNoteObj *note ;
/* UI */
+ BijiWebkitEditor *editor;
ClutterActor *embed;
GtkAccelGroup *accel;
ClutterActor *edit_actor;
@@ -68,6 +71,7 @@ struct _BjbNoteViewPrivate {
gulong destroy ;
gulong renamed ;
gulong deleted ;
+ gulong color;
};
static void
@@ -79,8 +83,8 @@ bjb_note_view_finalize(GObject *object)
g_signal_handler_disconnect (priv->note, priv->renamed);
g_signal_handler_disconnect (priv->window, priv->destroy);
g_signal_handler_disconnect (priv->note, priv->deleted);
+ g_signal_handler_disconnect (priv->note, priv->color);
- clutter_actor_destroy (priv->embed);
g_clear_object (&priv->accel);
g_clear_object (&priv->edit_bar);
clutter_color_free (priv->last_date_bckgrd_clr);
@@ -102,6 +106,9 @@ bjb_note_view_get_property (GObject *object,
case PROP_WINDOW:
g_value_set_object (value, self->priv->window);
break;
+ case PROP_PARENT:
+ g_value_set_object (value, self->priv->parent);
+ break;
case PROP_NOTE:
g_value_set_object (value, self->priv->note);
break;
@@ -124,6 +131,9 @@ bjb_note_view_set_property ( GObject *object,
case PROP_WINDOW:
self->priv->window = g_value_get_object(value);
break;
+ case PROP_PARENT:
+ self->priv->parent = g_value_get_object (value);
+ break;
case PROP_NOTE:
self->priv->note = g_value_get_object(value);
break;
@@ -139,7 +149,6 @@ bjb_note_view_init (BjbNoteView *self)
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, BJB_TYPE_NOTE_VIEW,
BjbNoteViewPrivate);
- self->priv->embed = clutter_actor_new ();
self->priv->accel = gtk_accel_group_new ();
self->priv->last_date_bckgrd_clr = NULL;
}
@@ -163,8 +172,7 @@ just_switch_to_main_view(BjbNoteView *self)
window = GTK_WINDOW(self->priv->window);
gtk_window_remove_accel_group (window, self->priv->accel);
- g_clear_object (&self);
- bjb_window_base_switch_to (BJB_WINDOW_BASE (window), MAIN_VIEW);
+ bjb_window_base_switch_to (BJB_WINDOW_BASE (window), BJB_MAIN_VIEW);
}
static void
@@ -239,16 +247,15 @@ bjb_note_menu_new (BjbNoteView *self)
{
BjbNoteViewPrivate *priv = self->priv;
GtkWidget *result, *item;
- BijiWebkitEditor *editor;
result = gtk_menu_new();
- editor = BIJI_WEBKIT_EDITOR (biji_note_obj_get_editor (priv->note));
+ priv->editor = BIJI_WEBKIT_EDITOR (biji_note_obj_get_editor (priv->note));
/* Undo Redo separator */
item = gtk_menu_item_new_with_label (_("Undo"));
gtk_menu_shell_append (GTK_MENU_SHELL (result), item);
g_signal_connect_swapped (item, "activate",
- G_CALLBACK (webkit_web_view_undo), editor);
+ G_CALLBACK (webkit_web_view_undo), priv->editor);
gtk_widget_add_accelerator (item, "activate", priv->accel, GDK_KEY_u,
GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
gtk_widget_show (item);
@@ -256,7 +263,7 @@ bjb_note_menu_new (BjbNoteView *self)
item = gtk_menu_item_new_with_label (_("Redo"));
gtk_menu_shell_append (GTK_MENU_SHELL (result), item);
g_signal_connect_swapped (item, "activate",
- G_CALLBACK (webkit_web_view_redo), editor);
+ G_CALLBACK (webkit_web_view_redo), priv->editor);
gtk_widget_add_accelerator (item, "activate", priv->accel, GDK_KEY_r,
GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
gtk_widget_show (item);
@@ -270,14 +277,14 @@ bjb_note_menu_new (BjbNoteView *self)
item = gtk_menu_item_new_with_label (_("Bullets"));
gtk_menu_shell_append (GTK_MENU_SHELL (result), item);
g_signal_connect_swapped (item, "activate",
- G_CALLBACK (bjb_toggle_bullets), editor);
+ G_CALLBACK (bjb_toggle_bullets), priv->editor);
gtk_widget_show(item);
/* Ordered list as 1.mouse 2.cats 3.dogs */
item = gtk_menu_item_new_with_label (_("List"));
gtk_menu_shell_append (GTK_MENU_SHELL (result), item);
g_signal_connect_swapped (item, "activate",
- G_CALLBACK (bjb_toggle_list), editor);
+ G_CALLBACK (bjb_toggle_list), priv->editor);
gtk_widget_show(item);
item = gtk_separator_menu_item_new ();
@@ -493,7 +500,7 @@ bjb_note_view_constructed (GObject *obj)
BjbNoteViewPrivate *priv = self->priv;
BjbSettings *settings;
GtkWidget *scroll;
- ClutterActor *stage, *vbox;
+ ClutterActor *vbox;
ClutterConstraint *constraint;
ClutterLayoutManager *full, *box, *bin;
gchar *default_font;
@@ -512,22 +519,19 @@ bjb_note_view_constructed (GObject *obj)
priv->note);
/* Start packing ui */
- stage = bjb_window_base_get_stage (BJB_WINDOW_BASE (priv->window), NOTE_VIEW);
+ gtk_container_add (GTK_CONTAINER (priv->parent), GTK_WIDGET (self));
+ gtk_widget_show_all (priv->parent);
+ priv->embed = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (self));
full = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
CLUTTER_BIN_ALIGNMENT_CENTER);
clutter_actor_set_layout_manager (priv->embed,full);
- clutter_actor_add_child (stage,priv->embed);
-
- constraint = clutter_bind_constraint_new (stage, CLUTTER_BIND_SIZE, 0.0);
- clutter_actor_add_constraint (priv->embed, constraint);
vbox = clutter_actor_new();
box = clutter_box_layout_new();
clutter_box_layout_set_orientation(CLUTTER_BOX_LAYOUT(box),
CLUTTER_ORIENTATION_VERTICAL);
-
clutter_actor_set_layout_manager (vbox,box);
clutter_actor_add_child (priv->embed,vbox);
@@ -580,9 +584,8 @@ bjb_note_view_constructed (GObject *obj)
g_object_get (G_OBJECT(settings),"color", &default_color, NULL);
gdk_rgba_parse (&color, default_color);
g_free (default_color);
- }
-
- biji_note_obj_set_rgba (priv->note, &color);
+ biji_note_obj_set_rgba (priv->note, &color);
+ }
/* Edition Toolbar */
priv->edit_bar = bjb_editor_toolbar_new (overlay, self, priv->note);
@@ -600,20 +603,16 @@ bjb_note_view_constructed (GObject *obj)
clutter_actor_add_constraint (priv->last_update, constraint);
copy_note_color_to_last_updated_background (self);
- g_signal_connect_swapped (priv->note, "color-changed",
+ priv->color = g_signal_connect_swapped (priv->note, "color-changed",
G_CALLBACK (copy_note_color_to_last_updated_background), self);
-
- /* Show & let's go */
- gtk_widget_show_all (priv->window);
- bjb_window_base_set_note (BJB_WINDOW_BASE (priv->window), priv->note);
- bjb_window_base_switch_to (BJB_WINDOW_BASE (priv->window), NOTE_VIEW);
}
BjbNoteView *
-bjb_note_view_new (GtkWidget *win, BijiNoteObj* note)
+bjb_note_view_new (GtkWidget *win, GtkWidget *parent, BijiNoteObj* note)
{
return g_object_new (BJB_TYPE_NOTE_VIEW,
"window",win,
+ "parent", parent,
"note",note,
NULL);
}
@@ -640,6 +639,16 @@ bjb_note_view_class_init (BjbNoteViewClass *klass)
g_object_class_install_property (object_class,PROP_WINDOW,properties[PROP_WINDOW]);
+ properties[PROP_PARENT] = g_param_spec_object ("parent",
+ "Parent Widget",
+ "Widget to pack in",
+ GTK_TYPE_WIDGET,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_property (object_class,PROP_PARENT,properties[PROP_PARENT]);
+
properties[PROP_NOTE] = g_param_spec_object ("note",
"Note",
"Note",
@@ -651,12 +660,6 @@ bjb_note_view_class_init (BjbNoteViewClass *klass)
g_object_class_install_property (object_class,PROP_NOTE,properties[PROP_NOTE]);
}
-ClutterActor *
-bjb_note_view_get_actor ( BjbNoteView *v)
-{
- return v->priv->embed ;
-}
-
GtkWidget *
bjb_note_view_get_base_window (BjbNoteView *v)
{
diff --git a/src/bjb-note-view.h b/src/bjb-note-view.h
index e71290a..851b531 100644
--- a/src/bjb-note-view.h
+++ b/src/bjb-note-view.h
@@ -28,19 +28,17 @@ G_BEGIN_DECLS
typedef struct _BjbNoteViewPrivate BjbNoteViewPrivate;
typedef struct {
- ClutterActor parent;
+ GtkClutterEmbed parent;
BjbNoteViewPrivate * priv ;
} BjbNoteView;
typedef struct {
- ClutterActorClass parent_class;
+ GtkClutterEmbedClass parent_class;
} BjbNoteViewClass;
GType bjb_note_view_get_type (void);
-BjbNoteView * bjb_note_view_new (GtkWidget *win,BijiNoteObj* note);
-
-ClutterActor * bjb_note_view_get_actor (BjbNoteView *view);
+BjbNoteView * bjb_note_view_new (GtkWidget *win, GtkWidget *parent, BijiNoteObj* note);
GtkWidget * bjb_note_view_get_base_window (BjbNoteView *v);
diff --git a/src/bjb-search-toolbar.c b/src/bjb-search-toolbar.c
index e046fda..4a3cb15 100644
--- a/src/bjb-search-toolbar.c
+++ b/src/bjb-search-toolbar.c
@@ -24,10 +24,10 @@
#include "config.h"
-#include <clutter-gtk/clutter-gtk.h>
#include <glib.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
+#include <libgd/gd-entry-focus-hack.h>
#include "bjb-controller.h"
#include "bjb-search-toolbar.h"
@@ -36,7 +36,6 @@ enum
{
PROP_0,
PROP_WINDOW,
- PROP_ACTOR,
PROP_CONTROLLER,
NUM_PROPERTIES
};
@@ -59,40 +58,32 @@ struct _BjbSearchToolbarPrivate
gulong inserted;
/* Misc UI */
+ GdRevealer *revealer;
+ GtkWidget *widget; // GTK_WIDGET (self)
GtkWidget *window;
- GtkWidget *widget;
- ClutterActor *actor;
- ClutterActor *parent_actor;
- ClutterConstraint *width_constraint;
};
-G_DEFINE_TYPE (BjbSearchToolbar, bjb_search_toolbar, G_TYPE_OBJECT);
+G_DEFINE_TYPE (BjbSearchToolbar, bjb_search_toolbar, GTK_TYPE_TOOLBAR);
static void
bjb_search_toolbar_fade_in (BjbSearchToolbar *self)
{
- BjbSearchToolbarPrivate *priv = self->priv;
- guint8 opacity;
-
- opacity = clutter_actor_get_opacity (priv->actor);
-
- if (opacity != 0)
- return;
-
- clutter_actor_set_opacity (priv->actor, 255);
- clutter_actor_show (priv->actor);
+ if (!gd_revealer_get_child_revealed (self->priv->revealer))
+ {
+ GdkDevice *device;
+ gd_revealer_set_reveal_child (self->priv->revealer, TRUE);
- gtk_widget_grab_focus (priv->search_entry);
+ device = gtk_get_current_event_device ();
+ if (device)
+ gd_entry_focus_hack (self->priv->search_entry, device);
+ }
}
static void
bjb_search_toolbar_fade_out (BjbSearchToolbar *self)
{
- BjbSearchToolbarPrivate *priv = self->priv;
-
- clutter_actor_set_opacity (priv->actor, 0);
- clutter_actor_hide (priv->actor);
- gtk_entry_set_text (GTK_ENTRY (priv->search_entry),"");
+ if (gd_revealer_get_child_revealed (self->priv->revealer))
+ gd_revealer_set_reveal_child (self->priv->revealer, FALSE);
}
/* If some text has been input, handle position */
@@ -102,8 +93,8 @@ on_key_released (GtkWidget *widget,GdkEvent *event,gpointer user_data)
BjbSearchToolbar *self = BJB_SEARCH_TOOLBAR (user_data);
BjbSearchToolbarPrivate *priv = self->priv;
- if (clutter_actor_get_opacity (priv->actor) != 0)
- gtk_editable_set_position (GTK_EDITABLE (priv->search_entry),-1);
+ if (gd_revealer_get_child_revealed (self->priv->revealer) == TRUE)
+ gtk_editable_set_position (GTK_EDITABLE (priv->search_entry), -1);
return FALSE;
}
@@ -114,7 +105,7 @@ on_key_pressed (GtkWidget *widget,GdkEvent *event,gpointer user_data)
BjbSearchToolbar *self = BJB_SEARCH_TOOLBAR (user_data);
/* Reveal the entry is text is input. TODO add more keys not input */
- if (clutter_actor_get_opacity (self->priv->actor) == 0)
+ if (gd_revealer_get_child_revealed (self->priv->revealer) == FALSE)
{
switch (event->key.keyval)
{
@@ -154,9 +145,6 @@ bjb_search_toolbar_get_property (GObject *object,
switch (property_id)
{
- case PROP_ACTOR:
- g_value_set_object (value, self->priv->parent_actor);
- break;
case PROP_WINDOW:
g_value_set_object (value, self->priv->window);
break;
@@ -182,9 +170,6 @@ bjb_search_toolbar_set_property (GObject *object,
case PROP_WINDOW:
self->priv->window = g_value_get_object (value);
break;
- case PROP_ACTOR:
- self->priv->parent_actor = g_value_get_object (value);
- break;
case PROP_CONTROLLER:
self->priv->controller = g_value_get_object (value);
break;
@@ -300,12 +285,6 @@ bjb_search_toolbar_constructed (GObject *obj)
priv->entry_buf = gtk_entry_get_buffer (GTK_ENTRY (priv->search_entry));
- /* Constraints */
- priv->width_constraint = clutter_bind_constraint_new (priv->parent_actor,
- CLUTTER_BIND_WIDTH,
- 0.0);
- clutter_actor_add_constraint (priv->actor, priv->width_constraint);
-
if (priv->needle && g_strcmp0 (priv->needle, "") !=0)
{
gtk_entry_set_text (GTK_ENTRY (priv->search_entry), priv->needle);
@@ -320,17 +299,23 @@ bjb_search_toolbar_init (BjbSearchToolbar *self)
BjbSearchToolbarPrivate *priv;
GtkStyleContext *context;
GtkToolItem *separator;
+ GtkToolItem *entry_item ;
+ GtkToolbar *tlbar;
+ tlbar = GTK_TOOLBAR (self);
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, BJB_TYPE_SEARCH_TOOLBAR, BjbSearchToolbarPrivate);
priv = self->priv;
+ priv->widget = GTK_WIDGET (self);
+ priv->revealer = GD_REVEALER (gd_revealer_new ());
- priv->widget = gtk_toolbar_new ();
- gtk_toolbar_set_show_arrow (GTK_TOOLBAR (priv->widget), FALSE);
- gtk_toolbar_set_icon_size (GTK_TOOLBAR (priv->widget), GTK_ICON_SIZE_LARGE_TOOLBAR);
+ gtk_container_add (GTK_CONTAINER (priv->revealer), priv->widget);
+
+ gtk_toolbar_set_show_arrow (tlbar, FALSE);
+ gtk_toolbar_set_icon_size (tlbar, GTK_ICON_SIZE_LARGE_TOOLBAR);
separator = gtk_tool_item_new ();
gtk_tool_item_set_expand (separator,TRUE);
- gtk_toolbar_insert (GTK_TOOLBAR(priv->widget),separator,-1);
+ gtk_toolbar_insert (tlbar,separator,-1);
priv->search_entry = gtk_search_entry_new ();
gtk_entry_set_icon_from_stock (GTK_ENTRY(priv->search_entry),
@@ -338,24 +323,17 @@ bjb_search_toolbar_init (BjbSearchToolbar *self)
GTK_STOCK_CLEAR);
gtk_entry_set_text (GTK_ENTRY (priv->search_entry),"");
- GtkToolItem *entry_item ;
- entry_item = gtk_tool_item_new();
- gtk_container_add(GTK_CONTAINER(entry_item),priv->search_entry);
- gtk_toolbar_insert(GTK_TOOLBAR(priv->widget),entry_item,-1);
- gtk_tool_item_set_expand(entry_item,TRUE);
+ entry_item = gtk_tool_item_new ();
+ gtk_container_add (GTK_CONTAINER (entry_item), priv->search_entry);
+ gtk_toolbar_insert (tlbar, entry_item,-1);
+ gtk_tool_item_set_expand (entry_item, TRUE);
separator = gtk_tool_item_new ();
- gtk_tool_item_set_expand (separator,TRUE);
- gtk_toolbar_insert (GTK_TOOLBAR(priv->widget),separator,-1);
+ gtk_tool_item_set_expand (separator, TRUE);
+ gtk_toolbar_insert (tlbar, separator, -1);
- context = gtk_widget_get_style_context (priv->widget);
+ context = gtk_widget_get_style_context (GTK_WIDGET (self));
gtk_style_context_add_class (context,"primary-toolbar");
-
- priv->actor = gtk_clutter_actor_new_with_contents (priv->widget);
- clutter_actor_set_opacity (priv->actor, 0);
- g_object_set (priv->actor, "show-on-set-parent", FALSE, NULL);
-
- gtk_widget_show_all (priv->widget);
}
static void
@@ -376,14 +354,6 @@ bjb_search_toolbar_class_init (BjbSearchToolbarClass *class)
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS);
- properties[PROP_ACTOR] = g_param_spec_object ("actor",
- "Actor",
- "ParentActor",
- CLUTTER_TYPE_ACTOR,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS);
-
properties[PROP_CONTROLLER] = g_param_spec_object ("controller",
"Controller",
"Controller",
@@ -398,18 +368,16 @@ bjb_search_toolbar_class_init (BjbSearchToolbarClass *class)
BjbSearchToolbar *
bjb_search_toolbar_new (GtkWidget *window,
- ClutterActor *parent_actor,
BjbController *controller)
{
return g_object_new (BJB_TYPE_SEARCH_TOOLBAR,
"window",window,
- "actor",parent_actor,
"controller",controller,
NULL);
}
-ClutterActor *
-bjb_search_toolbar_get_actor (BjbSearchToolbar *self)
+GdRevealer *
+bjb_search_toolbar_get_revealer (BjbSearchToolbar *self)
{
- return self->priv->actor;
+ return self->priv->revealer;
}
diff --git a/src/bjb-search-toolbar.h b/src/bjb-search-toolbar.h
index 6d11408..2704b89 100644
--- a/src/bjb-search-toolbar.h
+++ b/src/bjb-search-toolbar.h
@@ -2,7 +2,7 @@
#ifndef BJB_SEARCH_TOOLBAR_H
#define BJB_SEARCH_TOOLBAR_H
-#include <clutter/clutter.h>
+#include <libgd/gd-revealer.h>
G_BEGIN_DECLS
@@ -24,25 +24,25 @@ typedef struct _BjbSearchToolbarPrivate BjbSearchToolbarPrivate;
struct _BjbSearchToolbar
{
- GObject parent_instance;
+ GtkToolbar parent_instance;
BjbSearchToolbarPrivate *priv;
};
struct _BjbSearchToolbarClass
{
- GObjectClass parent_class;
+ GtkToolbarClass parent_class;
};
GType bjb_search_toolbar_get_type (void) G_GNUC_CONST;
-BjbSearchToolbar * bjb_search_toolbar_new (GtkWidget *window, ClutterActor *parent_actor, BjbController
*controller);
+BjbSearchToolbar * bjb_search_toolbar_new (GtkWidget *window, BjbController *controller);
+
+GdRevealer * bjb_search_toolbar_get_revealer (BjbSearchToolbar *self);
void bjb_search_toolbar_disconnect (BjbSearchToolbar *self);
void bjb_search_toolbar_connect (BjbSearchToolbar *self);
-ClutterActor * bjb_search_toolbar_get_actor (BjbSearchToolbar *self);
-
G_END_DECLS
#endif /* BJB_SEARCH_TOOLBAR_H */
diff --git a/src/bjb-selection-toolbar.c b/src/bjb-selection-toolbar.c
index ad273ab..e8efca7 100644
--- a/src/bjb-selection-toolbar.c
+++ b/src/bjb-selection-toolbar.c
@@ -20,7 +20,6 @@
#include "config.h"
-#include <clutter-gtk/clutter-gtk.h>
#include <glib.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
@@ -33,7 +32,6 @@
enum
{
PROP_0,
- PROP_ACTOR,
PROP_BJB_SELECTION,
PROP_BJB_MAIN_VIEW,
NUM_PROPERTIES
@@ -49,11 +47,8 @@ struct _BjbSelectionToolbarPrivate
/* sure */
BjbMainView *view ;
- ClutterActor *actor ;
GtkWidget *widget ;
GdMainView *selection ;
- ClutterActor *parent_actor;
- ClutterConstraint *width_constraint ;
/* misc gtk */
GtkToolItem *left_group;
@@ -63,27 +58,19 @@ struct _BjbSelectionToolbarPrivate
GtkWidget *right_box;
};
-G_DEFINE_TYPE (BjbSelectionToolbar, bjb_selection_toolbar, G_TYPE_OBJECT);
+G_DEFINE_TYPE (BjbSelectionToolbar, bjb_selection_toolbar, GTK_TYPE_TOOLBAR);
static void
bjb_selection_toolbar_fade_in (BjbSelectionToolbar *self)
{
- BjbSelectionToolbarPrivate *priv = self->priv;
- guint8 opacity;
-
- opacity = clutter_actor_get_opacity (priv->actor);
-
- if (opacity != 0)
- return;
-
- clutter_actor_set_opacity (priv->actor, 255);
+ gtk_widget_set_opacity (self->priv->widget, 1);
}
static void
bjb_selection_toolbar_fade_out (BjbSelectionToolbar *self)
{
- clutter_actor_set_opacity (self->priv->actor, 0);
+ gtk_widget_set_opacity (self->priv->widget, 0);
}
static void
@@ -129,39 +116,36 @@ static void
bjb_selection_toolbar_init (BjbSelectionToolbar *self)
{
BjbSelectionToolbarPrivate *priv;
- GtkWidget *bin;
GtkWidget *image;
GtkStyleContext *context;
GdkRGBA color = {0.0, 0.0, 0.0, 0.0};
+ GtkToolbar *tlbar;
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, BJB_TYPE_SELECTION_TOOLBAR, BjbSelectionToolbarPrivate);
priv = self->priv;
+ priv->widget = GTK_WIDGET (self);
+ tlbar = GTK_TOOLBAR (self);
- priv->widget = gtk_toolbar_new ();
- gtk_toolbar_set_show_arrow (GTK_TOOLBAR (priv->widget), FALSE);
- gtk_toolbar_set_icon_size (GTK_TOOLBAR (priv->widget), GTK_ICON_SIZE_LARGE_TOOLBAR);
- context = gtk_widget_get_style_context (priv->widget);
- gtk_style_context_add_class (context, "osd");
+ gtk_toolbar_set_show_arrow (tlbar, FALSE);
+ gtk_toolbar_set_icon_size (tlbar, GTK_ICON_SIZE_LARGE_TOOLBAR);
- priv->actor = gtk_clutter_actor_new_with_contents (priv->widget);
- clutter_actor_set_opacity (priv->actor, 0);
- g_object_set (priv->actor, "show-on-set-parent", FALSE, NULL);
+ gtk_widget_set_halign (priv->widget, GTK_ALIGN_CENTER);
+ gtk_widget_set_valign (priv->widget, GTK_ALIGN_END);
+ gtk_widget_set_margin_bottom (priv->widget, 40);
+ gtk_widget_set_opacity (priv->widget, 0);
+ gtk_widget_set_size_request (priv->widget, 500, -1);
- clutter_actor_set_easing_mode (priv->actor, CLUTTER_EASE_IN_QUAD);
- clutter_actor_set_easing_duration (priv->actor, 300.0);
-
- clutter_actor_set_easing_mode (priv->actor, CLUTTER_EASE_OUT_QUAD);
- clutter_actor_set_easing_duration (priv->actor, 300.0);
+ context = gtk_widget_get_style_context (priv->widget);
+ gtk_style_context_add_class (context, "osd");
- bin = gtk_clutter_actor_get_widget (GTK_CLUTTER_ACTOR (priv->actor));
- gtk_widget_override_background_color (bin,
+ gtk_widget_override_background_color (priv->widget,
GTK_STATE_FLAG_NORMAL,
&color);
priv->left_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
priv->left_group = gtk_tool_item_new ();
gtk_container_add (GTK_CONTAINER (priv->left_group), priv->left_box);
- gtk_toolbar_insert (GTK_TOOLBAR (priv->widget), priv->left_group, -1);
+ gtk_toolbar_insert (tlbar, priv->left_group, -1);
gtk_widget_show_all (GTK_WIDGET (priv->left_group));
/* Notes tags */
@@ -180,12 +164,12 @@ bjb_selection_toolbar_init (BjbSelectionToolbar *self)
gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (priv->separator), FALSE);
gtk_widget_set_visible (GTK_WIDGET (priv->separator), TRUE);
gtk_tool_item_set_expand (priv->separator, TRUE);
- gtk_toolbar_insert (GTK_TOOLBAR (priv->widget), priv->separator, -1);
+ gtk_toolbar_insert (tlbar, priv->separator, -1);
priv->right_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
priv->right_group = gtk_tool_item_new ();
gtk_container_add (GTK_CONTAINER (priv->right_group), priv->right_box);
- gtk_toolbar_insert (GTK_TOOLBAR (priv->widget), priv->right_group, -1);
+ gtk_toolbar_insert (tlbar, priv->right_group, -1);
gtk_widget_show_all (GTK_WIDGET (priv->right_group));
/* Trash notes */
@@ -197,7 +181,6 @@ bjb_selection_toolbar_init (BjbSelectionToolbar *self)
gtk_container_add (GTK_CONTAINER (priv->right_box), priv->toolbar_trash);
gtk_widget_show_all (priv->widget);
- clutter_actor_show(priv->actor);
}
static void
@@ -210,9 +193,6 @@ bjb_selection_toolbar_get_property (GObject *object,
switch (property_id)
{
- case PROP_ACTOR:
- g_value_set_object (value, self->priv->actor);
- break;
case PROP_BJB_SELECTION:
g_value_set_object(value, self->priv->selection);
break;
@@ -232,9 +212,6 @@ bjb_selection_toolbar_set_property (GObject *object,
switch (property_id)
{
- case PROP_ACTOR:
- self->priv->parent_actor = g_value_get_object (value);
- break;
case PROP_BJB_SELECTION:
self->priv->selection = g_value_get_object (value);
break;
@@ -248,29 +225,8 @@ bjb_selection_toolbar_set_property (GObject *object,
}
static void
-bjb_selection_toolbar_notify_width (GObject *object,
- GParamSpec *pspec,
- gpointer user_data)
-{
- BjbSelectionToolbar *self = BJB_SELECTION_TOOLBAR (user_data);
- BjbSelectionToolbarPrivate *priv = self->priv;
-
- gfloat offset = 300.0;
- gfloat width;
-
- width = clutter_actor_get_width (priv->parent_actor);
- if (width > 1000)
- offset += (width - 1000);
- else if (width < 600)
- offset -= (600 - width);
-
- clutter_bind_constraint_set_offset (CLUTTER_BIND_CONSTRAINT (priv->width_constraint), -1 * offset);
-}
-
-static void
bjb_selection_toolbar_constructed(GObject *obj)
{
- ClutterConstraint *constraint ;
BjbSelectionToolbar *self = BJB_SELECTION_TOOLBAR(obj);
BjbSelectionToolbarPrivate *priv = self->priv ;
@@ -290,20 +246,6 @@ bjb_selection_toolbar_constructed(GObject *obj)
g_signal_connect(priv->toolbar_trash,"clicked",
G_CALLBACK(action_delete_selected_notes),priv->view);
-
- priv->width_constraint = clutter_bind_constraint_new (priv->parent_actor, CLUTTER_BIND_WIDTH, -300.0);
- clutter_actor_add_constraint (priv->actor, priv->width_constraint);
-
- g_signal_connect (priv->actor,
- "notify::width",
- G_CALLBACK (bjb_selection_toolbar_notify_width),
- self);
-
- constraint = clutter_align_constraint_new (priv->parent_actor, CLUTTER_ALIGN_X_AXIS, 0.50);
- clutter_actor_add_constraint (priv->actor, constraint);
-
- constraint = clutter_align_constraint_new (priv->parent_actor, CLUTTER_ALIGN_Y_AXIS, 0.95);
- clutter_actor_add_constraint (priv->actor, constraint);
}
static void
@@ -316,16 +258,6 @@ bjb_selection_toolbar_class_init (BjbSelectionToolbarClass *class)
object_class->set_property = bjb_selection_toolbar_set_property ;
object_class->constructed = bjb_selection_toolbar_constructed ;
- properties[PROP_ACTOR] = g_param_spec_object ("actor",
- "Actor",
- "ParentActor",
- CLUTTER_TYPE_ACTOR,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS);
-
- g_object_class_install_property (object_class,PROP_ACTOR,properties[PROP_ACTOR]);
-
properties[PROP_BJB_SELECTION] = g_param_spec_object ("selection",
"Selection",
"SelectionController",
@@ -352,20 +284,11 @@ bjb_selection_toolbar_class_init (BjbSelectionToolbarClass *class)
BjbSelectionToolbar *
-bjb_selection_toolbar_new (ClutterActor *parent_actor,
- GdMainView *selection,
+bjb_selection_toolbar_new (GdMainView *selection,
BjbMainView *bjb_main_view)
{
return g_object_new (BJB_TYPE_SELECTION_TOOLBAR,
- "actor", parent_actor,
"selection", selection,
"bjbmainview",bjb_main_view,
NULL);
}
-
-
-ClutterActor *
-bjb_selection_toolbar_get_actor (BjbSelectionToolbar *self)
-{
- return self->priv->actor;
-}
diff --git a/src/bjb-selection-toolbar.h b/src/bjb-selection-toolbar.h
index 2f4f713..c06a888 100644
--- a/src/bjb-selection-toolbar.h
+++ b/src/bjb-selection-toolbar.h
@@ -21,7 +21,6 @@
#ifndef BJB_SELECTION_TOOLBAR_H
#define BJB_SELECTION_TOOLBAR_H
-#include <clutter/clutter.h>
#include <libgd/gd.h>
G_BEGIN_DECLS
@@ -44,20 +43,19 @@ typedef struct _BjbSelectionToolbarPrivate BjbSelectionToolbarPrivate;
struct _BjbSelectionToolbar
{
- GObject parent_instance;
+ GtkToolbar parent_instance;
BjbSelectionToolbarPrivate *priv;
};
struct _BjbSelectionToolbarClass
{
- GObjectClass parent_class;
+ GtkToolbarClass parent_class;
};
GType bjb_selection_toolbar_get_type (void) G_GNUC_CONST;
-BjbSelectionToolbar * bjb_selection_toolbar_new (ClutterActor *parent_actor, GdMainView *selection,
BjbMainView *bjb_main_view);
-
-ClutterActor * bjb_selection_toolbar_get_actor (BjbSelectionToolbar *self);
+BjbSelectionToolbar * bjb_selection_toolbar_new (GdMainView *selection,
+ BjbMainView *bjb_main_view);
G_END_DECLS
diff --git a/src/bjb-window-base.c b/src/bjb-window-base.c
index fb93a73..f566142 100644
--- a/src/bjb-window-base.c
+++ b/src/bjb-window-base.c
@@ -30,11 +30,12 @@ struct _BjbWindowBasePriv
GdStack *stack;
BjbWindowViewType current_view;
BjbMainView *view;
- ClutterActor *stage, *note_stage, *frame;
gchar *entry;
/* when a note is opened */
BijiNoteObj *note;
+ BjbNoteView *note_view;
+ GtkWidget *note_overlay;
/* To avoid loiding several times */
PangoFontDescription *font ;
@@ -69,17 +70,6 @@ bjb_window_base_finalize (GObject *object)
G_OBJECT_CLASS (bjb_window_base_parent_class)->finalize (object);
}
-static void
-bjb_window_base_class_init (BjbWindowBaseClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- gobject_class->constructor = bjb_window_base_constructor;
- gobject_class->finalize = bjb_window_base_finalize ;
-
- g_type_class_add_private (klass, sizeof (BjbWindowBasePriv));
-}
-
/* Just disconnect to avoid crash, the finalize does the real
* job */
static void
@@ -89,20 +79,17 @@ bjb_window_base_destroy (gpointer a, BjbWindowBase * self)
}
/* Gobj */
-static void
-bjb_window_base_init (BjbWindowBase *self)
+static void
+bjb_window_base_constructed (GObject *obj)
{
+ BjbWindowBase *self = BJB_WINDOW_BASE (obj);
BjbWindowBasePriv *priv;
const gchar *icons_path;
gchar *full_path;
GList *icons = NULL;
GdkPixbuf *bjb ;
GError *error = NULL;
- GtkClutterEmbed *embed;
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE(self,
- BJB_TYPE_WINDOW_BASE,
- BjbWindowBasePriv);
priv = self->priv;
priv->note = NULL;
@@ -136,30 +123,40 @@ bjb_window_base_init (BjbWindowBase *self)
/* We probably want to offer a no entry window at first (startup) */
priv->entry = NULL ;
-
priv->font = pango_font_description_from_string (BJB_DEFAULT_FONT);
/* UI : basic notebook */
priv->stack = GD_STACK (gd_stack_new ());
gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (priv->stack));
- /* Page for overview */
- embed = GTK_CLUTTER_EMBED (gtk_clutter_embed_new());
- gtk_clutter_embed_set_use_layout_size (embed, TRUE);
- gd_stack_add_named (priv->stack, GTK_WIDGET (embed), "main-view");
- priv->stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (embed));
-
- /* Page for note */
- embed = GTK_CLUTTER_EMBED (gtk_clutter_embed_new());
- gtk_clutter_embed_set_use_layout_size (embed, TRUE);
- gd_stack_add_named (priv->stack, GTK_WIDGET (embed), "note-view");
- priv->note_stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (embed));
-
/* Signals */
g_signal_connect(GTK_WIDGET(self),"destroy",
G_CALLBACK(bjb_window_base_destroy),self);
}
+static void
+bjb_window_base_init (BjbWindowBase *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ BJB_TYPE_WINDOW_BASE,
+ BjbWindowBasePriv);
+
+ /* Default window has no note opened */
+ self->priv->note_view = NULL;
+}
+
+static void
+bjb_window_base_class_init (BjbWindowBaseClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+ gobject_class->constructed = bjb_window_base_constructed;
+ gobject_class->constructor = bjb_window_base_constructor;
+ gobject_class->finalize = bjb_window_base_finalize ;
+
+ g_type_class_add_private (klass, sizeof (BjbWindowBasePriv));
+}
+
GtkWindow *
bjb_window_base_new(void)
{
@@ -170,15 +167,18 @@ bjb_window_base_new(void)
"application", g_application_get_default(),
"hide-titlebar-when-maximized", TRUE,
NULL);
+
+ /* Rather dirty to finish UI there. maybe bjb_w_b_set_controller */
+
priv = retval->priv;
priv->controller = bjb_controller_new
(bijiben_get_book (BIJIBEN_APPLICATION(g_application_get_default())),
priv->entry );
- /* UI : notes view. But some settings could allow other default. */
- priv->view = bjb_main_view_new ( GTK_WIDGET(retval),priv->controller);
- priv->frame = bjb_main_view_get_actor(priv->view);
+ priv->view = bjb_main_view_new (GTK_WIDGET (retval), priv->controller);
+ gd_stack_add_named (priv->stack, GTK_WIDGET (priv->view), "main-view");
+ gtk_widget_show_all (GTK_WIDGET (retval));
return GTK_WINDOW (retval);
}
@@ -197,40 +197,6 @@ window_base_get_font(GtkWidget *window)
}
void
-bjb_window_base_set_frame(BjbWindowBase *bwb,ClutterActor *frame)
-{
- /* TODO removing frame should finalize
- * or we can implement some interface
- * (bool) (hide_frame) (bwb) */
- if ( bwb->priv->frame )
- {
- clutter_actor_destroy(bwb->priv->frame);
- bwb->priv->frame = NULL ;
- }
-
- if ( CLUTTER_IS_ACTOR( bwb->priv->frame) )
- {
- bwb->priv->frame = frame ;
- clutter_actor_add_child (bwb->priv->stage, frame);
- }
-}
-
-ClutterActor *
-bjb_window_base_get_frame(BjbWindowBase *bwb)
-{
- return bwb->priv->frame ;
-}
-
-ClutterActor *
-bjb_window_base_get_stage (BjbWindowBase *bwb, BjbWindowViewType type)
-{
- if (type == NOTE_VIEW)
- return bwb->priv->note_stage;
-
- return bwb->priv->stage;
-}
-
-void
bjb_window_base_set_note (BjbWindowBase *self, BijiNoteObj *note)
{
g_return_if_fail (BJB_IS_WINDOW_BASE (self));
@@ -246,6 +212,15 @@ bjb_window_base_get_note (BjbWindowBase *self)
return self->priv->note;
}
+static void
+destroy_note_if_needed (BjbWindowBase *bwb)
+{
+ if (bwb->priv->note_view && GTK_IS_WIDGET (bwb->priv->note_view))
+ {
+ g_clear_pointer (&(bwb->priv->note_overlay), gtk_widget_destroy);
+ }
+}
+
void
bjb_window_base_switch_to (BjbWindowBase *bwb, BjbWindowViewType type)
{
@@ -254,34 +229,43 @@ bjb_window_base_switch_to (BjbWindowBase *bwb, BjbWindowViewType type)
/* Precise the window does not display any specific note
* Refresh the model
* Ensure the main view receives the proper signals */
- if (type == MAIN_VIEW)
+ if (type == BJB_MAIN_VIEW)
{
priv->note = NULL;
bjb_main_view_connect_signals (priv->view);
gd_stack_set_visible_child_name (priv->stack, "main-view");
+
+ destroy_note_if_needed (bwb);
}
else
{
+ gtk_widget_show_all (GTK_WIDGET (priv->note_overlay));
gd_stack_set_visible_child_name (priv->stack, "note-view");
}
}
+void
+bjb_window_base_switch_to_note (BjbWindowBase *bwb, BijiNoteObj *note)
+{
+ BjbWindowBasePriv *priv = bwb->priv;
+ GtkWidget *w = GTK_WIDGET (bwb);
+
+ destroy_note_if_needed (bwb);
+
+ priv->note_overlay = gtk_overlay_new ();
+ gd_stack_add_named (priv->stack, priv->note_overlay, "note-view");
+ priv->note_view = bjb_note_view_new (w, priv->note_overlay, note);
+
+ bjb_window_base_set_note (bwb, priv->note);
+ bjb_window_base_switch_to (bwb, BJB_NOTE_VIEW);
+ gtk_widget_show_all (w);
+}
+
BijiNoteBook *
bjb_window_base_get_book(GtkWidget * win)
{
- BjbWindowBase *b = BJB_WINDOW_BASE(win);
-
- if ( b->priv )
- {
- return bijiben_get_book(BIJIBEN_APPLICATION(g_application_get_default()));
- }
-
- else
- {
- g_message("Can't get notes");
- return NULL ;
- }
+ return bijiben_get_book (BIJIBEN_APPLICATION (g_application_get_default()));
}
void
diff --git a/src/bjb-window-base.h b/src/bjb-window-base.h
index 9333d80..93c1881 100644
--- a/src/bjb-window-base.h
+++ b/src/bjb-window-base.h
@@ -2,7 +2,6 @@
#define _BJB_WINDOW_BASE_H
#include <gtk/gtk.h>
-#include <clutter-gtk/clutter-gtk.h>
#include <libbiji/libbiji.h>
#include "bjb-settings.h"
@@ -33,9 +32,9 @@ struct _BjbWindowBase
};
typedef enum {
- MAIN_VIEW,
- NOTE_VIEW,
- NO_VIEW
+ BJB_MAIN_VIEW,
+ BJB_NOTE_VIEW,
+ BJB_NO_VIEW
} BjbWindowViewType;
GType bjb_window_base_get_type (void);
@@ -48,15 +47,10 @@ BjbController * bjb_window_base_get_controller ( BjbWindowBase *window ) ;
PangoFontDescription *bjb_window_base_get_font(GtkWidget *window);
-void bjb_window_base_set_frame(BjbWindowBase *bwb,ClutterActor *frame);
-
-ClutterActor * bjb_window_base_get_frame(BjbWindowBase *bwb);
-
-/* get the notebook relevant page */
-ClutterActor * bjb_window_base_get_stage (BjbWindowBase *bwb, BjbWindowViewType type);
-
void bjb_window_base_switch_to (BjbWindowBase *bwb, BjbWindowViewType type);
+void bjb_window_base_switch_to_note (BjbWindowBase *bwb, BijiNoteObj *note);
+
BijiNoteBook * bjb_window_base_get_book(GtkWidget * win);
void bjb_window_base_set_entry(GtkWidget *win, gchar *search_entry) ;
@@ -71,9 +65,6 @@ BijiNoteObj * bjb_window_base_get_note (BjbWindowBase *self);
void bjb_window_base_set_note (BjbWindowBase *self, BijiNoteObj *note);
-// DEBUG
-void biji_application_print_note_id(GtkWindow* win);
-
gboolean switch_window_fullscreen();
#endif /* _BJB_WINDOW_BASE_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]