Skip to content

Commit

Permalink
Fixed chromium SN
Browse files Browse the repository at this point in the history
  • Loading branch information
rilian-la-te committed Mar 4, 2015
1 parent 3dd8cec commit 14c59e6
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 29 deletions.
11 changes: 6 additions & 5 deletions src/snhost.vala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ namespace StatusNotifier
private uint owned_name;
private uint watched_name;
private bool is_nested_watcher;
public signal void watcher_items_changed();
public signal void watcher_item_added(string id);
public signal void watcher_item_removed(string id);
public Host(string path)
{
Object(object_path: path);
Expand All @@ -38,8 +39,8 @@ namespace StatusNotifier
nested_watcher = new Watcher();
conn.register_object ("/StatusNotifierWatcher", nested_watcher);
nested_watcher.register_status_notifier_host(object_path);
nested_watcher.status_notifier_item_registered.connect(()=>{watcher_items_changed();});
nested_watcher.status_notifier_item_unregistered.connect(()=>{watcher_items_changed();});
nested_watcher.status_notifier_item_registered.connect((id)=>{watcher_item_added(id);});
nested_watcher.status_notifier_item_unregistered.connect((id)=>{watcher_item_removed(id);});
} catch (IOError e) {
stderr.printf ("Could not register service. Waiting for external watcher\n");
}
Expand Down Expand Up @@ -75,8 +76,8 @@ namespace StatusNotifier
);

outer_watcher.register_status_notifier_host(object_path);
outer_watcher.status_notifier_item_registered.connect(()=>{watcher_items_changed();});
outer_watcher.status_notifier_item_unregistered.connect(()=>{watcher_items_changed();});
outer_watcher.status_notifier_item_registered.connect((id)=>{watcher_item_added(id);});
outer_watcher.status_notifier_item_unregistered.connect((id)=>{watcher_item_removed(id);});
} catch (Error e) {
stderr.printf("%s\n",e.message);
return;
Expand Down
15 changes: 7 additions & 8 deletions src/snitem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ namespace StatusNotifier
} catch (GLib.Error e) {/* Errors cannot thrown there*/}
try
{
uint id;
id = Bus.watch_name(BusType.SESSION,object_name,BusNameWatcherFlags.NONE,
null,
() => {Bus.unwatch_name(id); get_applet().request_remove_item(this,object_name+(string)object_path);}
);
init_proxy.begin();
} catch (IOError e) {stderr.printf ("%s\n", e.message); this.destroy();}
client = null;
Expand Down Expand Up @@ -165,7 +160,10 @@ namespace StatusNotifier
private void iface_new_path_cb(string? path)
{
if (path != null)
{
icon_theme_path = path;
IconTheme.get_default().prepend_search_path(path);
}
iface_new_icon_cb();
}
private void iface_new_status_cb(Status status)
Expand Down Expand Up @@ -311,10 +309,10 @@ namespace StatusNotifier
return new FileIcon(File.new_for_path(icon_name));
else if (icon_theme.has_icon(icon_name)
|| icon_theme.has_icon(new_name)
|| iface.icon_theme_path == null
|| iface.icon_theme_path.length == 0)
|| icon_theme_path == null
|| icon_theme_path.length == 0)
return new ThemedIcon.with_default_fallbacks(new_name);
else return find_file_icon(icon_name,iface.icon_theme_path);
else return find_file_icon(icon_name,icon_theme_path);
}
else if (pixmaps.length > 0)
{
Expand Down Expand Up @@ -412,6 +410,7 @@ namespace StatusNotifier
string markup;
string accessible_desc;
string title;
string icon_theme_path;
bool use_menumodel;
DBusMenu.GtkClient? client;
MenuModel remote_menu_model;
Expand Down
25 changes: 17 additions & 8 deletions src/snitembox.vala
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,23 @@ namespace StatusNotifier
});
set_sort_func(sort_cb);
set_filter_func(filter_cb);
host.watcher_items_changed.connect(()=>{
recreate_items();
host.watcher_item_added.connect((item)=>{
string[] np = item.split("/",2);
if (!items.contains(item))
{
var snitem = new Item(np[0],(ObjectPath)("/"+np[1]));
items.insert(item, snitem);
this.add(snitem);
}
});
host.watcher_item_removed.connect((item)=>{
var child = items.lookup(item);
if (child != null)
{
items.remove(item);
this.remove(child);
child.destroy();
}
});
watcher_registration_handler = host.notify["watcher-registered"].connect(()=>{
if (host.watcher_registered)
Expand Down Expand Up @@ -88,12 +103,6 @@ namespace StatusNotifier
}
}
}
internal void request_remove_item(FlowBoxChild child, string item)
{
items.remove(item);
this.remove(child);
child.destroy();
}
private bool filter_cb(FlowBoxChild ch)
{
var item = ch as Item;
Expand Down
29 changes: 21 additions & 8 deletions src/snwatcher.vala
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ namespace StatusNotifier
public interface WatcherIface: Object
{
/* Signals */
public signal void status_notifier_item_registered(out string item);
public signal void status_notifier_item_registered(string item);
public signal void status_notifier_host_registered();
public signal void status_notifier_item_unregistered(out string item);
public signal void status_notifier_item_unregistered(string item);
public signal void status_notifier_host_unregistered();
/* Public properties */
public abstract string[] registered_status_notifier_items
Expand All @@ -26,9 +26,9 @@ namespace StatusNotifier
public class Watcher : Object
{
/* Signals */
public signal void status_notifier_item_registered(out string item);
public signal void status_notifier_item_registered(string item);
public signal void status_notifier_host_registered();
public signal void status_notifier_item_unregistered(out string item);
public signal void status_notifier_item_unregistered(string item);
public signal void status_notifier_host_unregistered();
/* Hashes */
private HashTable<string,uint> name_watcher;
Expand Down Expand Up @@ -63,12 +63,25 @@ namespace StatusNotifier
else
{
var name_handler = Bus.watch_name(BusType.SESSION,name,GLib.BusNameWatcherFlags.NONE,
null,
()=>{
Idle.add(()=>{
try
{
ItemIface ping_iface = Bus.get_proxy_sync(BusType.SESSION,name,path);
if (ping_iface.id == null)
{
remove(get_id(name,path));
return false;
}
} catch (Error e) {remove(get_id(name,path));}
return true;
});
},
() => {remove(get_id(name,path));}
);
name_watcher.insert(id,name_handler);
registered_status_notifier_items = get_registered_items();
status_notifier_item_registered(out id);
status_notifier_item_registered(id);
/* FIXME: PropertiesChanged for RegisteredStatusNotifierItems*/
}
}
Expand All @@ -92,9 +105,9 @@ namespace StatusNotifier
{
string outer = id.dup();
uint name = name_watcher.lookup(id);
name_watcher.remove(id);
Bus.unwatch_name(name);
status_notifier_item_unregistered(out outer);
name_watcher.remove(id);
status_notifier_item_unregistered(outer);
registered_status_notifier_items = get_registered_items();
/* FIXME PropertiesChanged for RegisteredStatusNotifierItems*/
}
Expand Down

0 comments on commit 14c59e6

Please sign in to comment.