0
#include <clutter-gtk/gtk-clutter-embed.h>
0
#include <tidy/tidy-finger-scroll.h>
0
+#include <tidy/tidy-stylable.h>
0
#include <twitter-glib/twitter-glib.h>
0
#include "tweet-config.h"
0
+#include "tweet-spinner.h"
0
#include "tweet-status-model.h"
0
#include "tweet-status-view.h"
0
+#include "tweet-utils.h"
0
#include "tweet-window.h"
0
#define TWEET_WINDOW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TWEET_TYPE_WINDOW, TweetWindowPrivate))
0
@@ -29,10 +32,16 @@ struct _TweetWindowPrivate
0
+ ClutterEffectTemplate *spin_tmpl;
0
+ ClutterActor *spinner;
0
+ ClutterActor *status_view;
0
- TweetStatusModel *
model;
0
+ TweetStatusModel *
status_model;
0
@@ -44,6 +53,12 @@ tweet_window_dispose (GObject *gobject)
0
TweetWindowPrivate *priv = TWEET_WINDOW (gobject)->priv;
0
+ g_object_unref (priv->spin_tmpl);
0
+ priv->spin_tmpl = NULL;
0
g_source_remove (priv->refresh_id);
0
@@ -52,14 +67,15 @@ tweet_window_dispose (GObject *gobject)
0
+ twitter_client_end_session (priv->client);
0
g_object_unref (priv->client);
0
+ if (priv->
status_model)
0
- g_object_unref (priv->model);
0
+ g_object_unref (priv->status_model);
0
+ priv->status_model = NULL;
0
G_OBJECT_CLASS (tweet_window_parent_class)->dispose (gobject);
0
@@ -79,7 +95,12 @@ on_status_received (TwitterClient *client,
0
- tweet_status_model_append_status (window->priv->model, status);
0
+ tweet_spinner_stop (TWEET_SPINNER (window->priv->spinner));
0
+ clutter_effect_fade (window->priv->spin_tmpl, window->priv->spinner, 0,
0
+ (ClutterEffectCompleteFunc) clutter_actor_hide,
0
+ tweet_status_model_append_status (window->priv->status_model, status);
0
@@ -107,6 +128,19 @@ static gboolean
0
refresh_timeout (gpointer data)
0
TweetWindow *window = data;
0
+ TweetWindowPrivate *priv = window->priv;
0
+ tidy_list_view_set_model (TIDY_LIST_VIEW (priv->status_view), NULL);
0
+ g_object_unref (priv->status_model);
0
+ priv->status_model = TWEET_STATUS_MODEL (tweet_status_model_new ());
0
+ tidy_list_view_set_model (TIDY_LIST_VIEW (priv->status_view),
0
+ CLUTTER_MODEL (priv->status_model));
0
+ clutter_actor_show (window->priv->spinner);
0
+ clutter_effect_fade (window->priv->spin_tmpl, window->priv->spinner, 255,
0
+ tweet_spinner_start (TWEET_SPINNER (window->priv->spinner));
0
twitter_client_get_user_timeline (window->priv->client, NULL, 0, NULL);
0
@@ -120,40 +154,90 @@ tweet_window_constructed (GObject *gobject)
0
TweetWindowPrivate *priv = window->priv;
0
ClutterColor stage_color = { 0, 0, 0, 255 };
0
stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->canvas));
0
clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
0
- view = tweet_status_view_new (priv->model);
0
- scroll = tidy_finger_scroll_new (TIDY_FINGER_SCROLL_MODE_KINETIC);
0
- clutter_container_add_actor (CLUTTER_CONTAINER (scroll), view);
0
+ view = tweet_status_view_new (priv->status_model);
0
+ priv->scroll = tidy_finger_scroll_new (TIDY_FINGER_SCROLL_MODE_KINETIC);
0
+ clutter_container_add_actor (CLUTTER_CONTAINER (priv->scroll), view);
0
clutter_actor_show (view);
0
+ priv->status_view = view;
0
+ clutter_actor_set_size (priv->scroll, 350, 500);
0
+ clutter_actor_set_position (priv->scroll, 6, 6);
0
+ clutter_container_add_actor (CLUTTER_CONTAINER (stage), priv->scroll);
0
+ clutter_actor_show (priv->scroll);
0
+ img = tweet_texture_new_from_stock (GTK_WIDGET (window),
0
+ GTK_ICON_SIZE_LARGE_TOOLBAR);
0
- clutter_actor_set_size (scroll, 350, 500);
0
- clutter_actor_set_position (scroll, 6, 6);
0
- clutter_container_add_actor (CLUTTER_CONTAINER (stage), scroll);
0
- clutter_actor_show (scroll);
0
+ priv->spinner = tweet_spinner_new ();
0
+ tweet_spinner_set_image (TWEET_SPINNER (priv->spinner), img);
0
+ clutter_container_add_actor (CLUTTER_CONTAINER (stage), priv->spinner);
0
+ clutter_actor_set_anchor_point (priv->spinner, 64, 64);
0
+ clutter_actor_set_position (priv->spinner, 364 / 2, 500 / 2);
0
+ tweet_spinner_start (TWEET_SPINNER (priv->spinner));
0
+ clutter_actor_show (priv->spinner);
0
clutter_actor_show (stage);
0
gtk_widget_show (GTK_WIDGET (window));
0
twitter_client_get_user_timeline (priv->client, NULL, 0, NULL);
0
- priv->refresh_id = g_timeout_add_seconds (tweet_config_get_refresh_time (priv->config),
0
+ g_timeout_add_seconds (tweet_config_get_refresh_time (priv->config),
0
+tweet_window_style_set (GtkWidget *widget,
0
+ TweetWindowPrivate *priv = TWEET_WINDOW (widget)->priv;
0
+ ClutterColor active_color = { 0, };
0
+ ClutterColor text_color = { 0, };
0
+ ClutterColor bg_color = { 0, };
0
+ tweet_widget_get_fg_color (widget, GTK_STATE_ACTIVE, &active_color);
0
+ tweet_widget_get_text_color (widget, GTK_STATE_NORMAL, &text_color);
0
+ tweet_widget_get_bg_color (widget, GTK_STATE_NORMAL, &bg_color);
0
+ font_name = pango_font_description_to_string (widget->style->font_desc);
0
+ tidy_stylable_set (TIDY_STYLABLE (priv->scroll),
0
+ "active-color", &active_color,
0
+ "bg-color", &bg_color,
0
+ tidy_stylable_set (TIDY_STYLABLE (priv->status_view),
0
+ "active-color", &active_color,
0
+ "bg-color", &bg_color,
0
+ "text-color", &text_color,
0
+ "font-name", font_name,
0
tweet_window_class_init (TweetWindowClass *klass)
0
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
0
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
0
g_type_class_add_private (klass, sizeof (TweetWindowPrivate));
0
gobject_class->dispose = tweet_window_dispose;
0
gobject_class->constructed = tweet_window_constructed;
0
+ widget_class->style_set = tweet_window_style_set;
0
@@ -163,8 +247,9 @@ tweet_window_init (TweetWindow *window)
0
GtkWidget *hbox, *button;
0
GTK_WINDOW (window)->type = GTK_WINDOW_TOPLEVEL;
0
- gtk_window_set_
default_size (GTK_WINDOW (window), 364, 500);
0
+ gtk_window_set_
resizable (GTK_WINDOW (window), FALSE);
0
gtk_window_set_title (GTK_WINDOW (window), "Tweet");
0
+ gtk_widget_set_size_request (GTK_WIDGET (window), 364, 550);
0
window->priv = priv = TWEET_WINDOW_GET_PRIVATE (window);
0
@@ -172,12 +257,17 @@ tweet_window_init (TweetWindow *window)
0
gtk_container_add (GTK_CONTAINER (window), priv->vbox);
0
gtk_widget_show (priv->vbox);
0
+ priv->canvas = gtk_clutter_embed_new ();
0
+ gtk_container_add (GTK_CONTAINER (priv->vbox), priv->canvas);
0
+ gtk_widget_show (priv->canvas);
0
hbox = gtk_hbox_new (FALSE, 12);
0
- gtk_box_pack_
start (GTK_BOX (priv->vbox), hbox, FALSE, FALSE, 0);
0
+ gtk_box_pack_
end (GTK_BOX (priv->vbox), hbox, FALSE, FALSE, 0);
0
gtk_widget_show (hbox);
0
priv->entry = gtk_entry_new ();
0
gtk_box_pack_start (GTK_BOX (hbox), priv->entry, TRUE, TRUE, 0);
0
+ gtk_widget_set_tooltip_text (priv->entry, "Update your status");
0
gtk_widget_show (priv->entry);
0
g_signal_connect (priv->entry, "activate",
0
G_CALLBACK (on_entry_activate),
0
@@ -191,11 +281,9 @@ tweet_window_init (TweetWindow *window)
0
gtk_widget_show (button);
0
g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_activate), priv->entry);
0
- priv->canvas = gtk_clutter_embed_new ();
0
- gtk_container_add (GTK_CONTAINER (priv->vbox), priv->canvas);
0
- gtk_widget_show (priv->canvas);
0
+ priv->spin_tmpl = clutter_effect_template_new_for_duration (250, CLUTTER_ALPHA_SINE_INC);
0
- priv->
model = TWEET_STATUS_MODEL (tweet_status_model_new ());
0
+ priv->
status_model = TWEET_STATUS_MODEL (tweet_status_model_new ());
0
priv->config = tweet_config_get_default ();
0
priv->client = twitter_client_new_for_user (tweet_config_get_username (priv->config),
Comments
No one has commented yet.