settings_utils.c File Reference

#include <sys/time.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <gconf/gconf-client.h>
#include "log.h"
#include "ipc.h"
#include "settings.h"
#include "settings_utils.h"
Include dependency graph for settings_utils.c:

Go to the source code of this file.

Functions

GtkWidget * create_separator_widgets ()
void set_popup_window_style (GtkWindow *window)
gboolean set_date_time (time_t t)
void gconf_initialize ()
void gconf_finalize ()
int get_value_int (const char *key)
gboolean set_value_int (const char *key, int new_value)
gboolean get_value_bool (const char *key)
gboolean set_value_bool (const char *key, gboolean new_value)
const char * get_value_string (const char *key)
gboolean set_value_string (const char *key, const char *new_value)
GSList * get_value_string_list (const char *key)
GArray * get_int_array (const gchar *key)
gboolean set_int_array (const gchar *key, const GArray *new_value)

Variables

static GConfClient * client = NULL

Function Documentation

GtkWidget* create_separator_widgets (  ) 

Definition at line 75 of file settings_utils.c.

References SETTINGS_SEPARATOR_HEIGHT.

Referenced by create_account_window(), create_continue_widgets(), create_descriptive_text_widgets(), and create_timezone_widget().

00076 {
00077     GtkWidget* separator = gtk_event_box_new();
00078     gtk_widget_set_name(separator, "irex-settings-separator");
00079     gtk_widget_set_size_request(separator, -1, SETTINGS_SEPARATOR_HEIGHT);
00080     return separator;
00081 }

Here is the caller graph for this function:

void gconf_finalize (  ) 

Definition at line 123 of file settings_utils.c.

References client.

Referenced by main_quit().

00124 {
00125     if (client)
00126     {
00127         g_object_unref(client);
00128         client = NULL;
00129     }
00130 }

Here is the caller graph for this function:

void gconf_initialize (  ) 

Definition at line 115 of file settings_utils.c.

References client.

Referenced by main().

00116 {
00117     if (client == NULL)
00118     {
00119         client = gconf_client_get_default();
00120     }
00121 }

Here is the caller graph for this function:

GArray* get_int_array ( const gchar *  key  ) 

Definition at line 174 of file settings_utils.c.

References client.

Referenced by load_margins_settings().

00175 {
00176     GConfValue *gc_value = NULL;
00177     GArray *ret = NULL;
00178 
00179     g_assert(client);
00180     g_assert(key && *key);
00181 
00182     gc_value = gconf_client_get (client, key, NULL);
00183     if (gc_value == NULL)
00184     {
00185         return NULL;
00186     }
00187 
00188     if (gc_value->type == GCONF_VALUE_LIST
00189         && gconf_value_get_list_type (gc_value) == GCONF_VALUE_INT)
00190     {
00191         GSList *elt;
00192 
00193         ret = g_array_new (FALSE, FALSE, sizeof (gint));
00194         for (elt = gconf_value_get_list (gc_value); 
00195              elt != NULL; 
00196              elt = g_slist_next (elt))
00197         {
00198             int i = gconf_value_get_int ((GConfValue *) elt->data);
00199             g_array_append_val (ret, i);
00200         }
00201     }
00202 
00203     if (gc_value != NULL)
00204     {
00205         gconf_value_free (gc_value);
00206     }
00207     return ret;
00208 }

Here is the caller graph for this function:

gboolean get_value_bool ( const char *  key  ) 

Definition at line 145 of file settings_utils.c.

References client.

Referenced by load_advanced_settings(), load_flightmode_settings(), load_flipbar_settings(), load_power_settings(), and load_sensor_settings().

00146 {
00147     return gconf_client_get_bool(client, key, NULL);
00148 }

Here is the caller graph for this function:

int get_value_int ( const char *  key  ) 

Definition at line 133 of file settings_utils.c.

References client.

Referenced by load_power_settings().

00134 {
00135     return gconf_client_get_int(client, key, NULL);
00136 }

Here is the caller graph for this function:

