zeitgeist team mailing list archive
-
zeitgeist team
-
Mailing list archive
-
Message #05130
[Merge] lp:~cando/activity-log-manager/appdialog-fixes into lp:activity-log-manager
Stefano Candori has proposed merging lp:~cando/activity-log-manager/appdialog-fixes into lp:activity-log-manager.
Requested reviews:
Activity Log Manager (activity-log-manager)
For more details, see:
https://code.launchpad.net/~cando/activity-log-manager/appdialog-fixes/+merge/97629
In this branch i've added a bunch of fixes regarding the ApplicationChooserDialog.
See the commit below for the explanation of the changes.
--
https://code.launchpad.net/~cando/activity-log-manager/appdialog-fixes/+merge/97629
Your team Activity Log Manager is requested to review the proposed merge of lp:~cando/activity-log-manager/appdialog-fixes into lp:activity-log-manager.
=== modified file 'src/applications-widget.vala'
--- src/applications-widget.vala 2012-03-12 14:45:32 +0000
+++ src/applications-widget.vala 2012-03-15 12:34:23 +0000
@@ -347,20 +347,34 @@
this.pack_start (scroll);
}
- public static Gdk.Pixbuf? get_pixbuf_from_gio_icon (Icon icon, int size=32) {
+ public static Gdk.Pixbuf? get_pixbuf_from_gio_icon (Icon? icon, int size=32) {
Gdk.Pixbuf? pix = null;
- var icon_info = IconTheme.get_default ().lookup_by_gicon (icon ,
- size,
- IconLookupFlags.FORCE_SVG);
- if (icon_info != null) {
- try {
- pix = icon_info.load_icon ();
- }
- catch (Error e){
- return null;
- }
- }
-
+ IconTheme theme = IconTheme.get_default ();
+ IconInfo icon_info = null;
+ /*If the application hasn't an icon in the current theme
+ let's use the gtk-execute icon:
+ http://developer.gnome.org/gtk3/3.2/gtk3-Stock-Items.html#GTK-STOCK-EXECUTE:CAPS
+ */
+ if(icon == null) {
+ icon_info = theme.lookup_icon ("gtk-execute" ,
+ size,
+ IconLookupFlags.FORCE_SVG);
+ }
+ else {
+ icon_info = theme.lookup_by_gicon (icon ,
+ size,
+ IconLookupFlags.FORCE_SVG);
+ if (icon_info == null)
+ icon_info = theme.lookup_icon ("gtk-execute" ,
+ size,
+ IconLookupFlags.FORCE_SVG);
+ }
+ try {
+ pix = icon_info.load_icon ();
+ }
+ catch (Error e){
+ return null;
+ }
return pix;
}
@@ -375,7 +389,13 @@
// Insert only when it is empty
if(this.blocked_apps.lookup(app) == null)
- this.blocked_apps.insert(app, new AppChooseInfo(app_info.get_id(), app_info.get_name(), pix, "", 0));
+ this.blocked_apps.insert(app, new AppChooseInfo(
+ app_info.get_id(),
+ app_info.get_name(),
+ pix,
+ "",
+ 0,
+ 0));
}
}
@@ -466,7 +486,7 @@
private void set_up_ui () {
var column_pix_name = new TreeViewColumn ();
- column_pix_name.set_title ("Name");
+ column_pix_name.set_title (_("Name"));
this.treeview.append_column (column_pix_name);
var pix_rend = new CellRendererPixbuf ();
column_pix_name.pack_start (pix_rend, false);
@@ -477,10 +497,11 @@
column_pix_name.add_attribute (name_rend, "text", 0);
column_pix_name.set_resizable (true);
column_pix_name.set_min_width (200);
+ column_pix_name.set_max_width (400);
column_pix_name.set_sort_column_id (0);
var column_used_name = new TreeViewColumn ();
- column_used_name.set_title ("Last Used");
+ column_used_name.set_title (_("Last Used"));
this.treeview.append_column (column_used_name);
var used_rend = new CellRendererText ();
used_rend.set_property ("ellipsize", Pango.EllipsizeMode.END);
@@ -488,11 +509,12 @@
column_used_name.add_attribute (used_rend, "text", 3);
column_used_name.set_resizable (true);
column_used_name.set_min_width (200);
+ column_used_name.set_max_width (400);
column_used_name.set_sort_column_id (4);
- used_rend.set_property("xalign", 1);
+ used_rend.set_property("xalign", 0);
var column_usage_name = new TreeViewColumn ();
- column_usage_name.set_title ("Activity");
+ column_usage_name.set_title (_("Activity"));
this.treeview.append_column (column_usage_name);
var usage_rend = new UsageCellRenderer ();
column_usage_name.pack_start (usage_rend, true);
@@ -557,6 +579,18 @@
}
}
+ private int compare_dates(DateTime now, DateTime time) {
+ int res = -1;
+ int now_y, now_m, now_d, time_y, time_m, time_d;
+ now.get_ymd(out now_y, out now_m, out now_d);
+ time.get_ymd(out time_y, out time_m, out time_d);
+ if (now_y == time_y && now_m == time_m && now_d == time_d)
+ return 0;
+ else if (now_y == time_y && now_m == time_m && now_d == time_d + 1)
+ return 1;
+ return res;
+ }
+
public void handle_app_population(HashTable<string, int64?> all_actors) {
all_actors_list = all_actors;
@@ -570,18 +604,27 @@
{
string id = app_info.get_id ();
int64? last_accessed_time = all_actors.lookup(id);
- //
if(last_accessed_time != null)
{
var time = new DateTime.from_unix_local (last_accessed_time/1000);
- var last_accessed = time.format("%e %B %Y");
+ var now = new DateTime.now_local();
+ var res = this.compare_dates(now, time);
+ string last_accessed = "";
+ string today = _("Today");
+ string yesterday = _("Yesterday");
+ if (res == 0) // Today
+ last_accessed = time.format(today + ", %H:%M");
+ else if (res == 1) // Yesterday
+ last_accessed = time.format(yesterday + ", %H:%M");
+ else
+ last_accessed = time.format("%e %B %Y, %H:%M");
insert_liststore(app_info, last_accessed, last_accessed_time,
0);
}
else {
other_appinfo.append(app_info);
- insert_liststore(app_info, "", 0, 0);
+ insert_liststore(app_info, _("Never"), 0, 0);
}
}
/*foreach(AppInfo app_info in other_appinfo)
@@ -596,9 +639,7 @@
var name = app_info.get_name ();
var icon = app_info.get_icon ();
- Gdk.Pixbuf? pix = null;
- if(icon != null)
- pix = ApplicationsTreeView.get_pixbuf_from_gio_icon (icon);
+ Gdk.Pixbuf? pix = ApplicationsTreeView.get_pixbuf_from_gio_icon (icon);
AppChooseInfo app_choose_info = blocked_apps.lookup(id);
if(app_choose_info == null)
@@ -607,11 +648,13 @@
this.treeview.liststore.append(out iter);
this.treeview.liststore.set(iter, 0, name, 1, pix, 2, id,
3, last_accessed, 4, last_accessed_time, 5, 0, -1);
- this.blocked_apps.insert(id, new AppChooseInfo(id, name, pix, last_accessed, usage));
+ this.blocked_apps.insert(id, new AppChooseInfo(id, name, pix,
+ last_accessed,
+ last_accessed_time,
+ usage));
//this.actors_iter[id] = iter;
if (last_accessed_time > 0)
- this.app_blacklist.get_count_for_app(id, iter, this.treeview.liststore);
-
+ this.app_blacklist.get_count_for_app(id, iter, this.treeview.liststore);
}
else
{
@@ -627,7 +670,8 @@
TreeIter iter;
this.treeview.liststore.insert(out iter, 1);
this.treeview.liststore.set(iter, 0, app_choose_info.name,
- 1, app_choose_info.icon, 2, app, -1);
+ 1, app_choose_info.icon, 2, app, 3, app_choose_info.last_accessed,
+ 4, app_choose_info.last_accessed_time, -1);
this.app_blacklist.get_count_for_app(app_choose_info.get_id(), iter, this.treeview.liststore);
}
}
@@ -709,14 +753,16 @@
private string app_id;
private string app_name;
private Gdk.Pixbuf? app_icon;
- private string last_accessed_time;
+ private string last_accessed_time_s;
+ private int64 last_accessed_time_i;
private uint usage_rating;
public AppChooseInfo(string id, string app_name, Gdk.Pixbuf? app_icon,
- string last_accessed_time, uint usage_rating ) {
+ string last_accessed_time_s, int64 last_accessed_time_i, uint usage_rating ) {
this.app_name = app_name;
this.app_icon = app_icon;
- this.last_accessed_time = last_accessed_time;
+ this.last_accessed_time_s = last_accessed_time_s;
+ this.last_accessed_time_i = last_accessed_time_i;
this.usage_rating = usage_rating;
this.app_id = id;
}
@@ -745,10 +791,19 @@
public string last_accessed {
get {
- return last_accessed_time;
- }
- set {
- last_accessed_time = value;
+ return last_accessed_time_s;
+ }
+ set {
+ last_accessed_time_s = value;
+ }
+ }
+
+ public int64 last_accessed_time {
+ get {
+ return last_accessed_time_i;
+ }
+ set {
+ last_accessed_time_i = value;
}
}
=== modified file 'src/blacklist-dbus.vala'
--- src/blacklist-dbus.vala 2012-02-24 17:48:20 +0000
+++ src/blacklist-dbus.vala 2012-03-15 12:34:23 +0000
@@ -162,20 +162,6 @@
null);
var counter = results.length/100;
- int64 last_accessed = 0;
- var last_accessed_string = "";
- if (counter > 0) {
- var ids= new Array<int>();
- int event_id = results.index(0);
- ids.append_val(event_id);
- var results2 = yield log.get_events(ids, null);
- last_accessed = results2.next().get_timestamp();
- var time = new DateTime.from_unix_local (last_accessed/1000);
- last_accessed_string = time.format("%e %B %Y");
- }
-
- store.set_value(iter, 3, last_accessed_string);
- store.set_value(iter, 4, last_accessed);
store.set_value(iter, 5, counter);
}
Follow ups