Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultiTerm: Add support for GTK3 #95

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
12 changes: 12 additions & 0 deletions multiterm/src/notebook.vala
Expand Up @@ -118,9 +118,13 @@ namespace MultiTerm
private void on_add_button_style_set()
{
int w, h;
#if MULTITERM_GTK3
Gtk.icon_size_lookup(IconSize.MENU, out w, out h);
#else
Gtk.icon_size_lookup_for_settings(add_button.get_settings(),
IconSize.MENU,
out w, out h);
#endif
add_button.set_size_request(w+2, h+2);
}

Expand Down Expand Up @@ -149,7 +153,11 @@ namespace MultiTerm
context_menu.new_window_activate.connect(on_new_window_activate);
context_menu.move_to_location_activate.connect(on_move_to_location);
}
#if MULTITERM_GTK3
context_menu.popup_at_pointer(event);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This requires GTK+ 3.22 but I think the build system only checks for GTK+ >= 3.0, so if someone built it with any version of GTK+ between 3.0 and 3.22, it would cause a build error.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I use normal gtk C-style version checks in valac?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for compile-time versions (ie. GTK_CHECK_VERSION macros), Vala's preprocessor is too wimpy. You can pass along a macro from the build system using -D option if it's really needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I tried defining something like MULTITERM_GTK_3_22 but failed at changing the makefiles properly. So I leave this as is for now.

#else
context_menu.popup(null, null, null, event.button, event.time);
#endif
return true;
}

Expand Down Expand Up @@ -190,7 +198,11 @@ namespace MultiTerm
style.xthickness = 0;
style.ythickness = 0;

#if MULTITERM_GTK3
img = new Image.from_icon_name("list-add", IconSize.MENU);
#else
img = new Gtk.Image.from_stock(Gtk.Stock.ADD, Gtk.IconSize.MENU);
#endif

add_button = new Button();
add_button.modify_style(style);
Expand Down
10 changes: 9 additions & 1 deletion multiterm/src/tab-label.vala
Expand Up @@ -53,9 +53,13 @@ namespace MultiTerm
private void on_button_style_set(Gtk.Style? previous_style)
{
int w, h;
#if MULTITERM_GTK3
Gtk.icon_size_lookup(IconSize.MENU, out w, out h);
#else
Gtk.icon_size_lookup_for_settings(btn.get_settings(),
IconSize.MENU,
out w, out h);
out w, out h);
#endif
btn.set_size_request(w+2, h+2);
}

Expand All @@ -72,7 +76,11 @@ namespace MultiTerm

this.pack_start(label, true, true, 0);

#if MULTITERM_GTK3
img = new Image.from_icon_name("window-close", IconSize.MENU);
#else
img = new Image.from_stock(Gtk.Stock.CLOSE, IconSize.MENU);
#endif

RcStyle style = new RcStyle();
style.xthickness = 0;
Expand Down