Skip to content
Browse files

updated for gnome 3.10. don't expect it to compile with old versions …

…of Gtk.
  • Loading branch information...
1 parent befaadb commit b44740149a67643d134885f28855d8757f57231b @ivonunes ivonunes committed Sep 12, 2013
View
2 src/API.vala
@@ -58,7 +58,7 @@ namespace Birdie {
public abstract int auth ();
public abstract int64 update (string status, string id = "");
public abstract int64 update_with_media (string status,
- string id = "", string media_uri, out string media_out);
+ string id, string media_uri, out string media_out);
public abstract int destroy (string id);
public abstract int destroy_dm (string id);
public abstract int retweet (string id);
View
59 src/Birdie.vala
@@ -144,7 +144,7 @@ namespace Birdie {
}
#else
private Gtk.Entry search_entry;
- private Gtk.MenuToolButton appmenu;
+ private Gtk.MenuButton appmenu;
#endif
public Birdie () {
@@ -193,10 +193,7 @@ namespace Birdie {
this.update_interval = settings.get_int ("update-interval");
this.limit_notifications = settings.get_int ("limit-notifications");
- if (this.legacy_window)
- this.m_window = new Widgets.UnifiedWindow ("Birdie", true);
- else
- this.m_window = new Widgets.UnifiedWindow ();
+ this.m_window = new Widgets.UnifiedWindow ();
this.m_window.set_default_size (355, 500);
this.m_window.set_size_request (355, 50);
@@ -224,9 +221,6 @@ namespace Birdie {
this.unread_mentions = 0;
this.unread_dm = 0;
- if (this.tweet_notification || this.mention_notification || this.dm_notification)
- this.m_window.hide_on_delete ();
-
this.new_tweet = new Gtk.ToolButton (new Gtk.Image.from_icon_name ("mail-message-new", Gtk.IconSize.LARGE_TOOLBAR), _("New Tweet"));
new_tweet.set_tooltip_text (_("New Tweet"));
@@ -241,38 +235,31 @@ namespace Birdie {
});
new_tweet.set_sensitive (false);
- this.m_window.add_bar (new_tweet);
-
- var left_sep = new Gtk.SeparatorToolItem ();
- left_sep.draw = false;
- left_sep.set_expand (true);
- this.m_window.add_bar (left_sep);
+ this.m_window.header.pack_start (new_tweet);
+
+ Gtk.Box centered_toolbar = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
+
this.home = new Gtk.ToggleToolButton ();
-
this.home.set_icon_widget (new Gtk.Image.from_icon_name ("twitter-home", Gtk.IconSize.LARGE_TOOLBAR));
-
home.set_tooltip_text (_("Home"));
home.set_label (_("Home"));
-
home.toggled.connect (() => {
if (!this.changing_tab)
this.switch_timeline ("home");
});
this.home.set_sensitive (false);
- this.m_window.add_bar (home);
+ centered_toolbar.add (home);
this.mentions = new Gtk.ToggleToolButton ();
this.mentions.set_icon_widget (new Gtk.Image.from_icon_name ("twitter-mentions", Gtk.IconSize.LARGE_TOOLBAR));
mentions.set_tooltip_text (_("Mentions"));
mentions.set_label (_("Mentions"));
-
mentions.toggled.connect (() => {
if (!this.changing_tab)
this.switch_timeline ("mentions");
});
-
this.mentions.set_sensitive (false);
- this.m_window.add_bar (mentions);
+ centered_toolbar.add (mentions);
this.dm = new Gtk.ToggleToolButton ();
this.dm.set_icon_widget (new Gtk.Image.from_icon_name ("twitter-dm", Gtk.IconSize.LARGE_TOOLBAR));
@@ -283,7 +270,7 @@ namespace Birdie {
this.switch_timeline ("dm");
});
this.dm.set_sensitive (false);
- this.m_window.add_bar (dm);
+ centered_toolbar.add (dm);
this.profile = new Gtk.ToggleToolButton ();
this.profile.set_icon_widget (new Gtk.Image.from_icon_name ("twitter-profile", Gtk.IconSize.LARGE_TOOLBAR));
@@ -295,7 +282,7 @@ namespace Birdie {
this.switch_timeline ("own");
});
this.profile.set_sensitive (false);
- this.m_window.add_bar (profile);
+ centered_toolbar.add (profile);
this.search = new Gtk.ToggleToolButton ();
this.search.set_icon_widget (new Gtk.Image.from_icon_name ("twitter-search", Gtk.IconSize.LARGE_TOOLBAR));
@@ -307,12 +294,9 @@ namespace Birdie {
this.switch_timeline ("search");
});
this.search.set_sensitive (false);
- this.m_window.add_bar (search);
-
- var right_sep = new Gtk.SeparatorToolItem ();
- right_sep.draw = false;
- right_sep.set_expand (true);
- this.m_window.add_bar (right_sep);
+ centered_toolbar.add (search);
+
+ this.m_window.header.set_custom_title (centered_toolbar);
menu = new Widgets.MenuPopOver ();
this.account_appmenu = new Gtk.MenuItem.with_label (_("Add Account"));
@@ -331,7 +315,7 @@ namespace Birdie {
if (response == Gtk.ResponseType.OK) {
var appmenu_icon = new Gtk.Image.from_icon_name ("application-menu", Gtk.IconSize.MENU);
appmenu_icon.show ();
- this.appmenu.set_icon_widget (appmenu_icon);
+ this.appmenu.child = appmenu_icon;
this.set_widgets_sensitive (false);
this.db.remove_account (this.default_account);
User account = this.db.get_default_account ();
@@ -415,11 +399,12 @@ namespace Birdie {
this.appmenu = new Granite.Widgets.ToolButtonWithMenu (new Gtk.Image.from_icon_name ("application-menu", Gtk.IconSize.MENU), _("Menu"), menu);
menu.move_to_widget (appmenu);
#else
- this.appmenu = new Gtk.MenuToolButton (new Gtk.Image.from_icon_name ("application-menu", Gtk.IconSize.MENU), _("Menu"));
- this.appmenu.set_menu (menu);
+ this.appmenu = new Gtk.MenuButton ();
+ this.appmenu.set_relief (Gtk.ReliefStyle.NONE);
+ this.appmenu.set_popup (menu);
#endif
- this.m_window.add_bar (appmenu);
+ this.m_window.header.pack_end (appmenu);
/*========== tweets lists ==========*/
@@ -654,7 +639,7 @@ namespace Birdie {
Idle.add (() => {
var appmenu_icon = new Gtk.Image.from_icon_name ("application-menu", Gtk.IconSize.MENU);
appmenu_icon.show ();
- this.appmenu.set_icon_widget (appmenu_icon);
+ this.appmenu.child = appmenu_icon;
this.set_widgets_sensitive (false);
return false;
});
@@ -821,7 +806,7 @@ namespace Birdie {
Gtk.Image avatar_image = new Gtk.Image.from_pixbuf (avatar_pixbuf);
avatar_image.show ();
- this.appmenu.set_icon_widget (avatar_image);
+ this.appmenu.child = avatar_image;
Gtk.Image avatar_image_menu = new Gtk.Image.from_file (Environment.get_home_dir () +
"/.local/share/birdie/avatars/" + account.profile_image_file);
@@ -850,7 +835,7 @@ namespace Birdie {
private void switch_account (User account) {
var appmenu_icon = new Gtk.Image.from_icon_name ("application-menu", Gtk.IconSize.MENU);
appmenu_icon.show ();
- this.appmenu.set_icon_widget (appmenu_icon);
+ this.appmenu.child = appmenu_icon;
this.search_list.clear ();
this.search_entry.text = "";
@@ -1360,7 +1345,7 @@ namespace Birdie {
*/
- public void tweet_callback (string text, string id = "",
+ public void tweet_callback (string text, string id,
string user_screen_name, bool dm, string media_uri) {
int64 code;
View
2 src/Twitter.vala
@@ -124,7 +124,7 @@ namespace Birdie {
}
public override int64 update_with_media (string status,
- string id = "", string media_uri, out string media_out) {
+ string id, string media_uri, out string media_out) {
string? link;
var imgur = new Imgur ();
View
4 src/Utils/StatusIcon.vala
@@ -47,7 +47,7 @@ namespace Birdie.Utils {
traymenu.append (menu_sep1);
/* Quit */
- var menu_quit = new Gtk.ImageMenuItem.from_stock (Gtk.Stock.QUIT, null);
+ var menu_quit = new Gtk.ImageMenuItem.with_label (_("Quit"));
menu_quit.activate.connect (exit);
traymenu.append (menu_quit);
@@ -82,4 +82,4 @@ namespace Birdie.Utils {
}
}
}
-}
+}
View
4 src/Widgets/Dialogs.vala
@@ -47,14 +47,14 @@ namespace Birdie.Widgets
public ConfirmationDialog (Gtk.Window? parent,
string primary, string? ok_button) {
base (parent, Gtk.MessageType.WARNING, primary,
- ok_button, Gtk.Stock.CANCEL);
+ ok_button, _("Cancel"));
}
}
class ErrorDialog : AlertDialog {
public ErrorDialog (Gtk.Window? parent,
string primary, string? secondary) {
- base (parent, Gtk.MessageType.ERROR, primary, Gtk.Stock.OK, null);
+ base (parent, Gtk.MessageType.ERROR, primary, _("OK"), null);
}
}
View
4 src/Widgets/MoreButton.vala
@@ -20,9 +20,9 @@ public class MoreButton : Gtk.Box {
public MoreButton () {
GLib.Object (orientation: Gtk.Orientation.HORIZONTAL, valign: Gtk.Align.START);
- button = new Gtk.ToolButton.from_stock (Gtk.Stock.GO_DOWN);
+ button = new Gtk.ToolButton (new Gtk.Image.from_icon_name ("go-down", Gtk.IconSize.LARGE_TOOLBAR), _("Get older entries"));
button.set_tooltip_text (_("Get older entries"));
button.set_size_request (40, 40);
this.pack_start(button, true, true, 0);
}
-}
+}
View
4 src/Widgets/TweetDialog.vala
@@ -233,8 +233,8 @@ namespace Birdie.Widgets {
private void on_add_photo_clicked () {
this.file_chooser = new Gtk.FileChooserDialog (_("Select a Picture"), this,
Gtk.FileChooserAction.OPEN,
- Gtk.Stock.CANCEL, Gtk.ResponseType.CANCEL,
- Gtk.Stock.OPEN, Gtk.ResponseType.ACCEPT);
+ new Gtk.Button.with_label (_("Cancel")), Gtk.ResponseType.CANCEL,
+ new Gtk.Button.with_label (_("Open")), Gtk.ResponseType.ACCEPT);
// filter to jpg, png and gif:
Gtk.FileFilter filter = new Gtk.FileFilter ();
View
153 src/Widgets/UnifiedWindow.vala
@@ -17,44 +17,14 @@
namespace Birdie.Widgets {
public class UnifiedWindow : Gtk.Window
{
- private bool hide_on_delete_enabled;
- private bool legacy;
-
- Gtk.Box container;
- Gtk.Toolbar toolbar;
- Gtk.ToolItem label;
-
- const int HEIGHT = 48;
- const int ICON_SIZE = Gtk.IconSize.LARGE_TOOLBAR;
- /*const string CSS = """
- .title {
- color: #666;
- text-shadow: 0 1 0 white;
- }
- .toolbar {
- padding: 0;
- box-shadow: inset 0 1 0 rgba(255,255,255,0.3);
- }
- """;
- Gtk.CssProvider css;*/
-
- Gtk.Label _title;
- public new string title {
- get {
- return _title.label;
- }
- set {
- _title.label = value;
- }
- }
-
public int opening_x;
public int opening_y;
public int window_width;
public int window_height;
+
+ public Gtk.HeaderBar header;
- public UnifiedWindow (string title = "", bool legacy = false) {
- this.legacy = legacy;
+ public UnifiedWindow () {
this.opening_x = -1;
this.opening_y = -1;
this.window_width = -1;
@@ -63,107 +33,20 @@ namespace Birdie.Widgets {
// set smooth scrolling events
set_events(Gdk.EventMask.SMOOTH_SCROLL_MASK);
- /*css = new Gtk.CssProvider ();
- try {
- if (!legacy)
- css.load_from_data (CSS, -1);
- } catch (Error e) { warning (e.message); }*/
-
- toolbar = new Gtk.Toolbar ();
- toolbar.icon_size = ICON_SIZE;
- if (legacy)
- toolbar.get_style_context ().add_class ("primary-toolbar");
- else
- toolbar.get_style_context ().add_class ("titlebar");
- //toolbar.get_style_context ().add_provider (css, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
-
- container = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
- container.pack_start (toolbar, false);
-
- var close = new Gtk.ToolButton (new Gtk.Image.from_file ("/usr/share/themes/elementary/metacity-1/close.svg"), "Close");
- close.height_request = HEIGHT;
- close.width_request = HEIGHT;
- close.clicked.connect (() => on_delete_event ());
-
- this.hide_on_delete_enabled = false;
-
- var maximize = new Gtk.ToolButton (new Gtk.Image.from_file ("/usr/share/themes/elementary/metacity-1/maximize.svg"), "Close");
- maximize.height_request = HEIGHT;
- maximize.width_request = HEIGHT;
- maximize.clicked.connect (() => { get_window ().maximize (); });
-
- _title = new Gtk.Label (title);
- _title.override_font (Pango.FontDescription.from_string ("bold"));
- this.title = title;
-
- if (!legacy)
- toolbar.insert (close, -1);
-
- if (this.title != "" && !legacy) {
- label = new Gtk.ToolItem ();
- label.add (_title);
- label.set_expand (true);
- label.get_style_context ().add_class ("title");
- //label.get_style_context ().add_provider (css, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
- toolbar.insert (create_separator (), -1);
- toolbar.insert (label, -1);
- toolbar.insert (create_separator (), -1);
- toolbar.insert (maximize, -1);
- }
-
- if (legacy) {
- this.set_title (title);
- this.delete_event.connect (on_delete_event);
- }
- base.add (container);
+ this.delete_event.connect (on_delete_event);
+
+ header = new Gtk.HeaderBar ();
+ header.set_show_close_button (true);
+ this.set_titlebar (header);
+ this.set_title ("Birdie");
}
private bool on_delete_event () {
- if (this.hide_on_delete_enabled) {
- this.save_window ();
- base.hide_on_delete ();
- } else {
- destroy ();
- }
+ this.save_window ();
+ base.hide_on_delete ();
return true;
}
- public new void hide_on_delete (bool enable = true) {
- if (enable)
- this.hide_on_delete_enabled = true;
- else
- this.hide_on_delete_enabled = false;
- }
-
- public Gtk.ToolItem create_separator () {
- var sep = new Gtk.ToolItem ();
- sep.height_request = HEIGHT;
- sep.width_request = 1;
- sep.draw.connect ((cr) => {
- cr.move_to (0, 0);
- cr.line_to (0, 60);
- cr.set_line_width (1);
- var grad = new Cairo.Pattern.linear (0, 0, 0, HEIGHT);
- grad.add_color_stop_rgba (0, 0.3, 0.3, 0.3, 0.4);
- grad.add_color_stop_rgba (0.8, 0, 0, 0, 0);
- cr.set_source (grad);
- cr.stroke ();
- return true;
- });
- sep.get_style_context ().add_class ("sep");
- //sep.get_style_context ().add_provider (css, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
-
- return sep;
- }
-
- public override void add (Gtk.Widget widget) {
- container.pack_start (widget);
- }
-
- public override void remove (Gtk.Widget widget) {
- container.remove (widget);
- }
-
public void save_window () {
this.get_position (out opening_x, out opening_y);
this.get_size (out window_width, out window_height);
@@ -178,21 +61,7 @@ namespace Birdie.Widgets {
public override void show () {
base.show ();
- if (!legacy)
- get_window ().set_decorations (Gdk.WMDecoration.BORDER);
this.restore_window ();
}
-
- public void add_bar (Gtk.ToolItem item, bool after_title = false) {
- if (this.title != "" && !legacy) {
- toolbar.insert (item, after_title ? toolbar.get_n_items () - 2 : toolbar.get_item_index (label));
- } else {
- toolbar.insert (item, -1);
- }
- }
-
- public void remove_bar (Gtk.ToolItem item) {
- toolbar.remove (item);
- }
}
}

0 comments on commit b447401

Please sign in to comment.
Something went wrong with that request. Please try again.