Changeset bbdcdb47aa4624e593c227cc18c6192deaf49938
- Timestamp:
- 06/01/09 22:42:56 (3 years ago)
- Author:
- Leo Antunes <leo@…>
- Children:
- f61e5d9f981e59d438edb649a97992469056a913
- Parents:
- c954bfe63faa9d655b8f94c13a9b8e2fbaa6df96
- git-committer:
- Leo Antunes <leo@…> (06/01/09 22:42:56)
- Message:
-
finally implemented the rest of the prefs
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r0dcf20b
|
rbbdcdb4
|
|
| 1 | | Version 0.2 (2009-??-??): |
| | 1 | Version 0.2 (2009-06-01): |
| 2 | 2 | |
| 3 | | - solved problem when the auto-away feature got activated before the screensaver |
| 4 | | - added pref to select which away status should be set by the screensaver |
| | 3 | - solved problem when pidgin's auto-away got activated before |
| | 4 | the screensaver |
| | 5 | - added pref to select which away status should be set by the |
| | 6 | screensaver |
| 5 | 7 | - plugin info finally translatable |
| 6 | 8 | |
-
|
r0dcf20b
|
rbbdcdb4
|
|
| 31 | 31 | #include <version.h> |
| 32 | 32 | #include <notify.h> |
| | 33 | #include <savedstatuses.h> |
| 33 | 34 | |
| 34 | 35 | #include "i18n.h" |
| … |
… |
|
| 37 | 38 | |
| 38 | 39 | static DBusGConnection *dbus_conn = NULL; |
| | 40 | |
| | 41 | void * |
| | 42 | awayonlock_get_handle(void) |
| | 43 | { |
| | 44 | static char* handle = "awayonlock"; |
| | 45 | return handle; |
| | 46 | } |
| | 47 | |
| 39 | 48 | |
| 40 | 49 | static gboolean plugin_load(PurplePlugin *plugin) { |
| … |
… |
|
| 55 | 64 | |
| 56 | 65 | |
| | 66 | /* |
| | 67 | * Gnome-screensaver specific stuff |
| | 68 | */ |
| 57 | 69 | dbus_proxy = dbus_g_proxy_new_for_name( dbus_conn, |
| 58 | 70 | "org.gnome.ScreenSaver", |
| … |
… |
|
| 73 | 85 | G_TYPE_INVALID |
| 74 | 86 | ); |
| 75 | | |
| | 87 | |
| 76 | 88 | dbus_g_proxy_connect_signal( dbus_proxy, |
| 77 | 89 | "SessionIdleChanged", |
| … |
… |
|
| 80 | 92 | NULL |
| 81 | 93 | ); |
| | 94 | /* |
| | 95 | * END Gnome-screensaver specific stuff |
| | 96 | */ |
| | 97 | |
| | 98 | |
| | 99 | /* |
| | 100 | * avoid dangling references to savedstatuses in the config |
| | 101 | */ |
| | 102 | purple_signal_connect(purple_savedstatuses_get_handle(), "savedstatus-deleted", |
| | 103 | awayonlock_get_handle(), |
| | 104 | PURPLE_CALLBACK(prefs_status_deleted_cb), |
| | 105 | NULL |
| | 106 | ); |
| 82 | 107 | |
| 83 | 108 | purple_debug(PURPLE_DEBUG_INFO, PACKAGE, N_("plugin_load finished\n")); |
| … |
… |
|
| 89 | 114 | purple_debug(PURPLE_DEBUG_INFO, PACKAGE, N_("plugin_unload called\n")); |
| 90 | 115 | dbus_g_connection_unref(dbus_conn); |
| | 116 | purple_signals_disconnect_by_handle(awayonlock_get_handle()); |
| 91 | 117 | return TRUE; |
| 92 | 118 | } |
-
|
rc954bfe
|
rbbdcdb4
|
|
| 27 | 27 | #include "i18n.h" |
| 28 | 28 | #include "callback.h" |
| | 29 | #include "prefs.h" |
| 29 | 30 | |
| 30 | 31 | static PurpleSavedStatus *status_saved = NULL; |
| … |
… |
|
| 33 | 34 | purple_debug(PURPLE_DEBUG_INFO, PACKAGE, N_("got message from screensaver: active=%u\n"), screensaver_status); |
| 34 | 35 | |
| 35 | | PurpleSavedStatus *status_idle = purple_savedstatus_get_idleaway(); |
| | 36 | PurpleSavedStatus *status_idle; |
| | 37 | |
| | 38 | const char *awayonlock_savedstatus = purple_prefs_get_string(AWAYONLOCK_PREF_STATUS); |
| | 39 | if(g_strcmp0(awayonlock_savedstatus, "") == 0) { |
| | 40 | status_idle = purple_savedstatus_get_idleaway(); |
| | 41 | } |
| | 42 | else { |
| | 43 | status_idle = purple_savedstatus_find_by_creation_time(g_ascii_strtoull(awayonlock_savedstatus,NULL,10)); |
| | 44 | } |
| | 45 | |
| 36 | 46 | |
| 37 | 47 | PurpleSavedStatus *status_current = purple_savedstatus_get_current(); |
-
|
r0dcf20b
|
rbbdcdb4
|
|
| 29 | 29 | |
| 30 | 30 | #include "i18n.h" |
| | 31 | #include "prefs.h" |
| 31 | 32 | |
| 32 | 33 | PurplePluginPrefFrame *get_prefs_frame(PurplePlugin *plugin) { |
| … |
… |
|
| 39 | 40 | frame = purple_plugin_pref_frame_new(); |
| 40 | 41 | |
| 41 | | ppref = purple_plugin_pref_new_with_name_and_label("/plugins/core/awayonlock/status",_("Status to set on screensaver activation")); |
| | 42 | ppref = purple_plugin_pref_new_with_name_and_label(AWAYONLOCK_PREF_STATUS, _("Status to set on screensaver activation")); |
| 42 | 43 | purple_plugin_pref_set_type(ppref, PURPLE_PLUGIN_PREF_CHOICE); |
| 43 | 44 | purple_plugin_pref_add_choice(ppref, _("Default away status"), ""); |
| … |
… |
|
| 49 | 50 | statuses = g_list_next(statuses)) { |
| 50 | 51 | if(! purple_savedstatus_is_transient(statuses->data)) { |
| 51 | | purple_plugin_pref_add_choice(ppref, purple_savedstatus_get_title(statuses->data), (char *)purple_savedstatus_get_title(statuses->data)); |
| | 52 | gchar *creation_time = NULL; |
| | 53 | creation_time = g_strdup_printf("%d", purple_savedstatus_get_creation_time(statuses->data)); |
| | 54 | purple_plugin_pref_add_choice(ppref, (gchar *)purple_savedstatus_get_title(statuses->data), creation_time); |
| | 55 | /* |
| | 56 | * FIXME: memleak! how can we free this after the frame has |
| | 57 | * been destroyed? Alternatively, how could we pass a |
| | 58 | * pointer to the original creation_time inside the |
| | 59 | * PurpleSavedStatus struct? |
| | 60 | */ |
| | 61 | //g_free(creation_time); |
| 52 | 62 | } |
| 53 | 63 | } |
| … |
… |
|
| 58 | 68 | } |
| 59 | 69 | |
| | 70 | void prefs_status_deleted_cb(PurpleSavedStatus *savedstatus, gpointer data) |
| | 71 | { |
| | 72 | GList *statuses; |
| | 73 | |
| | 74 | const char *awayonlock_savedstatus = purple_prefs_get_string(AWAYONLOCK_PREF_STATUS); |
| | 75 | |
| | 76 | if(g_strcmp0(awayonlock_savedstatus, "") == 0) |
| | 77 | return; // we use the default, nevermind |
| | 78 | |
| | 79 | statuses = g_list_copy(purple_savedstatuses_get_all()); |
| | 80 | |
| | 81 | for(statuses = g_list_first(statuses); |
| | 82 | statuses; |
| | 83 | statuses = g_list_next(statuses)) { |
| | 84 | if(purple_savedstatus_get_creation_time(statuses->data) == g_ascii_strtoull(awayonlock_savedstatus,NULL,10)) { |
| | 85 | return; // found it, it wasn't deleted |
| | 86 | } |
| | 87 | } |
| | 88 | |
| | 89 | purple_debug(PURPLE_DEBUG_INFO, PACKAGE, N_("our status got deleted, clearing preference\n")); |
| | 90 | purple_prefs_set_string(AWAYONLOCK_PREF_STATUS, ""); |
| | 91 | } |
| | 92 | |
-
|
r0dcf20b
|
rbbdcdb4
|
|
| 22 | 22 | #define _AWAYONLOCK_PREFS_H |
| 23 | 23 | |
| | 24 | #include <glib.h> |
| | 25 | #include <plugin.h> |
| | 26 | #include <savedstatuses.h> |
| | 27 | |
| | 28 | #define AWAYONLOCK_PREF_STATUS "/plugins/core/awayonlock/status" |
| | 29 | |
| 24 | 30 | PurplePluginPrefFrame* get_prefs_frame(PurplePlugin*); |
| | 31 | |
| | 32 | void prefs_status_deleted_cb(PurpleSavedStatus*, gpointer); |
| 25 | 33 | |
| 26 | 34 | static PurplePluginUiInfo prefs = { |