Skip to content

Commit

Permalink
Merge branch 'master' of github.com:rilian-la-te/xfce4-sntray-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
rilian-la-te committed Oct 22, 2016
2 parents c5015cb + 8d4c7c3 commit 6099dca
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 17 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ if (ENABLE_VALAPANEL)
endif()
endif()

option(ENABLE_BUDGIE "Enable budgie-desktop plugin" ON)
if (ENABLE_BUDGIE)
pkg_check_modules(BUDGIE budgie-1.0 libpeas-1.0)
if (NOT BUDGIE_FOUND)
set(ENABLE_BUDGIE OFF)
endif()
endif()

# Configuration
configure_file (${CMAKE_SOURCE_DIR}/src/config.vala.in ${CMAKE_BINARY_DIR}/src/config.vala)

Expand Down
5 changes: 5 additions & 0 deletions data/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ if (ENABLE_VALAPANEL)
add_schema("org.valapanel.toplevel.sntray.gschema.xml")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/sntray.plugin DESTINATION ${CMAKE_INSTALL_LIBDIR}/vala-panel/applets)
endif()
if (ENABLE_BUDGIE)
include(GSettings)
add_schema("org.valapanel.toplevel.sntray.gschema.xml")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/sntray-budgie.plugin DESTINATION ${CMAKE_INSTALL_LIBDIR}/budgie-desktop/plugins)
endif()
8 changes: 8 additions & 0 deletions data/sntray-budgie.desktop.plugin.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Plugin]
Module=sntray-budgie.so
Name=StatusNotifier
Description=System tray in KDE StatusNotifierItem format
Authors=Konstantin Pugin
Copyright=Copyright © 2016 Konstantin Pugin
Website=https://github.com/rilian-la-te/xfce4-sntray-plugin
Icon=view-grid-symbolic
10 changes: 0 additions & 10 deletions data/sntray-mate.desktop.in

This file was deleted.

37 changes: 37 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,43 @@ if (ENABLE_VALAPANEL)
# Install plugin stuffs
install(TARGETS sntray-valapanel DESTINATION ${CMAKE_INSTALL_LIBDIR}/vala-panel/applets)
endif()

#################
# Budgie Panel part
#################
set(VALA_FILES_BUDGIE sntray-applet-budgie.vala)
if (ENABLE_BUDGIE)
vala_precompile(VALA_C_BUDGIE sntray-budgie
${VALA_FILES_BUDGIE}
PACKAGES
gtk+-3.0
vala-panel-sntray
budgie-1.0
OPTIONS
--vapidir=${CMAKE_CURRENT_SOURCE_DIR}/vapi
--vapidir=${CMAKE_CURRENT_BINARY_DIR}
--target-glib=2.44
--gresources=${CMAKE_CURRENT_SOURCE_DIR}/${PLUGIN_NAME}.gresource.xml
--thread
)
#####
# Plugin Library
#####
add_library (sntray-budgie SHARED
${VALA_C_CORE}
${VALA_C_DBUSMENU}
${VALA_C_BUDGIE}
${RESOURCES}
)
add_dependencies(sntray-budgie sntray-core)
include_directories(${GTK+_INCLUDE_DIRS} ${BUDGIE_INCLUDE_DIRS})
target_link_libraries(sntray-budgie ${GTK+_LIBRARIES} ${BUDGIE_LIBRARIES} -lm)
add_custom_target(sntray-budgie-ide SOURCES ${VALA_FILES_BUDGIE})

# Install plugin stuffs
install(TARGETS sntray-budgie DESTINATION ${CMAKE_INSTALL_LIBDIR}/budgie-desktop/plugins)
endif()

#################
# MATE Panel part
#################
Expand Down
89 changes: 89 additions & 0 deletions src/sntray-applet-budgie.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
using Gtk;
using GLib;
using Budgie;
using StatusNotifier;

