Skip to content

Commit

Permalink
Design changed to look closer to the recent mockup
Browse files Browse the repository at this point in the history
* Added a send button
* Sending messages is now disabled for offline contacts
* Using the EditableLabel to change Groupchat names (temporary as they are discarded on close) and Aliases (stored in sqlite db)
* Background color changed to look closer to mockup
  • Loading branch information
naxuroqa committed May 22, 2014
1 parent 6cafb84 commit 6f89a57
Show file tree
Hide file tree
Showing 14 changed files with 134 additions and 43 deletions.
6 changes: 6 additions & 0 deletions misc/svg/send.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/core/GroupChat.vala
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace Venom {
}

public string get_name_string() {
return "Groupchat #%i".printf(group_id);
return local_name == "" ? "Groupchat #%i".printf(group_id) : Markup.escape_text(local_name);
}
public string get_name_string_with_hyperlinks() {
return get_name_string();
Expand Down
2 changes: 2 additions & 0 deletions src/core/ResourceFactory.vala
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ namespace Venom {

call = load_image_from_resource(pixmaps_prefix + "call.png");
call_video = load_image_from_resource(pixmaps_prefix + "call_video.png");
send = load_image_from_resource(pixmaps_prefix + "send.png");
send_file = load_image_from_resource(pixmaps_prefix + "send_file.png");

add = load_image_from_resource(pixmaps_prefix + "add.png");
Expand Down Expand Up @@ -89,6 +90,7 @@ namespace Venom {

public Gdk.Pixbuf call {get; private set;}
public Gdk.Pixbuf call_video {get; private set;}
public Gdk.Pixbuf send {get; private set;}
public Gdk.Pixbuf send_file {get; private set;}

public Gdk.Pixbuf add {get; private set;}
Expand Down
Binary file added src/pixmaps/send.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/pixmaps/venom_pixmaps.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<file>call.png</file>
<file>call_video.png</file>
<file>cancel.png</file>
<file>send_file.png</file>
<file>default_contact.png</file>
<file>default_groupchat.png</file>
<file>groupchat.png</file>
Expand All @@ -19,6 +18,8 @@
<file>ok.png</file>
<file>online.png</file>
<file>online_glow.png</file>
<file>send.png</file>
<file>send_file.png</file>
<file>settings.png</file>
</gresource>
</gresources>
3 changes: 3 additions & 0 deletions src/ui/ContactListWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ namespace Venom {
groupchat_added.connect(contact_list_tree_view.add_entry);

contact_changed.connect( (c) => {
session.save_extended_contact_data(c);
contact_list_tree_view.update_entry(c);
ConversationWidget w = conversation_widgets[c.friend_id];
if(w != null)
Expand Down Expand Up @@ -923,6 +924,7 @@ namespace Venom {
w.filetransfer_rejected.connect ( (ft) => {
session.reject_file(ft.friend.friend_id,ft.filenumber);
});
w.contact_changed.connect((contact) => {contact_changed(contact);});
conversation_widgets[c.friend_id] = w;
notebook_conversations.append_page(w, null);
}
Expand All @@ -937,6 +939,7 @@ namespace Venom {
incoming_group_action.connect(w.on_incoming_message);
w.new_outgoing_message.connect(on_outgoing_group_message);
w.new_outgoing_action.connect(on_outgoing_group_action);
w.groupchat_changed.connect((groupchat) => {groupchat_changed(groupchat);});
group_conversation_widgets[g.group_id] = w;
notebook_conversations.append_page(w, null);
}
Expand Down
3 changes: 0 additions & 3 deletions src/ui/ConversationView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ namespace Venom {
if(last_message != null && last_message.compare_sender(message)) {
cm = new ChatMessage(message, short_names, true);
} else {
var sep = new Gtk.Separator(Gtk.Orientation.HORIZONTAL);
conversation_list.pack_start(sep, false, false);
sep.show_all();
cm = new ChatMessage(message, short_names, false);
}
conversation_list.pack_start(cm, false, false);
Expand Down
31 changes: 27 additions & 4 deletions src/ui/ConversationWidget.vala
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@

namespace Venom {
public class ConversationWidget : Gtk.EventBox {
private Gtk.Label label_contact_name;
private EditableLabel label_contact_name;
private Gtk.Label label_contact_statusmessage;
private Gtk.Image image_contact_image;
private Gtk.Button button_send;
private Gtk.Button button_send_file;

private MessageTextView message_textview;
Expand All @@ -36,6 +37,7 @@ namespace Venom {
public signal void typing_status(bool typing);
public signal void filetransfer_accepted(FileTransfer ft);
public signal void filetransfer_rejected(FileTransfer ft);
public signal void contact_changed(Contact c);

public ConversationWidget( Contact contact ) {
this.contact = contact;
Expand All @@ -46,7 +48,7 @@ namespace Venom {

public void update_contact() {
// update contact name
label_contact_name.label = "<b>%s</b>".printf(contact.get_name_string_with_hyperlinks());
label_contact_name.label.label = "<b>%s</b>".printf(contact.get_name_string_with_hyperlinks());

// update contact status message
label_contact_statusmessage.label = contact.get_status_string_with_hyperlinks();
Expand All @@ -58,6 +60,7 @@ namespace Venom {
conversation_view.is_typing_string = "%s is typing...".printf(Markup.escape_text(contact.name));

button_send_file.sensitive = contact.online;
button_send.sensitive = contact.online;
}

private void init_widgets() {
Expand All @@ -70,19 +73,37 @@ namespace Venom {
Gtk.Box box = builder.get_object("box") as Gtk.Box;
this.add(box);
this.get_style_context().add_class("conversation_widget");
label_contact_name = builder.get_object("label_contact_name") as Gtk.Label;
label_contact_statusmessage = builder.get_object("label_contact_statusmessage") as Gtk.Label;
image_contact_image = builder.get_object("image_contact_image") as Gtk.Image;

Gtk.Image image_send = builder.get_object("image_send") as Gtk.Image;
Gtk.Image image_call = builder.get_object("image_call") as Gtk.Image;
Gtk.Image image_call_video = builder.get_object("image_call_video") as Gtk.Image;
Gtk.Image image_send_file = builder.get_object("image_send_file") as Gtk.Image;

Gtk.Label label_contact_name_ = builder.get_object("label_contact_name") as Gtk.Label;
Gtk.Box box_user_info = builder.get_object("box_user_info") as Gtk.Box;
box_user_info.remove(label_contact_name_);
label_contact_name = new EditableLabel.with_label(label_contact_name_);
box_user_info.pack_start(label_contact_name, false);
label_contact_name.button_cancel.get_style_context().add_class("callbutton");
label_contact_name.button_ok.get_style_context().add_class("callbutton");
label_contact_name.show_all();
label_contact_name.show_entry.connect_after(() => {
label_contact_name.entry.text = contact.alias;
});
label_contact_name.label_changed.connect((new_alias) => {
contact.alias = new_alias;
contact_changed(contact);
});

//TODO
//Gtk.Button button_call = builder.get_object("button_call") as Gtk.Button;
//Gtk.Button button_call_video = builder.get_object("button_call_video") as Gtk.Button;
button_send = builder.get_object("button_send") as Gtk.Button;
button_send_file = builder.get_object("button_send_file") as Gtk.Button;

button_send.clicked.connect(() => {textview_activate();});
button_send_file.clicked.connect(button_send_file_clicked);

Gtk.ScrolledWindow scrolled_window_message = builder.get_object("scrolled_window_message") as Gtk.ScrolledWindow;
Expand All @@ -96,6 +117,7 @@ namespace Venom {

scrolled_window_message.add(message_textview);

image_send.set_from_pixbuf(ResourceFactory.instance.send);
image_call.set_from_pixbuf(ResourceFactory.instance.call);
image_call_video.set_from_pixbuf(ResourceFactory.instance.call_video);
image_send_file.set_from_pixbuf(ResourceFactory.instance.send_file);
Expand Down Expand Up @@ -176,8 +198,9 @@ namespace Venom {

public void textview_activate() {
string s = message_textview.buffer.text;
if(s == "")
if(!contact.online || message_textview.placeholder_visible || s == "") {
return;
}

GLib.MatchInfo info = null;
if(Tools.action_regex.match(s, 0, out info) && info.fetch_named("action_name") == "me") {
Expand Down
10 changes: 8 additions & 2 deletions src/ui/EditableLabel.vala
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ namespace Venom {
public Gtk.Label label { get; set; }

public signal void label_changed(string label_text);
public signal void show_entry();
public signal void show_label();

public EditableLabel(string label = "") {
this.label = new Gtk.Label(label);
Expand All @@ -43,12 +45,12 @@ namespace Venom {
init_signals();
}

public void show_label() {
private void on_show_label() {
box_label.visible = true;
box_entry.visible = false;
}

public void show_entry() {
private void on_show_entry() {
//FIXME define GTK_<MAJOR>_<MINOR> in cmake instead of using glib version
#if GLIB_2_34
entry.attributes = label.attributes;
Expand All @@ -57,6 +59,7 @@ namespace Venom {
box_entry.no_show_all = false;
box_entry.show_all();
box_entry.visible = true;
box_entry.no_show_all = true;
}

private void init_widgets() {
Expand All @@ -73,6 +76,7 @@ namespace Venom {
Gtk.Box box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
box_label = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
box_entry = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
box_entry.spacing = 1;

box_label.pack_start(label);
box_entry.pack_start(entry);
Expand Down Expand Up @@ -119,6 +123,8 @@ namespace Venom {
}

private void init_signals() {
show_entry.connect(on_show_entry);
show_label.connect(on_show_label);
button_press_event.connect((event) => {
if(!box_entry.visible && event.button == Gdk.BUTTON_PRIMARY) {
entry.text = label.label;
Expand Down
43 changes: 32 additions & 11 deletions src/ui/GroupConversationWidget.vala
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,20 @@

namespace Venom {
public class GroupConversationWidget : Gtk.EventBox {
private Gtk.Label label_groupchat_name;
private EditableLabel label_groupchat_name;
private Gtk.Label label_groupchat_statusmessage;
private Gtk.Image image_groupchat_image;

private MessageTextView message_textview;

private IConversationView conversation_view;
private IGroupConversationSidebar group_conversation_sidebar;

private unowned GroupChat groupchat {get; private set;}

public signal void new_outgoing_message(GroupMessage message);
public signal void new_outgoing_action(GroupActionMessage action);
public signal void groupchat_changed(GroupChat g);

public GroupConversationWidget( GroupChat groupchat ) {
this.groupchat = groupchat;
Expand All @@ -41,7 +44,7 @@ namespace Venom {

public void update_groupchat_info() {
// update groupchat name
label_groupchat_name.label = "<b>%s</b>".printf(groupchat.get_name_string_with_hyperlinks());
label_groupchat_name.label.label = "<b>%s</b>".printf(groupchat.get_name_string_with_hyperlinks());

// update groupchat status message
label_groupchat_statusmessage.label = groupchat.get_status_string_with_hyperlinks();
Expand All @@ -68,17 +71,34 @@ namespace Venom {
Gtk.Box box = builder.get_object("box") as Gtk.Box;
this.add(box);
this.get_style_context().add_class("conversation_widget");
label_groupchat_name = builder.get_object("label_contact_name") as Gtk.Label;
label_groupchat_statusmessage = builder.get_object("label_contact_statusmessage") as Gtk.Label;
image_groupchat_image = builder.get_object("image_contact_image") as Gtk.Image;

Gtk.Image image_send = builder.get_object("image_send") as Gtk.Image;
Gtk.Image image_call = builder.get_object("image_call") as Gtk.Image;
Gtk.Image image_call_video = builder.get_object("image_call_video") as Gtk.Image;
Gtk.Image image_send_file = builder.get_object("image_send_file") as Gtk.Image;

Gtk.Label label_groupchat_name_ = builder.get_object("label_contact_name") as Gtk.Label;
Gtk.Box box_user_info = builder.get_object("box_user_info") as Gtk.Box;
box_user_info.remove(label_groupchat_name_);
label_groupchat_name = new EditableLabel.with_label(label_groupchat_name_);
box_user_info.pack_start(label_groupchat_name, false);
label_groupchat_name.button_cancel.get_style_context().add_class("callbutton");
label_groupchat_name.button_ok.get_style_context().add_class("callbutton");
label_groupchat_name.show_all();
label_groupchat_name.show_entry.connect_after(() => {
label_groupchat_name.entry.text = groupchat.local_name;
});
label_groupchat_name.label_changed.connect((new_name) => {
groupchat.local_name = new_name;
groupchat_changed(groupchat);
});

//TODO
//Gtk.Button button_call = builder.get_object("button_call") as Gtk.Button;
//Gtk.Button button_call_video = builder.get_object("button_call_video") as Gtk.Button;
Gtk.Button button_send = builder.get_object("button_send") as Gtk.Button;
Gtk.Button button_send_file = builder.get_object("button_send_file") as Gtk.Button;
button_send_file.visible = false;
button_send_file.no_show_all = true;
Expand All @@ -93,16 +113,17 @@ namespace Venom {
paned_sidebar.pack2(sidebar_scrolled_window, false, true);

Gtk.ScrolledWindow scrolled_window_message = builder.get_object("scrolled_window_message") as Gtk.ScrolledWindow;
MessageTextView message_textview = new MessageTextView();
message_textview = new MessageTextView();
message_textview.border_width = 6;
message_textview.wrap_mode = Gtk.WrapMode.WORD_CHAR;
message_textview.textview_activate.connect( () => {
textview_activate(message_textview);
});
message_textview.textview_activate.connect(textview_activate);
message_textview.completion_column = GroupConversationSidebar.TreeModelColumn.NAME;
message_textview.completion_model = group_conversation_sidebar.model;
scrolled_window_message.add(message_textview);

button_send.clicked.connect(textview_activate);

image_send.set_from_pixbuf(ResourceFactory.instance.send);
image_call.set_from_pixbuf(ResourceFactory.instance.call);
image_call_video.set_from_pixbuf(ResourceFactory.instance.call_video);
image_send_file.set_from_pixbuf(ResourceFactory.instance.send_file);
Expand Down Expand Up @@ -148,9 +169,9 @@ namespace Venom {
conversation_view.add_message(message);
}

public void textview_activate(Gtk.TextView source) {
string s = source.buffer.text;
if(s == "")
public void textview_activate() {
string s = message_textview.buffer.text;
if(s == "" || message_textview.placeholder_visible)
return;
GLib.MatchInfo info = null;
if(Tools.action_regex.match(s, 0, out info) && info.fetch_named("action_name") == "me") {
Expand All @@ -164,7 +185,7 @@ namespace Venom {
GroupMessage m = new GroupMessage.outgoing(groupchat, s);
new_outgoing_message(m);
}
source.buffer.text = "";
message_textview.buffer.text = "";
}
}
}
2 changes: 1 addition & 1 deletion src/ui/MessageTextView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace Venom {

public string placeholder_text { get; set; default = "Type your message here..."; }
public Gtk.TextTag placeholder_tag { get; set; }
public bool placeholder_visible { get; protected set; default = true; }

private Gtk.TreeModel _completion_model;
public Gtk.TreeModel completion_model {
Expand All @@ -40,7 +41,6 @@ namespace Venom {
public int completion_column { get; set; }

private bool is_typing = false;
private bool placeholder_visible = true;
private Gtk.TreeModelFilter completion_filtered;
private string filter_string;

Expand Down
2 changes: 1 addition & 1 deletion src/ui/contact_list.ui
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
<property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="box_self_info">
<property name="height_request">59</property>
<property name="height_request">76</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
Expand Down

0 comments on commit 6f89a57

Please sign in to comment.