[bijiben] Last Update : Use Gtk, not Clutter. Remove Clutter
- From: Pierre-Yves Luyten <pyluyten src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bijiben] Last Update : Use Gtk, not Clutter. Remove Clutter
- Date: Sun, 6 Apr 2014 21:58:36 +0000 (UTC)
commit a189da132e52e26d8413899d188432a8c8eb1ea7
Author: Pierre-Yves Luyten <py luyten fr>
Date: Sat Apr 5 22:48:42 2014 +0200
Last Update : Use Gtk, not Clutter. Remove Clutter
BjbNoteView : use Overlay. Last updated actor : use overlay power.
Remove Clutter dependency.
However there is a regression: this makes 689171 even worse.
configure.ac | 3 +-
src/bjb-bijiben.c | 10 +--
src/bjb-note-view.c | 149 ++++++++++---------------------------------------
src/bjb-note-view.h | 20 ++++--
src/bjb-window-base.c | 27 ++++-----
5 files changed, 59 insertions(+), 150 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 50b045c..b11f56b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -62,8 +62,7 @@ PKG_CHECK_MODULES([TRACKER], [tracker-sparql-1.0], [sparql_version="tracker-spar
])
PKG_CHECK_MODULES(BIJIBEN,
- [ clutter-gtk-1.0
- gio-unix-2.0
+ [ gio-unix-2.0
glib-2.0 >= $GLIB_REQUIRED_VERSION
goa-1.0
gtk+-3.0 >= $GTK_REQUIRED_VERSION
diff --git a/src/bjb-bijiben.c b/src/bjb-bijiben.c
index 5a16f25..51a924a 100644
--- a/src/bjb-bijiben.c
+++ b/src/bjb-bijiben.c
@@ -300,7 +300,7 @@ bijiben_startup (GApplication *application)
gchar *storage_path, *default_color;
GFile *storage;
GError *error;
- gchar *path;
+ gchar *path;
GdkRGBA color = {0,0,0,0};
@@ -309,11 +309,7 @@ bijiben_startup (GApplication *application)
error = NULL;
- if (gtk_clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS)
- {
- g_warning ("Unable to initialize Clutter");
- return;
- }
+ gtk_init (NULL, NULL);
bjb_app_menu_set(application);
@@ -321,7 +317,7 @@ bijiben_startup (GApplication *application)
storage_path = g_build_filename (g_get_user_data_dir (), "bijiben", NULL);
storage = g_file_new_for_path (storage_path);
- // Create the bijiben dir to ensure.
+ // Create the bijiben dir to ensure.
self->priv->first_run = TRUE;
g_file_make_directory (storage, NULL, &error);
diff --git a/src/bjb-note-view.c b/src/bjb-note-view.c
index 01aa852..eb4feb6 100644
--- a/src/bjb-note-view.c
+++ b/src/bjb-note-view.c
@@ -30,14 +30,13 @@ enum
{
PROP_0,
PROP_WINDOW,
- PROP_PARENT,
PROP_NOTE,
NUM_PROPERTIES
};
static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
-G_DEFINE_TYPE (BjbNoteView, bjb_note_view, GTK_CLUTTER_TYPE_EMBED)
+G_DEFINE_TYPE (BjbNoteView, bjb_note_view, GTK_TYPE_OVERLAY)
#define GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), BJB_TYPE_NOTE_VIEW, BjbNoteViewPrivate))
@@ -45,26 +44,19 @@ G_DEFINE_TYPE (BjbNoteView, bjb_note_view, GTK_CLUTTER_TYPE_EMBED)
struct _BjbNoteViewPrivate {
/* Data */
GtkWidget *window ;
- GtkWidget *parent;
GtkWidget *view;
BijiNoteObj *note ;
/* UI */
- BijiWebkitEditor *editor;
- ClutterActor *embed;
+ BijiWebkitEditor *editor;
BjbEditorToolbar *edit_bar;
gboolean edit_bar_is_sticky;
- // these two are the remaining Clutter to get rid of
- // kill this
- ClutterActor *last_update;
- ClutterColor *last_date_bckgrd_clr;
+ GtkWidget *last_update;
};
-
static void on_window_closed(GtkWidget *window,gpointer note);
static gboolean on_note_trashed (BijiNoteObj *note, BjbNoteView *view);
-static void copy_note_color_to_last_updated_background (BjbNoteView *self);
static void
@@ -75,7 +67,6 @@ bjb_note_view_disconnect (BjbNoteView *self)
priv = self->priv;
g_signal_handlers_disconnect_by_func (priv->window, on_window_closed, priv->note);
g_signal_handlers_disconnect_by_func (priv->note, on_note_trashed, self);
- g_signal_handlers_disconnect_by_func (priv->note, copy_note_color_to_last_updated_background, self);
}
@@ -88,7 +79,6 @@ bjb_note_view_finalize(GObject *object)
bjb_note_view_disconnect (self);
g_clear_object (&priv->view);
- clutter_color_free (priv->last_date_bckgrd_clr);
G_OBJECT_CLASS (bjb_note_view_parent_class)->finalize (object);
}
@@ -106,9 +96,6 @@ 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;
@@ -131,9 +118,6 @@ 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;
@@ -149,7 +133,6 @@ bjb_note_view_init (BjbNoteView *self)
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, BJB_TYPE_NOTE_VIEW,
BjbNoteViewPrivate);
- self->priv->last_date_bckgrd_clr = NULL;
}
static void
@@ -183,65 +166,34 @@ on_note_trashed (BijiNoteObj *note, BjbNoteView *view)
return TRUE;
}
-static void
-copy_note_color_to_last_updated_background (BjbNoteView *self)
-{
- BjbNoteViewPrivate *priv = self->priv;
- GdkRGBA note_color;
-
- if (biji_note_obj_get_rgba (priv->note, ¬e_color))
- {
- if (priv->last_date_bckgrd_clr)
- clutter_color_free (priv->last_date_bckgrd_clr);
-
- priv->last_date_bckgrd_clr = clutter_color_new (255 * note_color.red,
- 255 * note_color.green,
- 255 * note_color.blue,
- 255);
- clutter_actor_set_background_color (priv->last_update, priv->last_date_bckgrd_clr);
- }
-}
/* Number of days since last updated
* Instead we might want to play with a func to have a date
* Also this might be integrated in text view */
-ClutterActor *
+GtkWidget *
bjb_note_view_last_updated_actor_new (BjbNoteView *self)
{
- ClutterActor *result, *text;
- ClutterLayoutManager *layout;
- ClutterColor last_up_col = {122,122,122,255};
-
- gchar *last_updated_str;
-
- result = clutter_actor_new ();
- layout = clutter_box_layout_new ();
- clutter_actor_set_layout_manager (result, layout);
-
- text = clutter_text_new ();
- /* "Last updated" precedes the note last updated date */
-
- clutter_text_set_text (CLUTTER_TEXT (text), _("Last updated"));
- clutter_text_set_font_name (CLUTTER_TEXT (text), "Arial 12px");
- clutter_text_set_color (CLUTTER_TEXT (text), &last_up_col );
- clutter_actor_add_child (result, text);
-
- text = clutter_text_new ();
- clutter_text_set_text (CLUTTER_TEXT (text), " ");
- clutter_actor_add_child (result, text);
-
- text = clutter_text_new ();
- last_updated_str = biji_note_obj_get_last_change_date_string (
- self->priv->note);
- clutter_text_set_text (CLUTTER_TEXT (text), last_updated_str);
- clutter_text_set_font_name (CLUTTER_TEXT (text), "Arial 12px");
- clutter_actor_add_child (result, text);
-
- clutter_actor_show (result);
- return result ;
+ GtkWidget *ret;
+ gchar *str;
+
+
+ /* Translators: %s is the note last recency description.
+ * Last updated is placed as in left to right language
+ * right to left languages might move %s
+ * '%s <b>Last Updated</b>'
+ */
+ str = g_strdup_printf (_("<b>Last updated</b> %s"),
+ biji_note_obj_get_last_change_date_string (self->priv->note));
+ // "<span background='white'><b>Last updated</b> %s</span>
+ ret = gtk_label_new (str);
+ gtk_label_set_use_markup (GTK_LABEL (ret), TRUE);
+
+ g_free (str);
+ return ret;
}
+
static void
bjb_note_view_constructed (GObject *obj)
{
@@ -249,9 +201,6 @@ bjb_note_view_constructed (GObject *obj)
BjbNoteViewPrivate *priv = self->priv;
BjbSettings *settings;
GtkWidget *scroll;
- ClutterActor *text_actor, *overlay;
- ClutterConstraint *constraint;
- ClutterLayoutManager *full, *bin;
gchar *default_font;
GdkRGBA color;
@@ -272,24 +221,6 @@ bjb_note_view_constructed (GObject *obj)
g_signal_connect(priv->window,"destroy",
G_CALLBACK(on_window_closed), priv->note);
- /* Start packing ui */
- gtk_container_add (GTK_CONTAINER (priv->parent), GTK_WIDGET (self));
- 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);
-
- /* Overlay contains Text and EditToolbar */
- overlay = clutter_actor_new ();
- bin = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
- CLUTTER_BIN_ALIGNMENT_CENTER);
-
- clutter_actor_set_layout_manager (overlay,bin);
- clutter_actor_add_child (priv->embed, overlay);
- clutter_actor_set_x_expand (overlay,TRUE);
- clutter_actor_set_y_expand (overlay,TRUE);
/* Text Editor (WebKitMainView) */
scroll = gtk_scrolled_window_new (NULL,NULL);
@@ -306,14 +237,9 @@ bjb_note_view_constructed (GObject *obj)
GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER (scroll), GTK_WIDGET(priv->view));
+ gtk_container_add (GTK_CONTAINER (self), scroll);
gtk_widget_show (GTK_WIDGET (priv->view));
- text_actor = gtk_clutter_actor_new_with_contents (scroll);
- clutter_actor_add_child(overlay,text_actor);
-
- clutter_actor_set_x_expand(text_actor,TRUE);
- clutter_actor_set_y_expand(text_actor,TRUE);
-
/* Apply the gsettings font */
if (bjb_settings_use_system_font (settings))
@@ -342,25 +268,18 @@ bjb_note_view_constructed (GObject *obj)
/* Last updated row */
priv->last_update = bjb_note_view_last_updated_actor_new (self);
- clutter_actor_add_child (priv->embed,priv->last_update);
-
- constraint = clutter_align_constraint_new (priv->embed,CLUTTER_ALIGN_X_AXIS,0.05);
- clutter_actor_add_constraint (priv->last_update, constraint);
-
- constraint = clutter_align_constraint_new (priv->embed,CLUTTER_ALIGN_Y_AXIS,0.95);
- clutter_actor_add_constraint (priv->last_update, constraint);
-
- copy_note_color_to_last_updated_background (self);
- g_signal_connect_swapped (priv->note, "color-changed",
- G_CALLBACK (copy_note_color_to_last_updated_background), self);
+ gtk_widget_set_halign (priv->last_update, GTK_ALIGN_START);
+ gtk_widget_set_margin_start (priv->last_update, 50);
+ gtk_widget_set_valign (priv->last_update, GTK_ALIGN_END);
+ gtk_widget_set_margin_bottom (priv->last_update, 50);
+ gtk_overlay_add_overlay (GTK_OVERLAY (self), priv->last_update);
}
BjbNoteView *
-bjb_note_view_new (GtkWidget *win, GtkWidget *parent, BijiNoteObj* note)
+bjb_note_view_new (GtkWidget *win, BijiNoteObj* note)
{
return g_object_new (BJB_TYPE_NOTE_VIEW,
"window",win,
- "parent", parent,
"note",note,
NULL);
}
@@ -387,16 +306,6 @@ 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",
diff --git a/src/bjb-note-view.h b/src/bjb-note-view.h
index 8304cd0..3390e74 100644
--- a/src/bjb-note-view.h
+++ b/src/bjb-note-view.h
@@ -19,7 +19,7 @@
#define _NOTE_VIEW_H
#include <glib-object.h>
-#include <clutter-gtk/clutter-gtk.h>
+#include <gtk/gtk.h>
#include <libbiji/libbiji.h>
@@ -45,21 +45,27 @@ G_BEGIN_DECLS
typedef struct _BjbNoteViewPrivate BjbNoteViewPrivate;
typedef struct {
- GtkClutterEmbed parent;
+ GtkOverlay parent;
BjbNoteViewPrivate * priv ;
} BjbNoteView;
typedef struct {
- GtkClutterEmbedClass parent_class;
+ GtkOverlayClass parent_class;
} BjbNoteViewClass;
-GType bjb_note_view_get_type (void);
-BjbNoteView * bjb_note_view_new (GtkWidget *win, GtkWidget *parent, BijiNoteObj* note);
-GtkWidget * bjb_note_view_get_base_window (BjbNoteView *v);
+GType bjb_note_view_get_type (void);
-void bjb_note_view_grab_focus (BjbNoteView *view);
+
+BjbNoteView *bjb_note_view_new (GtkWidget *win,
+ BijiNoteObj* note);
+
+
+GtkWidget *bjb_note_view_get_base_window (BjbNoteView *v);
+
+
+void bjb_note_view_grab_focus (BjbNoteView *view);
G_END_DECLS
diff --git a/src/bjb-window-base.c b/src/bjb-window-base.c
index 9a49f83..440ccc2 100644
--- a/src/bjb-window-base.c
+++ b/src/bjb-window-base.c
@@ -60,7 +60,6 @@ struct _BjbWindowBasePriv
/* when a note is opened */
BijiNoteObj *note;
gboolean detached; // detached note
- GtkWidget *note_overlay;
PangoFontDescription *font ;
@@ -444,24 +443,24 @@ bjb_window_base_get_note (BjbWindowBase *self)
-
static void
-destroy_note_if_needed (BjbWindowBase *bwb)
+destroy_note_if_needed (BjbWindowBase *self)
{
- bwb->priv->note = NULL;
+ self->priv->note = NULL;
- if (bwb->priv->note_view && GTK_IS_WIDGET (bwb->priv->note_view))
- g_clear_pointer (&(bwb->priv->note_overlay), gtk_widget_destroy);
+ if (self->priv->note_view && GTK_IS_WIDGET (self->priv->note_view))
+ g_clear_pointer (&(self->priv->note_view), gtk_widget_destroy);
}
+
void
-bjb_window_base_switch_to (BjbWindowBase *bwb, BjbWindowViewType type)
+bjb_window_base_switch_to (BjbWindowBase *self, BjbWindowViewType type)
{
- BjbWindowBasePriv *priv = bwb->priv;
+ BjbWindowBasePriv *priv = self->priv;
priv->current_view = type;
if (type != BJB_WINDOW_BASE_NOTE_VIEW)
- destroy_note_if_needed (bwb);
+ destroy_note_if_needed (self);
switch (type)
{
@@ -520,7 +519,7 @@ bjb_window_base_switch_to (BjbWindowBase *bwb, BjbWindowViewType type)
case BJB_WINDOW_BASE_NOTE_VIEW:
- gtk_widget_show_all (GTK_WIDGET (priv->note_overlay));
+ gtk_widget_show_all (GTK_WIDGET (priv->note_view));
gtk_widget_hide (GTK_WIDGET (priv->search_bar));
gtk_stack_set_visible_child_name (priv->stack, "note-view");
break;
@@ -530,9 +529,10 @@ bjb_window_base_switch_to (BjbWindowBase *bwb, BjbWindowViewType type)
return;
}
- g_signal_emit (G_OBJECT (bwb), bjb_win_base_signals[BJB_WIN_BASE_VIEW_CHANGED],0);
+ g_signal_emit (G_OBJECT (self), bjb_win_base_signals[BJB_WIN_BASE_VIEW_CHANGED],0);
}
+
void
bjb_window_base_switch_to_item (BjbWindowBase *bwb, BijiItem *item)
{
@@ -549,10 +549,9 @@ bjb_window_base_switch_to_item (BjbWindowBase *bwb, BijiItem *item)
BijiNoteObj *note = BIJI_NOTE_OBJ (item);
priv->note = note;
- priv->note_overlay = gtk_overlay_new ();
- gtk_stack_add_named (priv->stack, priv->note_overlay, "note-view");
- priv->note_view = bjb_note_view_new (w, priv->note_overlay, note);
+ priv->note_view = bjb_note_view_new (w, note);
+ gtk_stack_add_named (priv->stack, GTK_WIDGET (priv->note_view), "note-view");
g_object_add_weak_pointer (G_OBJECT (priv->note_view),
(gpointer *) &priv->note_view);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]