public
Description: A Clutter-based Twitter client
Homepage: http://live.gnome.org/Tweet
Clone URL: git://github.com/ebassi/tweet.git
Search Repo:
Update the main window

Various tweaks to the TweetWindow widget: move the entry below the
scroll view; keep the GTK+ and Tidy styles in sync whenever is
possible; add the spinner actor.
Emmanuele Bassi (author)
Mon May 19 10:18:38 -0700 2008
commit  fea4e33e1f457a56e783333f233cb3dabbc113e4
tree    42ffbff7b56edcc91863528d16b0551e21e4309f
parent  44069485e2f76edd741bea11a02b2077d88194c5
...
13
14
15
 
16
17
18
19
 
20
21
 
22
23
24
...
29
30
31
 
 
 
 
 
 
32
33
34
35
 
36
37
38
...
44
45
46
 
 
 
 
 
 
47
48
49
...
52
53
54
 
55
56
57
58
59
 
60
61
62
 
 
63
64
65
...
79
80
81
82
 
 
 
 
 
 
83
84
85
...
107
108
109
 
 
 
 
 
 
 
 
 
 
 
 
 
110
111
112
...
120
121
122
123
 
124
125
126
127
128
129
130
131
 
 
 
132
 
 
 
 
 
 
 
 
 
 
133
134
135
136
137
 
 
 
 
 
 
 
138
139
140
141
142
143
144
145
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
147
148
149
150
151
 
152
153
154
155
156
 
 
157
158
159
...
163
164
165
166
 
167
 
168
169
170
...
172
173
174
 
 
 
 
175
176
 
177
178
179
180
 
181
182
183
...
191
192
193
194
195
196
 
197
198
 
199
200
201
...
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
...
32
33
34
35
36
37
38
39
40
41
42
43
 
44
45
46
47
...
53
54
55
56
57
58
59
60
61
62
63
64
...
67
68
69
70
71
72
73
74
 
75
76
 
 
77
78
79
80
81
...
95
96
97
 
98
99
100
101
102
103
104
105
106
...
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
...
154
155
156
 
157
158
159
160
161
162
 
 
 
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
 
 
 
 
178
179
180
181
182
183
184
185
186
187
188
189
 
 
 
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
...
247
248
249
 
250
251
252
253
254
255
...
257
258
259
260
261
262
263
264
 
265
266
267
268
269
270
271
272
273
...
281
282
283
 
 
 
284
285
 
286
287
288
289
0
@@ -13,12 +13,15 @@
0
 #include <clutter-gtk/gtk-clutter-embed.h>
0
 
0
 #include <tidy/tidy-finger-scroll.h>
0
+#include <tidy/tidy-stylable.h>
0
 
0
 #include <twitter-glib/twitter-glib.h>
0
 
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
 
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
   GtkWidget *entry;
0
   GtkWidget *canvas;
0
 
0
+ ClutterEffectTemplate *spin_tmpl;
0
+
0
+ ClutterActor *spinner;
0
+ ClutterActor *status_view;
0
+ ClutterActor *scroll;
0
+
0
   TwitterClient *client;
0
 
0
   TweetConfig *config;
0
- TweetStatusModel *model;
0
+ TweetStatusModel *status_model;
0
 
0
   guint refresh_id;
0
 };
0
@@ -44,6 +53,12 @@ tweet_window_dispose (GObject *gobject)
0
 {
0
   TweetWindowPrivate *priv = TWEET_WINDOW (gobject)->priv;
0
 
0
+ if (priv->spin_tmpl)
0
+ {
0
+ g_object_unref (priv->spin_tmpl);
0
+ priv->spin_tmpl = NULL;
0
+ }
0
+
0
   if (priv->refresh_id)
0
     {
0
       g_source_remove (priv->refresh_id);
0
@@ -52,14 +67,15 @@ tweet_window_dispose (GObject *gobject)
0
 
0
   if (priv->client)
0
     {
0
+ twitter_client_end_session (priv->client);
0
       g_object_unref (priv->client);
0
       priv->client = NULL;
0
     }
0
 
0
- if (priv->model)
0
+ if (priv->status_model)
0
     {
0
- g_object_unref (priv->model);
0
- priv->model = NULL;
0
+ g_object_unref (priv->status_model);
0
+ priv->status_model = NULL;
0
     }
0
 
0
   G_OBJECT_CLASS (tweet_window_parent_class)->dispose (gobject);
0
@@ -79,7 +95,12 @@ on_status_received (TwitterClient *client,
0
       return;
0
     }
0
 
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
+ NULL);
0
+
0
+ tweet_status_model_append_status (window->priv->status_model, status);
0
 }
