Move to GTK+3: Closes #4163

This commit is contained in:
Jim Nelson 2011-09-22 13:11:35 -07:00
parent 4ad276aa9a
commit 0fdc45e4ec
10 changed files with 123 additions and 27 deletions

View file

@ -123,7 +123,7 @@ public class MainWindow : Gtk.Window {
public override bool configure_event(Gdk.EventConfigure event) {
// Get window dimensions.
window_maximized = (window.get_state() == Gdk.WindowState.MAXIMIZED);
window_maximized = (get_window().get_state() == Gdk.WindowState.MAXIMIZED);
if (!window_maximized)
get_size(out window_width, out window_height);

View file

@ -89,36 +89,31 @@ public class MessageListCellRenderer : Gtk.CellRenderer {
height = cell_height;
}
public override void render(Gdk.Window window, Gtk.Widget widget, Gdk.Rectangle background_area,
Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, Gtk.CellRendererState flags) {
Cairo.Context ctx = Gdk.cairo_create(window);
Gdk.cairo_rectangle (ctx, expose_area);
ctx.clip();
public override void render(Cairo.Context ctx, Gtk.Widget widget, Gdk.Rectangle background_area,
Gdk.Rectangle cell_area, Gtk.CellRendererState flags) {
if (data == null)
return;
Pango.Rectangle? ink_rect;
Pango.Rectangle? logical_rect;
int y = LINE_SPACING + expose_area.y;
int y = LINE_SPACING + cell_area.y;
// Date field.
Pango.Layout layout_date = widget.create_pango_layout(null);
layout_date.set_markup(data.date, -1);
layout_date.set_alignment(Pango.Alignment.RIGHT);
layout_date.get_pixel_extents(out ink_rect, out logical_rect);
ctx.move_to(expose_area.width - expose_area.x - ink_rect.width - ink_rect.x - LINE_SPACING, y);
ctx.move_to(cell_area.width - cell_area.x - ink_rect.width - ink_rect.x - LINE_SPACING, y);
Pango.cairo_show_layout(ctx, layout_date);
// From field.
Pango.Layout layout_from = widget.create_pango_layout(null);
layout_from.set_markup(data.from, -1);
layout_from.set_width((expose_area.width - ink_rect.width - ink_rect.x - LINE_SPACING - TEXT_LEFT)
layout_from.set_width((cell_area.width - ink_rect.width - ink_rect.x - LINE_SPACING - TEXT_LEFT)
* Pango.SCALE);
layout_from.set_ellipsize(Pango.EllipsizeMode.END);
ctx.move_to(expose_area.x + TEXT_LEFT, y);
ctx.move_to(cell_area.x + TEXT_LEFT, y);
Pango.cairo_show_layout(ctx, layout_from);
y += ink_rect.height + ink_rect.y + LINE_SPACING;
@ -126,10 +121,10 @@ public class MessageListCellRenderer : Gtk.CellRenderer {
// Subject field.
Pango.Layout layout_subject = widget.create_pango_layout(null);
layout_subject.set_markup(data.subject, -1);
layout_subject.set_width((expose_area.width - TEXT_LEFT) * Pango.SCALE);
layout_subject.set_width((cell_area.width - TEXT_LEFT) * Pango.SCALE);
layout_subject.set_ellipsize(Pango.EllipsizeMode.END);
layout_date.get_pixel_extents(out ink_rect, out logical_rect);
ctx.move_to(expose_area.x + TEXT_LEFT, y);
ctx.move_to(cell_area.x + TEXT_LEFT, y);
Pango.cairo_show_layout(ctx, layout_subject);
y += ink_rect.height + ink_rect.y + LINE_SPACING;
@ -137,11 +132,11 @@ public class MessageListCellRenderer : Gtk.CellRenderer {
// Body preview.
Pango.Layout layout_preview = widget.create_pango_layout(null);
layout_preview.set_markup(data.body, -1);
layout_preview.set_width((expose_area.width - TEXT_LEFT) * Pango.SCALE);
layout_preview.set_width((cell_area.width - TEXT_LEFT) * Pango.SCALE);
layout_preview.set_height(preview_height * Pango.SCALE);
layout_preview.set_wrap(Pango.WrapMode.WORD);
layout_preview.set_ellipsize(Pango.EllipsizeMode.END);
ctx.move_to(expose_area.x + TEXT_LEFT, y);
ctx.move_to(cell_area.x + TEXT_LEFT, y);
Pango.cairo_show_layout(ctx, layout_preview);
// Unread indicator.
@ -155,8 +150,8 @@ public class MessageListCellRenderer : Gtk.CellRenderer {
}
}
Gdk.cairo_set_source_pixbuf(ctx, unread_pixbuf, expose_area.x + LINE_SPACING,
expose_area.y + (expose_area.height / 2) - (UNREAD_ICON_SIZE / 2));
Gdk.cairo_set_source_pixbuf(ctx, unread_pixbuf, cell_area.x + LINE_SPACING,
cell_area.y + (cell_area.height / 2) - (UNREAD_ICON_SIZE / 2));
ctx.paint();
}
}

View file

@ -26,7 +26,7 @@ gsettings_schemas = [
]
client_uselib = 'GLIB GEE GTK GNOME-KEYRING'
client_packages = [ 'gtk+-2.0', 'glib-2.0', 'gee-1.0', 'gnome-keyring-1' ]
client_packages = [ 'gtk+-3.0', 'glib-2.0', 'gee-1.0', 'gnome-keyring-1' ]
app = bld.program(
target = 'geary',

View file

@ -71,7 +71,7 @@ public abstract class YorbaApplication {
unique_app.message_received.connect(on_unique_app_message);
// If app already running, activate it and exit
if (unique_app.is_running) {
if (unique_app.is_running()) {
unique_app.send_message((int) Unique.Command.ACTIVATE, null);
return false;

View file

@ -38,7 +38,6 @@ class ImapConsole : Gtk.Window {
layout.pack_start(cmdline, false, false, 0);
statusbar_ctx = statusbar.get_context_id("status");
statusbar.has_resize_grip = true;
layout.pack_end(statusbar, false, false, 0);
add(layout);

View file

@ -8,7 +8,7 @@ console_src = [
]
console_uselib = 'GEE GTK GLIB'
console_packages = [ 'gee-1.0', 'gtk+-2.0', 'glib-2.0' ]
console_packages = [ 'gee-1.0', 'gtk+-3.0', 'glib-2.0' ]
bld.program(
target = 'console',

View file

@ -12,7 +12,7 @@ def build(bld):
]
bld.common_uselib = 'GLIB UNIQUE'
bld.common_packages = ['glib-2.0', 'unique-1.0', 'posix' ]
bld.common_packages = ['glib-2.0', 'unique-3.0', 'posix' ]
bld.engine_src = [
'../engine/api/geary-abstract-account.vala',

8
vapi/unique-3.0.deps Normal file
View file

@ -0,0 +1,8 @@
gio-2.0
cairo
atk
pango
gdk-3.0
gdk-pixbuf-2.0
gtk+-3.0

94
vapi/unique-3.0.vapi Normal file
View file

@ -0,0 +1,94 @@
/* unique-3.0.vapi generated by vapigen, do not modify. */
/* Pulled from http://permalink.gmane.org/gmane.linux.redhat.fedora.devel/147876 */
[CCode (cprefix = "Unique", lower_case_cprefix = "unique_")]
namespace Unique {
[CCode (cheader_filename = "unique/uniqueapp.h")]
public class App : GLib.Object {
[CCode (has_construct_function = false)]
public App (string name, string? startup_id);
public void add_command (string command_name, int command_id);
public bool is_running ();
public Unique.Response send_message (int command_id, Unique.MessageData? message_data);
public void watch_window (Gtk.Window window);
[CCode (has_construct_function = false)]
public App.with_commands (string name, string startup_id, ...);
[NoAccessorMethod]
public string name { owned get; construct; }
[NoAccessorMethod]
public Gdk.Screen screen { owned get; set construct; }
[NoAccessorMethod]
public string startup_id { owned get; construct; }
public virtual signal Unique.Response message_received (int command, Unique.MessageData message_data, uint time_);
}
[CCode (cheader_filename = "unique/uniquebackend.h")]
public class Backend : GLib.Object {
public weak string name;
public weak Unique.App parent;
public weak Gdk.Screen screen;
public weak string startup_id;
public uint workspace;
[CCode (has_construct_function = false)]
protected Backend ();
public static unowned Unique.Backend create ();
public unowned string get_name ();
public unowned Gdk.Screen get_screen ();
public unowned string get_startup_id ();
public uint get_workspace ();
public virtual bool request_name ();
public virtual Unique.Response send_message (int command_id, Unique.MessageData message_data, uint time_);
public void set_name (string name);
public void set_screen (Gdk.Screen screen);
public void set_startup_id (string startup_id);
}
[Compact]
[CCode (copy_function = "unique_message_data_copy", type_id = "UNIQUE_TYPE_MESSAGE_DATA", cheader_filename = "unique/uniquemessage.h")]
public class MessageData {
[CCode (has_construct_function = false)]
public MessageData ();
public unowned Unique.MessageData copy ();
public unowned uchar[] @get (size_t length);
public unowned string get_filename ();
public unowned Gdk.Screen get_screen ();
public unowned string get_startup_id ();
public unowned string get_text ();
public unowned string get_uris ();
public uint get_workspace ();
public void @set (uchar[] data, ssize_t length);
public void set_filename (string filename);
public bool set_text (string str, ssize_t length);
public bool set_uris (string uris);
}
[CCode (cprefix = "UNIQUE_", cheader_filename = "unique/uniqueenumtypes.h")]
public enum Command {
INVALID,
ACTIVATE,
NEW,
OPEN,
CLOSE
}
[CCode (cprefix = "UNIQUE_RESPONSE_", cheader_filename = "unique/uniqueenumtypes.h")]
public enum Response {
INVALID,
OK,
CANCEL,
FAIL,
PASSTHROUGH
}
[CCode (cheader_filename = "unique/uniqueversion.h")]
public const string API_VERSION_S;
[CCode (cheader_filename = "unique/uniqueversion.h")]
public const string DEFAULT_BACKEND_S;
[CCode (cheader_filename = "unique/uniqueversion.h")]
public const int MAJOR_VERSION;
[CCode (cheader_filename = "unique/uniqueversion.h")]
public const int MICRO_VERSION;
[CCode (cheader_filename = "unique/uniqueversion.h")]
public const int MINOR_VERSION;
[CCode (cheader_filename = "unique/uniqueversion.h")]
public const string PROTOCOL_VERSION_S;
[CCode (cheader_filename = "unique/uniqueversion.h")]
public const int VERSION_HEX;
[CCode (cheader_filename = "unique/uniqueversion.h")]
public const string VERSION_S;
}

View file

@ -47,16 +47,16 @@ def configure(conf):
args='--cflags --libs')
conf.check_cfg(
package='gtk+-2.0',
package='gtk+-3.0',
uselib_store='GTK',
atleast_version='2.22.0',
atleast_version='3.0.',
mandatory=1,
args='--cflags --libs')
conf.check_cfg(
package='unique-1.0',
package='unique-3.0',
uselib_store='UNIQUE',
atleast_version='1.0.0',
atleast_version='3.0.0',
mandatory=1,
args='--cflags --libs')