Fix previous commit
[debian/pino.git] / src / favorites_view_dialog.vala
1 /* favorites_view_dialog.vala
2  *
3  * Copyright (C) 2009-2010  troorl
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  *
18  * Author:
19  *      troorl <troorl@gmail.com>
20  */
21
22 using Gtk;
23 using Auth;
24 using RestAPI;
25
26 /* view conversation from bottom to top one */
27 public class FavoritesViewDialog : Dialog {
28         
29         private Image img;
30         private Button more_btn;
31         private FavoritesViewList view;
32         
33         public FavoritesViewDialog(Window parent, Accounts _accounts, Template template) {
34                 set_transient_for(parent);
35                 
36                 set_title(_("Favorites"));
37                 modal = true;
38                 has_separator = true;
39                 set_size_request(400, 500);
40                 
41                 Gdk.PixbufAnimation anima = new Gdk.PixbufAnimation.from_file(Config.PROGRESS_PATH);
42                 img = new Image();
43                 img.set_from_animation(anima);
44                 
45                 view = new FavoritesViewList(this, _accounts, template);
46                 vbox.pack_start(view, true, true, 0);
47                 
48                 var vb = new VBox(false, 0);
49                 vb.pack_end(img, false, false, 5);
50                 
51                 add_action_widget(vb, -1);
52                 more_btn = (Button) add_button(_("More"), 9000);
53                 add_button(STOCK_CLOSE, ResponseType.CLOSE);
54                 response.connect(response_act);
55                 
56                 var p_parent = (MainWindow)parent;
57                 signals_setup(p_parent, view);
58                 
59                 show_all();
60                 
61                 view.update();
62                 
63                 img.set_from_stock("gtk-apply", Gtk.IconSize.MENU);
64         }
65         
66         private void signals_setup(MainWindow p_parent, FavoritesViewList view) {
67                 view.nickto.connect((screen_name) => {
68                         p_parent.re_tweet.set_nickto(screen_name);
69                 });
70                 view.retweet.connect((status) => {
71                         p_parent.re_tweet.set_state_retweet(status);
72                 });
73                 view.directreply.connect((screen_name) => {
74                         p_parent.re_tweet.set_state_directreply(screen_name);
75                 });
76                 view.replyto.connect((status) => {
77                         p_parent.re_tweet.set_state_reply(status);
78                 });
79                 view.deleted.connect((msg) => {
80                         p_parent.statusbar.set_status(StatusbarSmart.StatusType.DATA_SENT, msg);
81                 });
82                 view.user_info.connect((screen_name) => {
83                         p_parent.user_info.show_user(screen_name);
84                 });
85         }
86         
87         private void response_act(int resp_id) {
88                 switch(resp_id) {
89                         case ResponseType.CLOSE:
90                                 close();
91                                 break;
92                         
93                         case 9000:
94                                 more_btn.set_sensitive(false);
95                                 Gdk.PixbufAnimation anima = new Gdk.PixbufAnimation.from_file(Config.PROGRESS_PATH);
96                                 img.set_from_animation(anima);
97                                 
98                                 view.get_older_public();
99                                 
100                                 more_btn.set_sensitive(true);
101                                 img.set_from_stock("gtk-apply", Gtk.IconSize.MENU);
102                                 break;
103                 }
104         }
105 }