~ubuntu-branches/ubuntu/precise/gnome-games/precise-proposed

« back to all changes in this revision

Viewing changes to libgames-support/games-conf.c

  • Committer: Package Import Robot
  • Author(s): Rodrigo Moya
  • Date: 2011-05-30 13:32:04 UTC
  • mfrom: (1.3.4)
  • mto: (163.1.3 precise)
  • mto: This revision was merged to the branch mainline in revision 143.
  • Revision ID: package-import@ubuntu.com-20110530133204-celaq1v1dsxc48q1
Tags: upstream-3.0.2
ImportĀ upstreamĀ versionĀ 3.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include <errno.h>
23
23
 
24
24
#include <gtk/gtk.h>
 
25
 
 
26
#if GTK_CHECK_VERSION (2, 90, 7)
 
27
#define GDK_KEY(symbol) GDK_KEY_##symbol
 
28
#else
25
29
#include <gdk/gdkkeysyms.h>
 
30
#define GDK_KEY(symbol) GDK_##symbol
 
31
#endif
26
32
 
27
33
#ifdef HAVE_GNOME
28
34
#include <gconf/gconf-client.h>
39
45
 
40
46
#define GAMES_CONF_GET_PRIVATE(that)(G_TYPE_INSTANCE_GET_PRIVATE ((that), GAMES_TYPE_CONF, GamesConfPrivate))
41
47
 
42
 
struct _GamesConfPrivate {
 
48
struct GamesConfPrivate {
43
49
  char *game_name;
44
50
 
45
51
#ifdef HAVE_GNOME
586
592
 * Returns the default #GamesConf instance. games_conf_init() must have
587
593
 * been called before this!
588
594
 *
589
 
