Skip to content

Commit

Permalink
2019年 06月 17日 星期一 15:16:11 CST
Browse files Browse the repository at this point in the history
  • Loading branch information
rocket049 committed Jun 17, 2019
1 parent 9eedec7 commit 2190720
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
32 changes: 22 additions & 10 deletions client/search.vala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public delegate void SearchCallback(UserMsg user1);
public class SearchDialg:GLib.Object{
public Gtk.Dialog dlg1;
public Gtk.Entry key1;
private Gtk.TreeView view;
public Gtk.ListStore store1;
public GLib.List<UserMsg?> persons;
public SearchDialg(){
Expand All @@ -20,15 +21,20 @@ public class SearchDialg:GLib.Object{
grid.attach(b1,2,0);
b1.clicked.connect( this.search );

this.store1 = new Gtk.ListStore (5, typeof(int64), typeof (string), typeof (string), typeof(int16), typeof(string));
this.store1 = new Gtk.ListStore (6, typeof(int64), typeof (string), typeof (string), typeof(int16), typeof(string), typeof(string));

var view = new Gtk.TreeView.with_model(this.store1);
view = new Gtk.TreeView.with_model(this.store1);
//Gtk.CellRendererText cell = new Gtk.CellRendererText ();
view.insert_column_with_attributes (0, "ID", new Gtk.CellRendererText(), "text",0);
view.insert_column_with_attributes (1, _("Name"), new Gtk.CellRendererText(), "text",1);
view.insert_column_with_attributes (2, _("Sex"), new Gtk.CellRendererText(), "text",2);
view.insert_column_with_attributes (3, _("Age"), new Gtk.CellRendererText(), "text",3);
view.insert_column_with_attributes (4, _("Description"), new Gtk.CellRendererText(), "text",4);
var renderer = new Gtk.CellRendererText();
view.insert_column_with_attributes (0, "ID", renderer, "text",0);
view.insert_column_with_attributes (1, _("Name"), renderer, "text",1);
view.insert_column_with_attributes (2, _("Sex"), renderer, "text",2);
view.insert_column_with_attributes (3, _("Age"), renderer, "text",3);
view.insert_column_with_attributes (4, _("Description"), renderer, "text",4);
for (int i=0;i<5;i++) {
view.get_column(i).add_attribute(renderer,"foreground",5);
}

view.headers_visible = true;
view.show_all();

Expand Down Expand Up @@ -72,8 +78,13 @@ public class SearchDialg:GLib.Object{
}else if(u1.sex==2){
sex = _("Woman");
}
this.store1.set (iter, 0, u1.id, 1, u1.name,2,sex,3,u1.age,4,u1.desc);
//stdout.printf("%s %s\n",u1.name,u1.desc);
var color1 = "#FF0000";
if ( u1.desc[0]=='+' ) {
color1 = "#0000FF";
}
this.store1.set (iter, 0, u1.id, 1, u1.name,2,sex,3,u1.age,4,u1.desc[1:u1.desc.length],5,color1);

view.scroll_to_cell(new Gtk.TreePath.first (),null,false,0,0);
}
public void seach_callback(UserMsg u){
this.add_row(u);
Expand All @@ -82,7 +93,8 @@ public class SearchDialg:GLib.Object{
public void search(){
this.store1.clear();
this.persons = new GLib.List<UserMsg?>();
this.store1.set_sort_column_id(0,Gtk.SortType.ASCENDING);
//this.store1.set_sort_column_id(0,Gtk.SortType.ASCENDING);
this.store1.set_sort_column_id(5,Gtk.SortType.ASCENDING );

client.search_person_async(this.key1.text);
}
Expand Down
2 changes: 1 addition & 1 deletion client/ui.vala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ static LoginDialog login1;
static AddUserDialog adduser1;
static MultiSendUi msend_ui;
static ChatClient client;
static int RELEASE=41;
static int RELEASE=42;
static int LATESTVER=0;

public struct UserMsg{
Expand Down

0 comments on commit 2190720

Please sign in to comment.