summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--data/ephraim.glade2
-rw-r--r--src/gui/CMakeLists.txt2
-rw-r--r--src/gui/CellRendererAvatar.vala19
-rw-r--r--src/gui/CellRendererContact.vala146
-rw-r--r--src/gui/CellRendererPresence.vala55
5 files changed, 141 insertions, 83 deletions
diff --git a/data/ephraim.glade b/data/ephraim.glade
index 5535b26..d5bf424 100644
--- a/data/ephraim.glade
+++ b/data/ephraim.glade
@@ -77,7 +77,7 @@
<object class="GtkScrolledWindow" id="ScrolledRoster">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="hscrollbar_policy">never</property>
+ <property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<child>
<object class="GtkViewport" id="viewport2">
diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt
index e446c77..42b7734 100644
--- a/src/gui/CMakeLists.txt
+++ b/src/gui/CMakeLists.txt
@@ -2,9 +2,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${ephraim_BINARY_DIR})
vala_precompile(VALA_C
"Ephraim.vala"
- "CellRendererAvatar.vala"
"CellRendererContact.vala"
- "CellRendererPresence.vala"
"Contact.vala"
"Conversation.vala"
"CoreConnector.vala"
diff --git a/src/gui/CellRendererAvatar.vala b/src/gui/CellRendererAvatar.vala
deleted file mode 100644
index e4b53f4..0000000
--- a/src/gui/CellRendererAvatar.vala
+++ /dev/null
@@ -1,19 +0,0 @@
-public class CellRendererAvatar : Gtk.CellRendererPixbuf {
- private Contact _contact;
-
- public Contact contact {
- get {
- return _contact;
- }
- set {
- _contact = value;
-
- if(value == null) {
- pixbuf = null;
- return;
- }
-
- pixbuf = value.avatar;
- }
- }
-}
diff --git a/src/gui/CellRendererContact.vala b/src/gui/CellRendererContact.vala
index d7d9309..bff0bba 100644
--- a/src/gui/CellRendererContact.vala
+++ b/src/gui/CellRendererContact.vala
@@ -1,6 +1,29 @@
-public class CellRendererContact : Gtk.CellRendererText {
+public class CellRendererContact : Gtk.CellRenderer {
+ private static Gdk.Pixbuf online;
+ private static Gdk.Pixbuf away;
+ private static Gdk.Pixbuf dnd;
+ private static Gdk.Pixbuf xa;
+ private static Gdk.Pixbuf undefined;
+ private static Gdk.Pixbuf offline;
+
+ static construct {
+ try {
+ online = new Gdk.Pixbuf.from_file("icons/16x16/online.png");
+ away = new Gdk.Pixbuf.from_file("icons/16x16/away.png");
+ dnd = new Gdk.Pixbuf.from_file("icons/16x16/dnd.png");
+ xa = new Gdk.Pixbuf.from_file("icons/16x16/xa.png");
+ undefined = new Gdk.Pixbuf.from_file("icons/16x16/requested.png");
+ offline = new Gdk.Pixbuf.from_file("icons/16x16/offline.png");
+ } catch(Error e) {
+ }
+ }
+
private Object _data;
+ private Gtk.CellRendererText textRenderer = new Gtk.CellRendererText();
+ private Gtk.CellRendererPixbuf presenceRenderer = new Gtk.CellRendererPixbuf();
+ private Gtk.CellRendererPixbuf avatarRenderer = new Gtk.CellRendererPixbuf();
+
public Object data {
get {
return _data;
@@ -10,23 +33,134 @@ public class CellRendererContact : Gtk.CellRendererText {
if(_data is Contact) {
Contact contact = _data as Contact;
-
+
string str = Markup.escape_text(contact.display_string);
Gee.Map.Entry<string, Contact.Resource> res = contact.get_resource_with_highest_priority();
if(res != null && res.value.status != null) {
str += "\n<span size=\"small\" fgcolor=\"grey40\" style=\"italic\">" + Markup.escape_text(res.value.status) + "</span>";
}
+
+ textRenderer.markup = str;
+
+ Gee.Map.Entry<string, Contact.Resource>? r = contact.get_resource_with_highest_priority();
+ if(r == null) {
+ presenceRenderer.pixbuf = offline;
+ return;
+ }
- markup = str;
+ switch(r.value.show) {
+ case Contact.Show.ONLINE:
+ presenceRenderer.pixbuf = online;
+ break;
+ case Contact.Show.AWAY:
+ presenceRenderer.pixbuf = away;
+ break;
+ case Contact.Show.DND:
+ presenceRenderer.pixbuf = dnd;
+ break;
+ case Contact.Show.XA:
+ presenceRenderer.pixbuf = xa;
+ break;
+ case Contact.Show.UNDEFINED:
+ presenceRenderer.pixbuf = undefined;
+ break;
+ }
+
+ avatarRenderer.pixbuf = contact.avatar;
}
else if(_data is String) {
- markup = Markup.escape_text((_data as String).data);
+ textRenderer.text = (_data as String).data;
}
}
}
-
+
+ public override void get_size(Gtk.Widget widget, Gdk.Rectangle? cell_area, out int x_offset, out int y_offset, out int width, out int height) {
+ if(_data is Contact) {
+ int presenceX, presenceY, presenceWidth, presenceHeight;
+ presenceRenderer.get_size(widget, cell_area, out presenceX, out presenceY, out presenceWidth, out presenceHeight);
+ presenceWidth = 32;
+
+ int textX, textY, textWidth, textHeight;
+ textRenderer.get_size(widget, cell_area, out textX, out textY, out textWidth, out textHeight);
+
+ int avatarX, avatarY, avatarWidth, avatarHeight;
+ avatarRenderer.get_size(widget, cell_area, out avatarX, out avatarY, out avatarWidth, out avatarHeight);
+
+ int calc_width = (presenceWidth + textWidth + avatarWidth);
+ int calc_height = int.max(int.max(presenceHeight, textHeight), avatarHeight);
+
+ if(&width != null)
+ width = calc_width;
+ if(&height != null)
+ height = calc_height;
+
+ if(cell_area != null) {
+ if(&width != null)
+ width = cell_area.width;
+ if(&x_offset != null)
+ x_offset = 0;
+ if(&y_offset != null)
+ y_offset = int.max((int)(yalign * (cell_area.height - calc_height)), 0);
+ }
+ else {
+ if(&x_offset != null)
+ x_offset = 0;
+ if(&y_offset != null)
+ y_offset = 0;
+ }
+ }
+ else {
+ textRenderer.get_size(widget, cell_area, out x_offset, out y_offset, out width, out 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) {
+ if(_data is Contact) {
+ // A bit hacky...
+ int extra_width = cell_area.x - background_area.x;
+ cell_area.x -= extra_width;
+ cell_area.width += extra_width;
+ expose_area.x -= extra_width;
+ expose_area.width += extra_width;
+
+ int presenceX, presenceY, presenceWidth, presenceHeight;
+ presenceRenderer.get_size(widget, cell_area, out presenceX, out presenceY, out presenceWidth, out presenceHeight);
+ presenceWidth = 32;
+
+ int textX, textY, textWidth, textHeight;
+ textRenderer.get_size(widget, cell_area, out textX, out textY, out textWidth, out textHeight);
+
+ int avatarX, avatarY, avatarWidth, avatarHeight;
+ avatarRenderer.get_size(widget, cell_area, out avatarX, out avatarY, out avatarWidth, out avatarHeight);
+
+
+ Gdk.Rectangle presenceArea = cell_area;
+ presenceArea.width = presenceWidth;
+
+ presenceRenderer.render(window, widget, background_area, presenceArea, expose_area, flags);
+
+ Gdk.Rectangle textArea = cell_area;
+ textArea.x += presenceWidth;
+ textArea.width -= (presenceWidth + avatarWidth);
+
+ textRenderer.render(window, widget, background_area, textArea, expose_area, flags);
+
+ Gdk.Rectangle avatarArea = cell_area;
+ avatarArea.width = avatarWidth;
+ avatarArea.x += (cell_area.width - avatarWidth);
+
+ avatarRenderer.render(window, widget, background_area, avatarArea, expose_area, flags);
+ }
+ else if(_data is String) {
+ textRenderer.render(window, widget, background_area, cell_area, expose_area, flags);
+ }
+ }
+
public CellRendererContact() {
- ellipsize = Pango.EllipsizeMode.END;
+ Object();
+
+ textRenderer.ellipsize = Pango.EllipsizeMode.END;
}
}
diff --git a/src/gui/CellRendererPresence.vala b/src/gui/CellRendererPresence.vala
deleted file mode 100644
index 0a93b51..0000000
--- a/src/gui/CellRendererPresence.vala
+++ /dev/null
@@ -1,55 +0,0 @@
-public class CellRendererPresence : Gtk.CellRendererPixbuf {
- private static Gdk.Pixbuf online;
- private static Gdk.Pixbuf away;
- private static Gdk.Pixbuf dnd;
- private static Gdk.Pixbuf xa;
- private static Gdk.Pixbuf undefined;
- private static Gdk.Pixbuf offline;
-
- private Contact _contact;
-
- static construct {
- try {
- online = new Gdk.Pixbuf.from_file("icons/16x16/online.png");
- away = new Gdk.Pixbuf.from_file("icons/16x16/away.png");
- dnd = new Gdk.Pixbuf.from_file("icons/16x16/dnd.png");
- xa = new Gdk.Pixbuf.from_file("icons/16x16/xa.png");
- undefined = new Gdk.Pixbuf.from_file("icons/16x16/requested.png");
- offline = new Gdk.Pixbuf.from_file("icons/16x16/offline.png");
- } catch(Error e) {
- }
- }
-
- public Contact contact {
- get {
- return _contact;
- }
- set {
- _contact = value;
-
- Gee.Map.Entry<string, Contact.Resource>? r = value.get_resource_with_highest_priority();
- if(r == null) {
- pixbuf = offline;
- return;
- }
-
- switch(r.value.show) {
- case Contact.Show.ONLINE:
- pixbuf = online;
- break;
- case Contact.Show.AWAY:
- pixbuf = away;
- break;
- case Contact.Show.DND:
- pixbuf = dnd;
- break;
- case Contact.Show.XA:
- pixbuf = xa;
- break;
- case Contact.Show.UNDEFINED:
- pixbuf = undefined;
- break;
- }
- }
- }
-}