Changeset bbdcdb47aa4624e593c227cc18c6192deaf49938

Show
Ignore:
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:
5 modified

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r0dcf20b rbbdcdb4  
    1 Version 0.2 (2009-??-??): 
     1Version 0.2 (2009-06-01): 
    22 
    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 
    57        - plugin info finally translatable 
    68 
  • awayonlock.c

    r0dcf20b rbbdcdb4  
    3131#include <version.h> 
    3232#include <notify.h> 
     33#include <savedstatuses.h> 
    3334 
    3435#include "i18n.h" 
     
    3738 
    3839static DBusGConnection *dbus_conn = NULL; 
     40 
     41void * 
     42awayonlock_get_handle(void) 
     43{ 
     44        static char* handle = "awayonlock"; 
     45        return handle; 
     46} 
     47 
    3948 
    4049static gboolean plugin_load(PurplePlugin *plugin) { 
     
    5564         
    5665 
     66        /* 
     67         * Gnome-screensaver specific stuff 
     68         */ 
    5769        dbus_proxy = dbus_g_proxy_new_for_name( dbus_conn, 
    5870                        "org.gnome.ScreenSaver", 
     
    7385                        G_TYPE_INVALID 
    7486                        ); 
    75          
     87 
    7688        dbus_g_proxy_connect_signal( dbus_proxy, 
    7789                        "SessionIdleChanged", 
     
    8092                        NULL 
    8193                        ); 
     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                                                ); 
    82107 
    83108        purple_debug(PURPLE_DEBUG_INFO, PACKAGE, N_("plugin_load finished\n")); 
     
    89114        purple_debug(PURPLE_DEBUG_INFO, PACKAGE, N_("plugin_unload called\n")); 
    90115        dbus_g_connection_unref(dbus_conn); 
     116        purple_signals_disconnect_by_handle(awayonlock_get_handle()); 
    91117        return TRUE; 
    92118} 
  • callback.c

    rc954bfe rbbdcdb4  
    2727#include "i18n.h" 
    2828#include "callback.h" 
     29#include "prefs.h" 
    2930 
    3031static PurpleSavedStatus *status_saved = NULL; 
     
    3334        purple_debug(PURPLE_DEBUG_INFO, PACKAGE, N_("got message from screensaver: active=%u\n"), screensaver_status); 
    3435 
    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 
    3646 
    3747        PurpleSavedStatus *status_current = purple_savedstatus_get_current(); 
  • prefs.c

    r0dcf20b rbbdcdb4  
    2929 
    3030#include "i18n.h" 
     31#include "prefs.h" 
    3132 
    3233PurplePluginPrefFrame *get_prefs_frame(PurplePlugin *plugin) { 
     
    3940        frame = purple_plugin_pref_frame_new(); 
    4041 
    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")); 
    4243        purple_plugin_pref_set_type(ppref, PURPLE_PLUGIN_PREF_CHOICE); 
    4344        purple_plugin_pref_add_choice(ppref, _("Default away status"), ""); 
     
    4950            statuses = g_list_next(statuses)) { 
    5051                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); 
    5262                } 
    5363        } 
     
    5868} 
    5969 
     70void 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 
  • prefs.h

    r0dcf20b rbbdcdb4  
    2222#define _AWAYONLOCK_PREFS_H 
    2323 
     24#include <glib.h> 
     25#include <plugin.h> 
     26#include <savedstatuses.h> 
     27 
     28#define AWAYONLOCK_PREF_STATUS "/plugins/core/awayonlock/status" 
     29 
    2430PurplePluginPrefFrame* get_prefs_frame(PurplePlugin*); 
     31 
     32void prefs_status_deleted_cb(PurpleSavedStatus*, gpointer); 
    2533 
    2634static PurplePluginUiInfo prefs = {