Skip to content

Commit 49f36bf

Browse files
committed
show last message
1 parent 5ee7557 commit 49f36bf

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

client/ui.vala

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class MyGrid: GLib.Object{
3232
Gtk.Label droplabel;
3333
public Gtk.Entry port1;
3434
int64 to;
35+
string last_from="";
3536
bool running = true;
3637
//public MyBrowser browser;
3738

@@ -268,11 +269,14 @@ public class MyGrid: GLib.Object{
268269
this.msg_win.remove(this.msgs);
269270
}
270271
this.msgs = this.boxes[id.to_string()];
272+
271273
this.msg_win.add(this.msgs);
272274
Gtk.Grid grid = this.frd_boxes[id.to_string()];
273275
var sc3 = grid.get_style_context();
276+
//print("before crash 1\n");
274277
sc3.remove_provider(this.mark1);
275278
if ( sc3.has_class("mark") ){
279+
//print("before crash 2\n");
276280
sc3.remove_class("mark");
277281
this.mark_num--;
278282
if (this.mark_num==0)
@@ -282,9 +286,10 @@ public class MyGrid: GLib.Object{
282286
}else{
283287
this.msg_win.show_all();
284288
}
289+
//print("before crash 3\n");
285290
scroll_msgbox();
286291
});
287-
292+
//print("before crash 4\n");
288293
set_css_once();
289294
}
290295
public void send_uri1(string[] uris){
@@ -552,6 +557,27 @@ label{
552557
//r.hide();
553558
this.friends.remove( r );
554559
}
560+
561+
public void set_last_from(string fid) {
562+
this.last_from=fid;
563+
}
564+
public void select_last_from() {
565+
if(this.last_from==""){
566+
return;
567+
}
568+
var grid = this.frd_boxes[this.last_from];
569+
Gtk.ListBoxRow r = grid.get_parent() as Gtk.ListBoxRow;
570+
this.friends.select_row(r);
571+
}
572+
public string get_user_id(string uname) {
573+
foreach( var v in this.frds1.values ){
574+
if( v.name==uname ){
575+
//print (@"get_user_id: $(v.id) - $(uname)\n");
576+
return v.id.to_string();
577+
}
578+
}
579+
return "";
580+
}
555581
public void add_right_name_icon(string name,int16 sex){
556582
string iconp;
557583
if (sex==1)
@@ -899,6 +925,12 @@ public void msg_notify(string uname){
899925
var notify1 = new Notification(_("New message"));
900926
notify1.set_body(_("From: ")+uname);
901927
notify1.set_default_action("app.show-win");
928+
929+
var fid=grid1.get_user_id(uname);
930+
if (fid!="") {
931+
grid1.set_last_from(fid);
932+
}
933+
902934
app.send_notification(null,notify1);
903935
app.release();
904936
#endif
@@ -996,6 +1028,7 @@ public class AppWin:Gtk.ApplicationWindow{
9961028
if(grid1.mark_num==0){
9971029
this.clear_notify();
9981030
}
1031+
grid1.select_last_from();
9991032
});
10001033
// Method called on pressing [X]
10011034
this.set_destroy_with_parent(false);

0 commit comments

Comments
 (0)