GtkWidget *bar_pane_comment_new_from_config(const gchar **attribute_names, const gchar **attribute_values) { gchar *title = NULL; gchar *key = g_strdup(COMMENT_KEY); gboolean expanded = TRUE; gint height = 50; gchar *id = g_strdup("comment"); GtkWidget *ret; while (*attribute_names) { const gchar *option = *attribute_names++; const gchar *value = *attribute_values++; if (READ_CHAR_FULL("title", title)) continue; if (READ_CHAR_FULL("key", key)) continue; if (READ_BOOL_FULL("expanded", expanded)) continue; if (READ_INT_FULL("height", height)) continue; if (READ_CHAR_FULL("id", id)) continue; log_printf("unknown attribute %s = %s\n", option, value); } bar_pane_translate_title(PANE_COMMENT, id, &title); ret = bar_pane_comment_new(id, title, key, expanded, height); g_free(title); g_free(key); g_free(id); return ret; }
void bar_pane_comment_update_from_config(GtkWidget *pane, const gchar **attribute_names, const gchar **attribute_values) { PaneCommentData *pcd; pcd = g_object_get_data(G_OBJECT(pane), "pane_data"); if (!pcd) return; gchar *title = NULL; while (*attribute_names) { const gchar *option = *attribute_names++; const gchar *value = *attribute_values++; if (READ_CHAR_FULL("title", title)) continue; if (READ_CHAR_FULL("key", pcd->key)) continue; if (READ_BOOL_FULL("expanded", pcd->pane.expanded)) continue; if (READ_INT_FULL("height", pcd->height)) continue; if (READ_CHAR_FULL("id", pcd->pane.id)) continue; log_printf("unknown attribute %s = %s\n", option, value); } if (title) { bar_pane_translate_title(PANE_COMMENT, pcd->pane.id, &title); gtk_label_set_text(GTK_LABEL(pcd->pane.title), title); g_free(title); } gtk_widget_set_size_request(pcd->widget, -1, pcd->height); bar_update_expander(pane); bar_pane_comment_update(pcd); }
void bar_pane_gps_update_from_config(GtkWidget *pane, const gchar **attribute_names, const gchar **attribute_values) { PaneGPSData *pgd; gint zoom; gint int_longitude, int_latitude; gdouble longitude, latitude; pgd = g_object_get_data(G_OBJECT(pane), "pane_data"); if (!pgd) return; gchar *title = NULL; while (*attribute_names) { const gchar *option = *attribute_names++; const gchar *value = *attribute_values++; if (READ_CHAR_FULL("title", title)) continue; if (READ_CHAR_FULL("map-id", pgd->map_source)) continue; if (READ_BOOL_FULL("expanded", pgd->pane.expanded)) continue; if (READ_INT_FULL("height", pgd->height)) continue; if (READ_CHAR_FULL("id", pgd->pane.id)) continue; if (READ_INT_CLAMP_FULL("zoom-level", zoom, 1, 8)) { g_object_set(G_OBJECT(CHAMPLAIN_VIEW(pgd->gps_view)), "zoom-level", zoom, NULL); continue; } if (READ_INT_CLAMP_FULL("longitude", int_longitude, -90000000, +90000000)) { longitude = int_longitude / 1000000; g_object_set(G_OBJECT(CHAMPLAIN_VIEW(pgd->gps_view)), "longitude", longitude, NULL); continue; } if (READ_INT_CLAMP_FULL("latitude", int_latitude, -90000000, +90000000)) { latitude = int_latitude / 1000000; g_object_set(G_OBJECT(CHAMPLAIN_VIEW(pgd->gps_view)), "latitude", latitude, NULL); continue; } log_printf("unknown attribute %s = %s\n", option, value); } if (title) { bar_pane_translate_title(PANE_COMMENT, pgd->pane.id, &title); gtk_label_set_text(GTK_LABEL(pgd->pane.title), title); g_free(title); } gtk_widget_set_size_request(pgd->widget, -1, pgd->height); bar_update_expander(pane); }
GtkWidget *bar_pane_gps_new_from_config(const gchar **attribute_names, const gchar **attribute_values) { gchar *title = g_strdup(_("GPS Map")); gchar *map_id = NULL; gboolean expanded = TRUE; gint height = 350; gint zoom = 7; gdouble latitude; gdouble longitude; /* Latitude and longitude are stored in the config file as an integer of * (actual value * 1,000,000). There is no READ_DOUBLE utilty function. */ gint int_latitude = 54000000; gint int_longitude = -4000000; gchar *id = g_strdup("gps"); GtkWidget *ret; while (*attribute_names) { const gchar *option = *attribute_names++; const gchar *value = *attribute_values++; if (READ_CHAR_FULL("title", title)) continue; if (READ_CHAR_FULL("map-id", map_id)) continue; /* There is a bug in the libchamplain libraries which prevents correct * initialisation if the zoom level starts higher than 8 */ if (READ_INT_CLAMP_FULL("zoom-level", zoom, 1, 8)) continue; if (READ_INT_CLAMP_FULL("latitude", int_latitude, -90000000, +90000000)) continue; if (READ_INT_CLAMP_FULL("longitude", int_longitude, -90000000, +90000000)) continue; if (READ_BOOL_FULL("expanded", expanded)) continue; if (READ_INT_FULL("height", height)) continue; if (READ_CHAR_FULL("id", id)) continue; log_printf("unknown attribute %s = %s\n", option, value); } bar_pane_translate_title(PANE_COMMENT, id, &title); latitude = int_latitude / 1000000; longitude = int_longitude / 1000000; ret = bar_pane_gps_new(id, title, map_id, zoom, latitude, longitude, expanded, height); g_free(title); g_free(map_id); g_free(id); return ret; }
GtkWidget *bar_update_from_config(GtkWidget *bar, const gchar **attribute_names, const gchar **attribute_values) { gboolean enabled = TRUE; gint width = SIDEBAR_DEFAULT_WIDTH; while (*attribute_names) { const gchar *option = *attribute_names++; const gchar *value = *attribute_values++; if (READ_BOOL_FULL("enabled", enabled)) continue; if (READ_INT_FULL("width", width)) continue; log_printf("unknown attribute %s = %s\n", option, value); } #if !GTK_CHECK_VERSION(3,0,0) /* FIXME: In bar_size_allocate() the width obained is the allocated width. In GTK2 this * is the actual width. In GTK3 it is the *minimum* width. * This results in the info sidebar being able to increase, but not * decrease. There does not seem to be a way in GTK3 to get the actual width of * a widget. For GTK3 the only way is to disable it. The width of the sidebar * is therefore not preserved across restarts. */ gtk_widget_set_size_request(bar, width, -1); #endif if (enabled) { gtk_widget_show(bar); } else { gtk_widget_hide(bar); } return bar; }