const char* get_value_string ( const char *  key  ) 

Definition at line 157 of file settings_utils.c.

References client.

Referenced by load_account_settings(), load_language_settings(), and load_rotation_settings().

00158 {
00159     return gconf_client_get_string(client, key, NULL);
00160 }

Here is the caller graph for this function:

GSList* get_value_string_list ( const char *  key  ) 

Definition at line 169 of file settings_utils.c.

References client.

Referenced by get_available_languages(), and get_available_locales().

00170 {
00171     return gconf_client_get_list(client, key, GCONF_VALUE_STRING, NULL);
00172 }

Here is the caller graph for this function:

gboolean set_date_time ( time_t  t  ) 

Definition at line 96 of file settings_utils.c.

References LOGPRINTF.

Referenced by datetime_base_save_datetime().

00097 {
00098     LOGPRINTF("entry");
00099     gboolean ret = TRUE;
00100 #ifndef WIN32
00101     // set system clock 
00102     struct timeval tv;
00103     memset(&tv, 0, sizeof(struct timeval));
00104     tv.tv_sec = t;
00105     ret = (0 == settimeofday(&tv, NULL));
00106     LOGPRINTF("returned %d", ret);
00107 
00108     // synchronise hardware clock
00109     system("/sbin/hwclock -w -u");
00110 #endif
00111     return ret;
00112 }

Here is the caller graph for this function:

gboolean set_int_array ( const gchar *  key,
const GArray *  new_value 
)

Definition at line 210 of file settings_utils.c.

References client.

Referenced by save_margins_settings().

00211 {
00212     gboolean ret = FALSE;
00213     GSList *list = NULL;
00214 
00215     g_assert(client);
00216     g_assert(key && *key);
00217     g_return_val_if_fail(new_value != NULL, FALSE);
00218 
00219     unsigned int i;
00220     for (i = 0; i < new_value->len; i++)
00221     {
00222         gint val = g_array_index (new_value, gint, i);
00223         list = g_slist_append (list, GINT_TO_POINTER(val));
00224     }
00225 
00226     ret = gconf_client_set_list (client, key, GCONF_VALUE_INT, list, NULL);
00227 
00228     g_slist_free (list);
00229 
00230     return ret;
00231 }

Here is the caller graph for this function:

void set_popup_window_style ( GtkWindow *  window  ) 

Definition at line 84 of file settings_utils.c.

00085 {
00086     gtk_window_set_type_hint(window, GDK_WINDOW_TYPE_HINT_DIALOG);
00087     gtk_window_set_decorated(window, FALSE);
00088     gtk_widget_realize(GTK_WIDGET(window));
00089     gdk_window_set_decorations(GTK_WIDGET(window)->window, GDK_DECOR_BORDER);
00090 
00091     // Put the window in the center of its parent.
00092     gtk_window_set_position(window, GTK_WIN_POS_CENTER_ON_PARENT);
00093 }

gboolean set_value_bool ( const char *  key,
gboolean  new_value 
)

Definition at line 151 of file settings_utils.c.

References client.

Referenced by save_advanced_settings(), save_flightmode_settings(), save_flipbar_settings(), save_power_settings(), and save_sensor_settings().

00152 {
00153     return gconf_client_set_bool(client, key, new_value, NULL);
00154 }

Here is the caller graph for this function:

gboolean set_value_int ( const char *  key,
int  new_value 
)

Definition at line 139 of file settings_utils.c.

References client.

Referenced by save_power_settings().

00140 {
00141     return gconf_client_set_int(client, key, new_value, NULL);
00142 }

Here is the caller graph for this function:

gboolean set_value_string ( const char *  key,
const char *  new_value 
)

Definition at line 163 of file settings_utils.c.

References client.

Referenced by save_account_settings(), save_language_settings(), and save_rotation_settings().

00164 {
00165     return gconf_client_set_string(client, key, new_value, NULL);
00166 }

Here is the caller graph for this function:


Variable Documentation

GConfClient* client = NULL [static]
Generated by  doxygen 1.6.2-20100208