~ubuntu-branches/ubuntu/precise/gwibber/precise-proposed

« back to all changes in this revision

Viewing changes to libgwibber-gtk/action-box.vala

  • Committer: Package Import Robot
  • Author(s): Ken VanDine
  • Date: 2012-01-30 10:55:24 UTC
  • mto: This revision was merged to the branch mainline in revision 114.
  • Revision ID: package-import@ubuntu.com-20120130105524-87s04jfxw7bery0n
Tags: upstream-3.3.3
ImportĀ upstreamĀ versionĀ 3.3.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
namespace GwibberGtk
20
20
{
21
 
public class ActionBox : Gtk.HBox
 
21
public class ActionBox : Gtk.Box
22
22
{
23
23
  /*
24
24
  private ActionBoxItem? _item = null;
43
43
 
44
44
  public ActionBox ()
45
45
  {
46
 
    Object ();
 
46
    Object (homogeneous:false, spacing:0);
47
47
  }
48
48
 
49
49
  construct
50
50
  {
 
51
    set_orientation (Gtk.Orientation.HORIZONTAL);
51
52
  }
52
53
}
53
54
 
64
65
  private Gtk.Image _image;
65
66
  private string _icon;
66
67
  private string _scalable_icon;
67
 
  private Gtk.Menu? menu;
68
 
  private Gtk.MenuItem? amenu;
 
68
  private Gtk.Menu? _menu;
 
69
  private Gtk.MenuItem? _amenu;
69
70
 
70
71
  public ActionBoxItem (string service, string stream, string account, string mid, string sender, string tooltip = "")
71
72
  {
74
75
 
75
76
  ~ActionBoxItem ()
76
77
  {
77
 
    _image.destroy ();
78
 
    _image = null;
79
 
    foreach (var _w in menu.get_children ())
80
 
    {
81
 
      menu.remove (_w);
82
 
      _w.destroy ();
83
 
      _w = null;
84
 
    }
85
 
    menu.destroy ();
86
 
    menu = null;
 
78
    if (_image is Gtk.Widget)
 
79
      _image.destroy ();
 
80
    if (_menu is Gtk.Widget)
 
81
      _menu.destroy ();
 
82
    if (_amenu is Gtk.Widget)
 
83
      _amenu.destroy ();
87
84
  }
88
85
 
89
86
  construct
103
100
    _image.set_no_show_all (false);
104
101
    _image.tooltip_text = tooltip;
105
102
    add (_image);
106
 
    menu = build_menu ();
 
103
    _menu = build_menu ();
107
104
    if (get_parent() is Gtk.Widget)
108
 
      reparent (menu);
109
 
    else
110
 
      menu.attach_to_widget (this, null);
 
105
      reparent (_menu);
111
106
 
112
107
    button_press_event.connect((event) => {
113
 
      if (menu.get_children ().length () > 0)
114
 
        menu.popup (null, null, null, event.button, event.time);
 
108
      if (_menu.get_children ().length () > 0)
 
109
        _menu.popup (null, null, null, event.button, event.time);
115
110
      return true;
116
111
    });
117
112
 
143
138
 
144
139
  private Gtk.Menu build_menu ()
145
140
  {
146
 
    menu = new Gtk.Menu ();
 
141
    _menu = new Gtk.Menu ();
147
142
 
148
143
    if (service != "flicker" && service != "pingfm" && service != "foursquare" && service != "digg")
149
144
    {
150
 
      amenu = new Gtk.MenuItem.with_mnemonic (_("_Reply"));
151
 
      amenu.activate.connect(() => {
 
145
      _amenu = new Gtk.MenuItem.with_mnemonic (_("_Reply"));
 
146
      _amenu.activate.connect(() => {
152
147
        string nick = "";
153
148
        Json.Object obj = null;
154
149
        Json.Object sender_obj = null;
181
176
          nick = "@" + nick;
182
177
        reply (mid, account, nick);
183
178
      });
184
 
      menu.append(amenu);
 
179
      _menu.append(_amenu);
185
180
    }
186
181
 
187
182
    if (service != "flicker" && service != "pingfm" && service != "foursquare" && service != "digg" && service != "qaiku" && service != "buzz" && stream != "private")
188
183
    {
189
 
      amenu = new Gtk.MenuItem.with_mnemonic (_("_Like"));
190
 
      amenu.activate.connect(() => {
 
184
      _amenu = new Gtk.MenuItem.with_mnemonic (_("_Like"));
 
185
      _amenu.activate.connect(() => {
191
186
        var ret = like (mid, account);
192
187
        if (ret) {
193
188
          string name = "";
228
223
          notification.show ();
229
224
        }
230
225
      });
231
 
      menu.append(amenu);
 
226
      _menu.append(_amenu);
232
227
    }
233
228
 
234
229
    if ((service == "twitter" || service == "identica" || service == "statusnet" || service == "sina" || service == "sohu") && stream != "private")
235
230
    {
236
 
      amenu = new Gtk.MenuItem ();
 
231
      _amenu = new Gtk.MenuItem ();
237
232
      if (service == "twitter")
238
233
      {
239
 
        amenu = new Gtk.MenuItem.with_mnemonic (_("Re_tweet"));
 
234
        _amenu = new Gtk.MenuItem.with_mnemonic (_("Re_tweet"));
240
235
      }
241
236
      if (service == "identica" || service == "statusnet")
242
237
      {
243
 
        amenu = new Gtk.MenuItem.with_mnemonic (_("Re_peat"));
 
238
        _amenu = new Gtk.MenuItem.with_mnemonic (_("Re_peat"));
244
239
      }
245
 
      amenu.activate.connect(() => {
 
240
      _amenu.activate.connect(() => {
246
241
        var ret = share (mid, account);
247
242
        if (ret) {
248
243
          var notification = new Notify.Notification (_("Shared"), _("Shared post from %s").printf (sender), _scalable_icon);
249
244
          notification.show ();
250
245
        }
251
246
      });
252
 
      menu.append(amenu);
 
247
      _menu.append(_amenu);
253
248
    }
254
249
 
255
250
    if ((service == "twitter" || service == "identica" || service == "statusnet") && stream != "user")
256
251
    {
257
 
      amenu = new Gtk.MenuItem.with_mnemonic (_("View User _Profile"));
258
 
      amenu.activate.connect(() => {
 
252
      _amenu = new Gtk.MenuItem.with_mnemonic (_("View User _Profile"));
 
253
      _amenu.activate.connect(() => {
259
254
        user_stream (account, sender);
260
255
      });
261
 
      menu.append(amenu);
 
256
      _menu.append(_amenu);
262
257
    }
263
258
 
264
 
    menu.show_all ();
265
 
    return menu;
 
259
    _menu.show_all ();
 
260
    return _menu;
266
261
  }
267
262
}
268
263
}