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:
1 modified

Legend:

Unmodified
Added
Removed
  • 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