public
Description: A Clutter-based Twitter client
Homepage: http://live.gnome.org/Tweet
Clone URL: git://github.com/ebassi/tweet.git
Dynamically size the TweetCanvas on resize

When resizing the TweetWindow, propagate the changes to the contents
of the canvas, namely: the  FingerScroll and the ListView.

Also, use the canvas size requisition to position the items the first
time they are laid out.
Emmanuele Bassi (author)
Thu Jun 26 00:59:54 -0700 2008
commit  177a30a2af78767007b8aa0d5dd001412fe46ff5
tree    734019965166c183ae556e513637b664476b11ca
parent  6f10f44ca16265120ab345e592a77929b3e01876
...
43
44
45
 
46
47
48
...
1112
1113
1114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1115
1116
1117
...
1193
1194
1195
 
1196
1197
1198
1199
1200
1201
...
1257
1258
1259
1260
 
 
 
1261
1262
1263
1264
1265
1266
1267
 
 
 
1268
1269
1270
1271
 
1272
1273
 
 
1274
1275
1276
1277
1278
1279
1280
1281
 
 
1282
1283
1284
...
1293
1294
1295
1296
 
1297
1298
1299
...
43
44
45
46
47
48
49
...
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
...
1212
1213
1214
1215
1216
1217
 
1218
1219
1220
...
1276
1277
1278
 
1279
1280
1281
1282
1283
1284
1285
1286
1287
 
1288
1289
1290
1291
 
 
 
1292
1293
1294
1295
1296
1297
 
 
 
1298
1299
 
 
1300
1301
1302
1303
1304
...
1313
1314
1315
 
1316
1317
1318
1319
0
@@ -43,6 +43,7 @@
0
 #include <twitter-glib/twitter-glib.h>
0
 
0
 #include "tweet-animation.h"
0
+#include "tweet-canvas.h"
0
 #include "tweet-config.h"
0
 #include "tweet-preferences.h"
0
 #include "tweet-spinner.h"
0
@@ -1112,6 +1113,24 @@ on_canvas_focus_out (GtkWidget *widget,
0
   return FALSE;
0
 }
0
 
0
+static void
0
+on_canvas_size_allocate (GtkWidget *widget,
0
+ GtkAllocation *allocation,
0
+ TweetWindow *window)
0
+{
0
+ TweetWindowPrivate *priv = window->priv;
0
+
0
+ if (!priv->scroll)
0
+ return;
0
+
0
+ clutter_actor_set_size (priv->scroll,
0
+ allocation->width,
0
+ allocation->height);
0
+ clutter_actor_set_size (priv->status_view,
0
+ allocation->width,
0
+ allocation->height);
0
+}
0
+
0
 static gboolean
0
 tweet_window_focus_in (GtkWidget *widget,
0
                        GdkEventFocus *event)
0
@@ -1193,9 +1212,9 @@ tweet_window_init (TweetWindow *window)
0
   GError *error;
0
   ClutterActor *stage, *view;
0
   ClutterColor stage_color = { 0, 0, 0, 255 };
0
+ GtkRequisition canvas_req = { 0, };
0
 
0
   GTK_WINDOW (window)->type = GTK_WINDOW_TOPLEVEL;
0
- gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
0
   gtk_window_set_default_size (GTK_WINDOW (window), WINDOW_WIDTH, 600);
0
   gtk_window_set_title (GTK_WINDOW (window), "Tweet");
0
 
0
@@ -1257,28 +1276,29 @@ tweet_window_init (TweetWindow *window)
0
   gtk_container_add (GTK_CONTAINER (priv->vbox), frame);
0
   gtk_widget_show (frame);
0
 
0
- priv->canvas = gtk_clutter_embed_new ();
0
+ priv->canvas = tweet_canvas_new ();
0
+ tweet_canvas_set_border_width (TWEET_CANVAS (priv->canvas), CANVAS_PADDING);
0
+
0
   g_signal_connect (priv->canvas,
0
                     "focus-in-event", G_CALLBACK (on_canvas_focus_in),
0
                     window);
0
   g_signal_connect (priv->canvas,
0
                     "focus-out-event", G_CALLBACK (on_canvas_focus_out),
0
                     window);
0
- GTK_WIDGET_SET_FLAGS (priv->canvas, GTK_CAN_FOCUS);
0
+ g_signal_connect (priv->canvas,
0
+ "size-allocate", G_CALLBACK (on_canvas_size_allocate),
0
+ window);
0
 
0
- gtk_widget_set_size_request (priv->canvas,
0
- CANVAS_WIDTH + CANVAS_PADDING,
0
- CANVAS_HEIGHT + CANVAS_PADDING);
0
+ GTK_WIDGET_SET_FLAGS (priv->canvas, GTK_CAN_FOCUS);
0
   gtk_container_add (GTK_CONTAINER (frame), priv->canvas);
0
 
0
+ gtk_widget_size_request (priv->canvas, &canvas_req);
0
+
0
   stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->canvas));
0
- gtk_widget_set_size_request (priv->canvas,
0
- CANVAS_WIDTH + CANVAS_PADDING,
0
- CANVAS_HEIGHT + CANVAS_PADDING);
0
   clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
0
   clutter_actor_set_size (stage,
0
- CANVAS_WIDTH + CANVAS_PADDING,
0
- CANVAS_HEIGHT + CANVAS_PADDING);
0
+ canvas_req.width + CANVAS_PADDING,
0
+ canvas_req.height + CANVAS_PADDING);
0
 
0
   view = tweet_status_view_new (priv->status_model);
0
   g_signal_connect (view,
0
@@ -1293,7 +1313,7 @@ tweet_window_init (TweetWindow *window)
0
   clutter_actor_set_reactive (view, TRUE);
0
   priv->status_view = view;
0
 
0
- clutter_actor_set_size (priv->scroll, CANVAS_WIDTH, CANVAS_HEIGHT);
0
+ clutter_actor_set_size (priv->scroll, canvas_req.width, canvas_req.height);
0
   clutter_actor_set_position (priv->scroll, CANVAS_PADDING, CANVAS_PADDING);
0
   clutter_container_add_actor (CLUTTER_CONTAINER (stage), priv->scroll);
0
   clutter_actor_set_reactive (priv->scroll, TRUE);

Comments

    No one has commented yet.