Changeset 3355
- Timestamp:
- 11/04/07 20:30:41 (6 years ago)
- Location:
- trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-battery
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
configure.ac (modified) (1 diff)
-
src/openmoko-panel-battery.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-battery/ChangeLog
r3272 r3355 1 2007-11-02 Michael Lauer <mickey@openmoko.org> 2 3 * configure.ac: Add dbus(-glib)-1 dependency 4 * src/openmoko-panel-battery.c: 5 (battery_panel_dbus_init): Listen to dbus for charger insertion/removal events. 6 1 7 2007-10-25 Thomas Wood <thomas@openedhand.com> 2 8 -
trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-battery/configure.ac
r2563 r3355 12 12 13 13 # base deps 14 PKG_CHECK_MODULES(OPENMOKO, libmokopanelui2 )14 PKG_CHECK_MODULES(OPENMOKO, libmokopanelui2 dbus-1 dbus-glib-1) 15 15 16 16 LIBS="$LIBS $OPENMOKO_LIBS" -
trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-battery/src/openmoko-panel-battery.c
r3272 r3355 25 25 26 26 #include <gtk/gtklabel.h> 27 #include <dbus/dbus.h> 27 28 28 29 #include <apm.h> … … 37 38 } BatteryApplet; 38 39 40 static gboolean 41 timeout (BatteryApplet *applet); 42 39 43 /* applets cannot be unloaded yet */ 40 44 #if 0 … … 47 51 #endif 48 52 49 /* Called every 5 minutes */ 53 #define CHARGER_DBUS_SERVICE "org.freedesktop.PowerManagement" 54 #define CHARGER_DBUS_PATH "/org/freedesktop/PowerManagement" 55 #define CHARGER_DBUS_INTERFACE "org.freedesktop.PowerManagement" 56 57 DBusHandlerResult signal_filter (DBusConnection *bus, DBusMessage *msg, void *user_data) 58 { 59 g_debug( "signal_filter" ); 60 if ( dbus_message_is_signal( msg, CHARGER_DBUS_INTERFACE, "ChargerConnected" ) ) 61 { 62 g_debug( "connected" ); 63 timeout( user_data ); 64 return DBUS_HANDLER_RESULT_HANDLED; 65 } 66 else if ( dbus_message_is_signal( msg, CHARGER_DBUS_INTERFACE, "ChargerDisconnected" ) ) 67 { 68 g_debug( "disconnected" ); 69 timeout( user_data ); 70 return DBUS_HANDLER_RESULT_HANDLED; 71 } 72 73 g_debug( "(unknown dbus message, ignoring)" ); 74 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; 75 } 76 77 static void battery_applet_init_dbus( BatteryApplet* applet ) 78 { 79 DBusError error; 80 dbus_error_init (&error); 81 82 /* Get a connection to the system bus */ 83 DBusConnection* bus = dbus_bus_get (DBUS_BUS_SYSTEM, &error); 84 if (!bus) 85 { 86 gchar buffer[100]; 87 sprintf (buffer, "Failed to connect to the D-BUS daemon: %s", error.message); 88 g_critical (buffer); 89 dbus_error_free (&error); 90 return ; 91 } 92 g_debug("Connection to bus successfully made"); 93 94 dbus_connection_setup_with_g_main (bus, NULL); 95 96 dbus_bus_add_match (bus, "type='signal'", &error); 97 dbus_connection_add_filter (bus, signal_filter, applet, NULL); 98 } 99 100 101 /* Called frequently */ 50 102 static gboolean 51 103 timeout (BatteryApplet *applet) … … 105 157 local_time = localtime(&t); 106 158 107 //FIXME Add source watching for charger insertion event on /dev/input/event1159 battery_applet_init_dbus( applet ); 108 160 109 161 /* should use g_timeout_add_seconds() here to save power, but it is only … … 111 163 */ 112 164 applet->timeout_id = g_timeout_add ( 10 * 1000, (GSourceFunc) timeout, applet); 113 timeout(applet); 114 115 moko_panel_applet_set_icon( mokoapplet, PKGDATADIR "/Battery_00.png" ); 165 moko_panel_applet_set_icon( applet->mokoapplet, icon ); // initial status = unknown 116 166 gtk_widget_show_all( GTK_WIDGET(mokoapplet) ); 117 167 return GTK_WIDGET(mokoapplet); 118 168 } 169 22
Note: See TracChangeset
for help on using the changeset viewer.