0
 
0
 static void
0
@@ -107,6 +128,19 @@ static gboolean
0
 refresh_timeout (gpointer data)
0
 {
0
   TweetWindow *window = data;
0
+ TweetWindowPrivate *priv = window->priv;
0
+
0
+ tidy_list_view_set_model (TIDY_LIST_VIEW (priv->status_view), NULL);
0
+ g_object_unref (priv->status_model);
0
+
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
+
0
+ clutter_actor_show (window->priv->spinner);
0
+ clutter_effect_fade (window->priv->spin_tmpl, window->priv->spinner, 255,
0
+ NULL, NULL);
0
+ tweet_spinner_start (TWEET_SPINNER (window->priv->spinner));
0
 
0
   twitter_client_get_user_timeline (window->priv->client, NULL, 0, NULL);
0
 
0
@@ -120,40 +154,90 @@ tweet_window_constructed (GObject *gobject)
0
   TweetWindowPrivate *priv = window->priv;
0
   ClutterActor *stage;
0
   ClutterActor *view;
0
- ClutterActor *scroll;
0
+ ClutterActor *img;
0
   ClutterColor stage_color = { 0, 0, 0, 255 };
0
 
0
   stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->canvas));
0
   clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
0
 
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
+
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
+
0
+ img = tweet_texture_new_from_stock (GTK_WIDGET (window),
0
+ GTK_STOCK_REFRESH,
0
+ GTK_ICON_SIZE_LARGE_TOOLBAR);
0
 
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
 
0
   clutter_actor_show (stage);
0
   gtk_widget_show (GTK_WIDGET (window));
0
 
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
- refresh_timeout,
0
- window);
0
+
0
+#if 0
0
+ priv->refresh_id =
0
+ g_timeout_add_seconds (tweet_config_get_refresh_time (priv->config),
0
+ refresh_timeout,
0
+ window);
0
+#endif
0
+}
0
+
0
+static void
0
+tweet_window_style_set (GtkWidget *widget,
0
+ GtkStyle *old_style)
0
+{
0
+ TweetWindowPrivate *priv = TWEET_WINDOW (widget)->priv;
0
+ ClutterColor active_color = { 0, };
0
+ ClutterColor text_color = { 0, };
0
+ ClutterColor bg_color = { 0, };
0
+ gchar *font_name;
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
+
0
+ font_name = pango_font_description_to_string (widget->style->font_desc);
0
+
0
+ tidy_stylable_set (TIDY_STYLABLE (priv->scroll),
0
+ "active-color", &active_color,
0
+ "bg-color", &bg_color,
0
+ NULL);
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
+ NULL);
0
+
0
+ g_free (font_name);
0
 }
0
 
0
 static void
0
 tweet_window_class_init (TweetWindowClass *klass)
0
 {
0
   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
0
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
0
 
0
   g_type_class_add_private (klass, sizeof (TweetWindowPrivate));
0
 
0
   gobject_class->dispose = tweet_window_dispose;
0
   gobject_class->constructed = tweet_window_constructed;
0
+
0
+ widget_class->style_set = tweet_window_style_set;
0
 }
0
 
0
 static void
0
@@ -163,8 +247,9 @@ tweet_window_init (TweetWindow *window)
0
   GtkWidget *hbox, *button;
0
 
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
 
0
   window->priv = priv = TWEET_WINDOW_GET_PRIVATE (window);
0
 
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
 
0
+ priv->canvas = gtk_clutter_embed_new ();
0
+ gtk_container_add (GTK_CONTAINER (priv->vbox), priv->canvas);
0
+ gtk_widget_show (priv->canvas);
0
+
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
 
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
 
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
 
0
- priv->model = TWEET_STATUS_MODEL (tweet_status_model_new ());
0
+ priv->status_model = TWEET_STATUS_MODEL (tweet_status_model_new ());
0
 
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.