0
+#include <glib-object.h>
0
+#include <clutter/clutter.h>
0
+#include <clutter-gtk/gtk-clutter-embed.h>
0
+#include <twitter-glib/twitter-glib.h>
0
+#include "tweet-config.h"
0
+#include "tweet-status-model.h"
0
+#include "tweet-status-view.h"
0
+#include "tweet-window.h"
0
+#define TWEET_WINDOW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TWEET_TYPE_WINDOW, TweetWindowPrivate))
0
+struct _TweetWindowPrivate
0
+ TwitterClient *client;
0
+ TweetStatusModel *model;
0
+G_DEFINE_TYPE (TweetWindow, tweet_window, GTK_TYPE_WINDOW);
0
+tweet_window_dispose (GObject *gobject)
0
+ TweetWindowPrivate *priv = TWEET_WINDOW (gobject)->priv;
0
+ g_object_unref (priv->client);
0
+ g_object_unref (priv->model);
0
+ G_OBJECT_CLASS (tweet_window_parent_class)->dispose (gobject);
0
+on_status_received (TwitterClient *client,
0
+ TwitterStatus *status,
0
+ TweetWindow *window = user_data;
0
+ g_warning ("Unable to retrieve status from Twitter: %s", error->message);
0
+ g_print ("Received status [%u] from user %s\n",
0
+ twitter_status_get_id (status),
0
+ twitter_user_get_screen_name (twitter_status_get_user (status)));
0
+ tweet_status_model_append_status (window->priv->model, status);
0
+tweet_window_constructed (GObject *gobject)
0
+ TweetWindow *window = TWEET_WINDOW (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
+ clutter_actor_show (view);
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
+ clutter_actor_show (stage);
0
+ gtk_widget_show (GTK_WIDGET (window));
0
+ twitter_client_get_user_timeline (priv->client, NULL, 0, NULL);
0
+tweet_window_class_init (TweetWindowClass *klass)
0
+ GObjectClass *gobject_class = G_OBJECT_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
+tweet_window_init (TweetWindow *window)
0
+ TweetWindowPrivate *priv;
0
+ GTK_WINDOW (window)->type = GTK_WINDOW_TOPLEVEL;
0
+ gtk_window_set_default_size (GTK_WINDOW (window), 364, 500);
0
+ gtk_window_set_title (GTK_WINDOW (window), "Tweet");
0
+ g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
0
+ window->priv = priv = TWEET_WINDOW_GET_PRIVATE (window);
0
+ priv->canvas = gtk_clutter_embed_new ();
0
+ gtk_container_add (GTK_CONTAINER (window), priv->canvas);
0
+ gtk_widget_show (priv->canvas);
0
+ priv->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),
0
+ tweet_config_get_password (priv->config));
0
+ g_signal_connect (priv->client,
0
+ "status-received", G_CALLBACK (on_status_received),
0
+tweet_window_new (void)
0
+ return g_object_new (TWEET_TYPE_WINDOW, NULL);
Comments
No one has commented yet.