public class SNApplet : Budgie.Plugin, Peas.ExtensionBase
{
public Applet get_panel_widget(string uid)
{
return new SNTray(uid);
}
}
public class SNTray: Budgie.Applet
{
unowned ItemBox widget;
GLib.Settings settings;
public string uuid { public set ; public get; }
public override Gtk.Widget? get_settings_ui()
{
var dlg = new ConfigDialog(widget);
dlg.configure_icon_size = false;
return dlg.get_content_area();
}

public override bool supports_settings()
{
return true;
}
public SNTray (string uuid)
{
Object(uuid: uuid);
var layout = new ItemBox();
widget = layout;
settings_schema = "org.valapanel.toplevel.sntray-valapanel";
settings_prefix = "/com/solus-project/budgie-panel/instance/sntray";
settings = get_applet_settings(uuid);
settings.bind(SHOW_APPS,layout,SHOW_APPS,SettingsBindFlags.DEFAULT);
settings.bind(SHOW_COMM,layout,SHOW_COMM,SettingsBindFlags.DEFAULT);
settings.bind(SHOW_SYS,layout,SHOW_SYS,SettingsBindFlags.DEFAULT);
settings.bind(SHOW_HARD,layout,SHOW_HARD,SettingsBindFlags.DEFAULT);
settings.bind(SHOW_OTHER,layout,SHOW_OTHER,SettingsBindFlags.DEFAULT);
settings.bind(SHOW_PASSIVE,layout,SHOW_PASSIVE,SettingsBindFlags.DEFAULT);
settings.bind(INDICATOR_SIZE,layout,INDICATOR_SIZE,SettingsBindFlags.DEFAULT);
settings.bind(USE_SYMBOLIC,layout,USE_SYMBOLIC,SettingsBindFlags.DEFAULT);
settings.bind(USE_LABELS,layout,USE_LABELS,SettingsBindFlags.DEFAULT);
settings.bind_with_mapping(INDEX_OVERRIDE,layout,INDEX_OVERRIDE,SettingsBindFlags.DEFAULT,
(SettingsBindGetMappingShared)get_vardict,
(SettingsBindSetMappingShared)set_vardict,
(void*)"i",null);
settings.bind_with_mapping(FILTER_OVERRIDE,layout,FILTER_OVERRIDE,SettingsBindFlags.DEFAULT,
(SettingsBindGetMappingShared)get_vardict,
(SettingsBindSetMappingShared)set_vardict,
(void*)"b",null);
layout.orientation = Orientation.VERTICAL; //Budgie does not support vertical panels now
panel_size_changed.connect((p,i,s)=> {
layout.indicator_size = (int)i;
});
this.add(layout);
show_all();
}
private static bool get_vardict(Value val, Variant variant,void* data)
{
var iter = variant.iterator();
string name;
Variant inner_val;
var dict = new HashTable<string,Variant?>(str_hash,str_equal);
while(iter.next("{sv}",out name, out inner_val))
dict.insert(name,inner_val);
val.set_boxed((void*)dict);
return true;
}
private static Variant set_vardict(Value val, VariantType type,void* data)
{
var builder = new VariantBuilder(type);
unowned HashTable<string,Variant?> table = (HashTable<string,Variant?>)val.get_boxed();
table.foreach((k,v)=>{
builder.add("{sv}",k,v);
});
return builder.end();
}
} // End class

[ModuleInit]
public void peas_register_types(TypeModule module)
{
// boilerplate - all modules need this
var objmodule = module as Peas.ObjectModule;
objmodule.register_extension_type(typeof(Budgie.Plugin), typeof(SNApplet));
}
9 changes: 2 additions & 7 deletions src/snwatcher.vala
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ namespace StatusNotifier
public signal void status_notifier_item_unregistered(string item);
public signal void status_notifier_host_unregistered();
/* Hashes */
private HashTable<string,uint> name_watcher;
private HashTable<string,uint> hosts;
private HashTable<string,uint> name_watcher = new HashTable<string,uint>(str_hash, str_equal);
private HashTable<string,uint> hosts = new HashTable<string,uint>(str_hash, str_equal);
/* Public properties */
public string[] registered_status_notifier_items {owned get {return get_registered_items();}}
public bool is_status_notifier_host_registered {get; private set; default = true;}
Expand Down Expand Up @@ -112,11 +112,6 @@ namespace StatusNotifier
ret += item;
return ret;
}
construct
{
name_watcher = new HashTable<string,uint>(str_hash, str_equal);
hosts = new HashTable<string,uint>(str_hash, str_equal);
}
~Watcher()
{
name_watcher.foreach((k,v)=>{Bus.unwatch_name(v);});
Expand Down

0 comments on commit 6099dca

Please sign in to comment.