| | 144 | /// @brief Gets an integer configuration option. |
| | 145 | /// |
| | 146 | /// @param group Configuration group where the key belongs. |
| | 147 | /// @param key The key name to retrieve its value. |
| | 148 | /// @param defaultValue The default value to return if @a key doesn't exists. |
| | 149 | /// |
| | 150 | /// @return The value of the @a key in @a group or @a defaultValue if @a key |
| | 151 | /// doesn't exists. |
| | 152 | /// |
| | 153 | gint |
| | 154 | Config::getInteger (const gchar *group, const gchar *key, gint defaultValue) |
| | 155 | { |
| | 156 | gint value = defaultValue; |
| | 157 | |
| | 158 | if ( g_key_file_has_key (m_Values, group, key, NULL) ) |
| | 159 | { |
| | 160 | GError *error = NULL; |
| | 161 | gint savedValue = g_key_file_get_integer (m_Values, group, key, &error); |
| | 162 | if ( NULL == error ) |
| | 163 | { |
| | 164 | value = savedValue; |
| | 165 | } |
| | 166 | else |
| | 167 | { |
| | 168 | g_warning ("Error reading key '%s' from group '%s': %s\n", |
| | 169 | key, group, error->message); |
| | 170 | g_error_free (error); |
| | 171 | } |
| | 172 | } |
| | 173 | |
| | 174 | return value; |
| | 175 | } |
| | 176 | |
| | 177 | /// |
| | 338 | } |
| | 339 | |
| | 340 | /// |
| | 341 | /// @brief Sets the zoom to fit option. |
| | 342 | /// |
| | 343 | /// @param activate Set to TRUE to activate the zoom to fit option. FALSE |
| | 344 | /// otherwise. |
| | 345 | /// |
| | 346 | void |
| | 347 | Config::setZoomToFit (gboolean activate) |
| | 348 | { |
| | 349 | g_key_file_set_boolean (m_Values, "main window", "zoomToFit", activate); |
| | 350 | g_key_file_set_boolean (m_Values, "main window", "zoomToWidth", |
| | 351 | !activate && zoomToWidth ()); |
| | 352 | } |
| | 353 | |
| | 354 | /// |
| | 355 | /// @brief Sets the zoom to with option. |
| | 356 | /// |
| | 357 | /// @param activate Set to TRUE to activate the zoom to width option. FALSE |
| | 358 | /// otherwise. |
| | 359 | /// |
| | 360 | void |
| | 361 | Config::setZoomToWidth (gboolean activate) |
| | 362 | { |
| | 363 | g_key_file_set_boolean (m_Values, "main window", "zoomToFit", |
| | 364 | !activate && zoomToFit ()); |
| | 365 | g_key_file_set_boolean (m_Values, "main window", "zoomToWidth", activate); |
| | 366 | } |
| | 367 | |
| | 368 | /// |
| | 369 | /// @brief Gets the zoom to fit option. |
| | 370 | /// |
| | 371 | /// @return TRUE if the zoom to fit option is activated. FALSE otherwise. |
| | 372 | /// |
| | 373 | gboolean |
| | 374 | Config::zoomToFit () |
| | 375 | { |
| | 376 | return getBoolean ("main window", "zoomToFit", DEFAULT_ZOOM_TO_FIT); |
| | 377 | } |
| | 378 | |
| | 379 | /// |
| | 380 | /// @brief Gets the zoom to width option. |
| | 381 | /// |
| | 382 | /// @return TRUE if the zoom to width option is activated. FALSE otherwise. |
| | 383 | /// |
| | 384 | gboolean |
| | 385 | Config::zoomToWidth () |
| | 386 | { |
| | 387 | return getBoolean ("main window", "zoomToWidth", DEFAULT_ZOOM_TO_WIDTH); |