 * Returns: a #GamesConf (no reference)
 
595
 * Returns: (transfer none): a #GamesConf (no reference)
590
596
 */
591
597
GamesConf *
592
598
games_conf_get_default (void)
655
661
 
656
662
/**
657
663
 * games_conf_get_string:
658
 
 * @group: the group name, or %NULL to use the default group
 
664
 * @group: (allow-none): the group name, or %NULL to use the default group
659
665
 * @key: the key name
660
 
 * @error: a location for a #GError
 
666
 * @error: (allow-none): a location for a #GError
661
667
 *
662
668
 * Returns the string associated with @key in @group, or %NULL if
663
669
 * @key is not set, or an error occurred
685
691
 
686
692
/**
687
693
 * games_conf_get_string_with_default:
688
 
 * @group: the group name, or %NULL to use the default group
 
694
 * @group: (allow-none): the group name, or %NULL to use the default group
689
695
 * @key: the key name
690
696
 * @def_value: the default value
691
697
 *
714
720
 
715
721
/**
716
722
 * games_conf_set_string:
717
 
 * @group: the group name, or %NULL to use the default group
 
723
 * @group: (allow-none): the group name, or %NULL to use the default group
718
724
 * @key: the key name
719
725
 * @value: the value to store
720
726
 *
740
746
 
741
747
/**
742
748
 * games_conf_get_string_list:
743
 
 * @group: the group name, or %NULL to use the default group
 
749
 * @group: (allow-none): the group name, or %NULL to use the default group
744
750
 * @key: the key name
745
 
 * @len: a location to store the length of the returned array
746
 
 * @error: a location for a #GError
 
751
 * @n_values: a location to store the length of the returned array
 
752
 * @error: (allow-none): a location for a #GError
747
753
 *
748
754
 * Returns the string array associated with @key in @group, or %NULL if
749
755
 * @key is not set, or an error occurred
750
756
 *
751
 
 * Returns: a newly allocated string array, or %NULL
 
757
 * Returns: (transfer full): a newly allocated string array, or %NULL
752
758
 */
753
759
char **
754
760
games_conf_get_string_list (const char *group, const char *key,
789
795
 
790
796
/**
791
797
 * games_conf_set_string_list:
792
 
 * @group: the group name, or %NULL to use the default group
 
798
 * @group: (allow-none): the group name, or %NULL to use the default group
793
799
 * @key: the key name
794
800
 * @values: the value to store
795
801
 * @n_values: the length of the @values array
827
833
 
828
834
/**
829
835
 * games_conf_get_integer:
830
 
 * @group: the group name, or %NULL to use the default group
 
836
 * @group: (allow-none): the group name, or %NULL to use the default group
831
837
 * @key: the key name
832
 
 * @error: a location for a #GError
 
838
 * @error: (allow-none): a location for a #GError
833
839
 *
834
840
 * Returns the integer associated with @key in @group, or 0 if
835
841
 * @key is not set, or an error occurred
858
864
 
859
865
/**
860
866
 * games_conf_get_integer_with_default:
861
 
 * @group: the group name, or %NULL to use the default group
 
867
 * @group: (allow-none): the group name, or %NULL to use the default group
862
868
 * @key: the key name
863
869
 * @def_value: the default value
864
870
 *
886
892
 
887
893
/**
888
894
 * games_conf_set_integer:
889
 
 * @group: the group name, or %NULL to use the default group
 
895
 * @group: (allow-none): the group name, or %NULL to use the default group
890
896
 * @key: the key name
891
897
 * @value: the value to store
892
898
 *
911
917
 
912
918
/**
913
919
 * games_conf_get_integer_list:
914
 
 * @group: the group name, or %NULL to use the default group
 
920
 * @group: (allow-none): the group name, or %NULL to use the default group
915
921
 * @key: the key name
916
 
 * @len: a location to store the length of the returned array
917
 
 * @error: a location for a #GError
 
922
 * @n_values: a location to store the length of the returned array
 
923
 * @error: (allow-none): a location for a #GError
918
924
 *
919
925
 * Returns the integer associated with @key in @group, or 0 if
920
926
 * @key is not set, or an error occurred
955
961
 
956
962
/**
957
963
 * games_conf_set_integer_list:
958
 
 * @group: the group name, or %NULL to use the default group
 
964
 * @group: (allow-none): the group name, or %NULL to use the default group
959
965
 * @key: the key name
960
966
 * @values: the value to store
961
967
 * @n_values: the length of the @values array
993
999
 
994
1000
/**
995
1001
 * games_conf_get_boolean:
996
 
 * @group: the group name, or %NULL to use the default group
 
1002
 * @group: (allow-none): the group name, or %NULL to use the default group
997
1003
 * @key: the key name
998
 
 * @error: a location for a #GError
 
1004
 * @error: (allow-none): a location for a #GError
999
1005
 *
1000
1006
 * Returns the boolean associated with @key in @group, or %FALSE if
1001
1007
 * @key is not set, or an error occurred
1023
1029
}
1024
1030
 
1025
1031
/**
1026
 
 * games_conf_get_boolean_width_default:
1027
 
 * @group: the group name, or %NULL to use the default group
 
1032
 * games_conf_get_boolean_with_default:
 
1033
 * @group: (allow-none): the group name, or %NULL to use the default group
1028
1034
 * @key: the key name
1029
1035
 * @def_value: the default value
1030
1036
 *
1051
1057
 
1052
1058
/**
1053
1059
 * games_conf_set_boolean:
1054
 
 * @group: the group name, or %NULL to use the default group
 
1060
 * @group: (allow-none): the group name, or %NULL to use the default group
1055
1061
 * @key: the key name
1056
1062
 * @value: the value to store
1057
1063
 *
1077
1083
 
1078
1084
/**
1079
1085
 * games_conf_get_double:
1080
 
 * @group: the group name, or %NULL to use the default group
 
1086
 * @group: (allow-none): the group name, or %NULL to use the default group
1081
1087
 * @key: the key name
1082
1088
 * @error: a location for a #GError
1083
1089
 *
1113
1119
 
1114
1120
/**
1115
1121
 * games_conf_set_double:
1116
 
 * @group: the group name, or %NULL to use the default group
 
1122
 * @group: (allow-none): the group name, or %NULL to use the default group
1117
1123
 * @key: the key name
1118
1124
 * @value: the value to store
1119
1125
 *
1141
1147
 
1142
1148
/**
1143
1149
 * games_conf_get_keyval:
1144
 
 * @group: the group name, or %NULL to use the default group
 
1150
 * @group: (allow-none): the group name, or %NULL to use the default group
1145
1151
 * @key: the key name
1146
 
 * @error: a location for a #GError
 
1152
 * @error: (allow-none): a location for a #GError
1147
1153
 *
1148
1154
 * Returns the keyboard key associated with @key in @group, or 0 if
1149
1155
 * @key is not set, or an error occurred
1159
1165
#ifdef HAVE_GNOME
1160
1166
  GConfValueType type;
1161
1167
  char *key_name, *value;
1162
 
  guint keyval = GDK_VoidSymbol;
 
1168
  guint keyval = GDK_KEY (VoidSymbol);
1163
1169
 
1164
1170
  key_name = get_gconf_key_name (group, key);
1165
1171
  type = get_gconf_value_type_from_schema (key_name);
1168
1174
  if (type == GCONF_VALUE_STRING) {
1169
1175
    value = gconf_client_get_string (priv->gconf_client, key_name, error);
1170
1176
    if (!value) {
1171
 
      keyval = GDK_VoidSymbol;
 
1177
      keyval = GDK_KEY (VoidSymbol);
1172
1178
    } else {
1173
1179
      keyval = gdk_keyval_from_name (value);
1174
1180
      g_free (value);
1176
1182
  } else if (type == GCONF_VALUE_INT) {
1177
1183
    keyval = gconf_client_get_int (priv->gconf_client, key_name, error);
1178
1184
    if (*error || keyval == 0)
1179
 
      keyval = GDK_VoidSymbol;
 
1185
      keyval = GDK_KEY (VoidSymbol);
1180
1186
  } else {
1181
1187
    g_warning ("Unknown value type for key %s\n", key_name);
1182
1188
  }
1186
1192
  return keyval;
1187
1193
#else
1188
1194
  char *value;
1189
 
  guint keyval = GDK_VoidSymbol;
 
1195
  guint keyval = GDK_KEY (VoidSymbol);
1190
1196
 
1191
1197
  value = g_key_file_get_string (priv->key_file, group, key, error);
1192
1198
  if (value) {
1199
1205
}
1200
1206
 
1201
1207
/**
1202
 
 * games_conf_get_keyval:
1203
 
 * @group: the group name, or %NULL to use the default group
 
1208
 * games_conf_get_keyval_with_default:
 
1209
 * @group: (allow-none): the group name, or %NULL to use the default group
1204
1210
 * @key: the key name
1205
1211
 * @default_keyval: the default value
1206
1212
 *
1221
1227
    g_error_free (error);
1222
1228
    value = default_keyval;
1223
1229
  }
1224
 
  if (value == GDK_VoidSymbol) {
 
1230
  if (value == GDK_KEY (VoidSymbol)) {
1225
1231
    value = default_keyval;
1226
1232
  }
1227
1233
 
1230
1236
 
1231
1237
/**
1232
1238
 * games_conf_set_keyval:
1233
 
 * @group: the group name, or %NULL to use the default group
 
1239
 * @group: (allow-none): the group name, or %NULL to use the default group
1234
1240
 * @key: the key name
1235
1241
 * @value: the value to store
1236
1242
 *
1245
1251
  GConfValueType type;
1246
1252
  char *key_name, *name;
1247
1253
 
1248
 
  if (value == GDK_VoidSymbol)
 
1254
  if (value == GDK_KEY (VoidSymbol))
1249
1255
    return;
1250
1256
 
1251
1257
  key_name = get_gconf_key_name (group, key);
1265
1271
#else
1266
1272
  char *name;
1267
1273
 
1268
 
  if (value == GDK_VoidSymbol)
 
1274
  if (value == GDK_KEY (VoidSymbol))
1269
1275
    return;
1270
1276
  
1271
1277
  name = gdk_keyval_name (value);
1277
1283
/**
1278
1284
 * games_conf_add_window:
1279
1285
 * @window: a #GtkWindow
1280
 
 * @group: the group to store the state in, or %NULL to use
 
1286
 * @group: (allow-none): the group to store the state in, or %NULL to use
1281
1287
 * the default group
1282
1288
 * 
1283
1289
 * Restore the window configuration, and persist changes to the window configuration: