void bg_nle_track_widget_update_parameters(bg_nle_track_widget_t * w, bg_cfg_section_t * s) { const char * str; bg_cfg_section_get_parameter_string(s, "name", &str); gtk_expander_set_label(GTK_EXPANDER(w->panel), str); gtk_container_check_resize(GTK_CONTAINER(gtk_widget_get_parent(w->panel))); }
void gui_prompt_show(const gchar * message) { gtk_label_set_text(GTK_LABEL(prompt_lbl), message); /* Force resize of the notebook, this is needed because * GTK does not redraw when the text in a label changes. */ gtk_container_check_resize(GTK_CONTAINER(develop_notebook)); gtk_notebook_set_current_page(GTK_NOTEBOOK(develop_notebook), 3); }
int clip_GTK_CONTAINERCHECKRESIZE(ClipMachine * cm) { C_widget *ccon = _fetch_cw_arg(cm); CHECKCWID(ccon,GTK_IS_CONTAINER); gtk_container_check_resize(GTK_CONTAINER(ccon->widget)); return 0; err: return 1; }
static void gtk_message_toggle_repeats(GtkWidget *button, gpointer *userdata) { DiaMessageInfo *msginfo = (DiaMessageInfo*)userdata; if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) gtk_widget_show(msginfo->repeat_view); else { gtk_widget_hide(msginfo->repeat_view); gtk_container_check_resize(GTK_CONTAINER(msginfo->dialog)); } }
static gboolean aoview_eeprom_parse(struct aoview_serial *serial, char *line) { char cmd; int tick; int a; int b; int serial_number; const char *name; char *utf8_name; if (!strcmp(line, "end")) { aoview_eeprom_done(serial); return FALSE; } if (sscanf(line, "serial-number %u", &serial_number) == 1) { aoview_file_set_serial(eeprom_file, serial_number); } else if (sscanf(line, "%c %x %x %x", &cmd, &tick, &a, &b) == 4) { if (cmd == 'F') aoview_file_set_flight(eeprom_file, b); aoview_file_printf(eeprom_file, "%s\n", line); if (cmd == 'S' && a == 8) { aoview_eeprom_done(serial); return FALSE; } if (!eeprom_save_shown) { name = aoview_file_name(eeprom_file); if (name) { utf8_name = g_filename_to_utf8(name, -1, NULL, NULL, NULL); if (!utf8_name) utf8_name = (char *) name; gtk_widget_set_sensitive(eeprom_save_close, FALSE); gtk_window_set_title(GTK_WINDOW(eeprom_save_done), "Saving EEPROM data"); gtk_message_dialog_set_markup(eeprom_save_done, "<b>Saving EEPROM data as</b>"); gtk_message_dialog_format_secondary_text(eeprom_save_done, "%s", utf8_name); if (utf8_name != name) g_free(utf8_name); gtk_container_check_resize(GTK_CONTAINER(eeprom_save_done)); gtk_widget_show(GTK_WIDGET(eeprom_save_done)); eeprom_save_shown = TRUE; eeprom_save_close = gtk_window_get_default_widget(GTK_WINDOW(eeprom_save_done)); if (eeprom_save_close) gtk_widget_set_sensitive(eeprom_save_close, FALSE); } } } return TRUE; }
static void set_parameter(void * data, const char * name, const bg_parameter_value_t * val) { bg_nle_track_widget_t * t = data; if(!name) return; if(!strcmp(name, "name")) { gtk_expander_set_label(GTK_EXPANDER(t->panel), val->val_str); gtk_container_check_resize(GTK_CONTAINER(gtk_widget_get_parent(t->panel))); } }
static void network_gui_update (void) { #ifdef GGZ_CLIENT if (ggz_network_mode) { gtk_widget_show (chat); } else { gtk_widget_hide (chat); } gtk_action_set_visible (new_game_action, !ggz_network_mode); gtk_action_set_visible (player_list_action, ggz_network_mode); gtk_container_check_resize (GTK_CONTAINER (window)); #endif }
void glade_gtk_action_bar_set_child_property (GladeWidgetAdaptor * adaptor, GObject * container, GObject * child, const gchar * id, GValue * value) { if (!strcmp (id, "position")) glade_gtk_action_bar_set_child_position (container, child, value); else if (!strcmp (id, "pack-type")) glade_gtk_action_bar_set_child_pack_type (container, child, value); else GWA_GET_CLASS (GTK_TYPE_CONTAINER)->child_set_property (adaptor, container, child, id, value); gtk_container_check_resize (GTK_CONTAINER (container)); }
static void glade_gtk_table_refresh_placeholders (GtkTable * table) { guint n_columns, n_rows, i, j; gchar *child_map; gpointer *placeholder_map; g_object_get (table, "n-columns", &n_columns, "n-rows", &n_rows, NULL); glade_gtk_table_build_occupation_maps (table, n_columns, n_rows, &child_map, &placeholder_map); for (i = 0; i < n_columns; i++) { for (j = 0; j < n_rows; j++) { gpointer placeholder = TABLE_OCCUPIED(placeholder_map, n_columns, i, j); if (TABLE_OCCUPIED(child_map, n_columns, i, j)) { if (placeholder) { gtk_container_remove (GTK_CONTAINER (table), GTK_WIDGET (placeholder)); } } else { if (!placeholder) { G_GNUC_BEGIN_IGNORE_DEPRECATIONS; gtk_table_attach_defaults (table, glade_placeholder_new (), i, i + 1, j, j + 1); G_GNUC_END_IGNORE_DEPRECATIONS; } } } } g_free(child_map); g_free(placeholder_map); if (gtk_widget_get_realized (GTK_WIDGET (table))) gtk_container_check_resize (GTK_CONTAINER (table)); }
static void glade_gtk_grid_refresh_placeholders (GtkGrid *grid, gboolean load_finished) { GladeWidget *widget; GladeProject *project; GtkContainer *container; GList *list, *children; guint n_columns, n_rows; gint i, j; widget = glade_widget_get_from_gobject (grid); project = glade_widget_get_project (widget); /* Wait for project to finish loading */ if ((project && glade_project_is_loading (project)) && !load_finished) return; glade_widget_property_get (widget, "n-columns", &n_columns); glade_widget_property_get (widget, "n-rows", &n_rows); container = GTK_CONTAINER (grid); children = gtk_container_get_children (container); for (list = children; list && list->data; list = list->next) { GtkWidget *child = list->data; if (GLADE_IS_PLACEHOLDER (child)) gtk_container_remove (container, child); } g_list_free (children); children = gtk_container_get_children (container); for (i = 0; i < n_columns; i++) for (j = 0; j < n_rows; j++) if (glade_gtk_grid_has_child (grid, children, i, j) == FALSE) gtk_grid_attach (grid, glade_placeholder_new (), i, j, 1, 1); if (gtk_widget_get_realized (GTK_WIDGET (grid))) gtk_container_check_resize (container); g_list_free (children); }
void frontend_resource_change(Resource type, gint new_amount) { if (type < NO_RESOURCE) { char buff[16]; gint res[NO_RESOURCE]; memset(res, 0, sizeof(res)); res[type] = new_amount; snprintf(buff, sizeof(buff), "%d", resource_total()); gtk_label_set_text(GTK_LABEL(asset_total_label), buff); /* Force resize of the table, this is needed because * GTK does not correctly redraw a label when the amounts * cross the barrier of 1 or 2 positions. */ gtk_container_check_resize(GTK_CONTAINER (gtk_widget_get_parent (asset_total_label))); rebuild_single_resource(type); } frontend_gui_update(); }
void vi_list_refresh(struct vi_list_t *list) { int width; int height; int x; int y; int count; int i; GtkStyle *style; GList *child; /* Clear current item list and empty layout */ while (list->item_list->count) vi_list_item_free(list_remove_at(list->item_list, 0)); while ((child = gtk_container_get_children(GTK_CONTAINER(list->widget)))) gtk_container_remove(GTK_CONTAINER(list->widget), child->data); /* Get 'list' widget size */ width = gtk_widget_get_allocated_width(list->widget); height = gtk_widget_get_allocated_height(list->widget); list->width = width; list->height = height; /* Background color */ GdkColor color; style = gtk_widget_get_style(list->widget); color = style->bg[GTK_STATE_NORMAL]; /* Fill it with labels */ x = 0; y = 0; count = list->elem_list->count; for (i = 0; i < count; i++) { int last; struct vi_list_item_t *item; void *elem; char str1[MAX_STRING_SIZE]; char str2[MAX_STRING_SIZE]; char *comma; GtkWidget *label; GtkWidget *event_box; PangoAttrList *attrs; PangoAttribute *size_attr; GtkRequisition req; /* Create list item */ item = vi_list_item_create(); /* Get current element */ elem = list_get(list->elem_list, i); /* Create label */ comma = i < count - 1 ? "," : ""; if (list->get_elem_name) (*list->get_elem_name)(elem, str1, sizeof str1); else snprintf(str1, sizeof str1, "item-%d", i); snprintf(str2, sizeof str2, "%s%s", str1, comma); label = gtk_label_new(str2); gtk_label_set_use_markup(GTK_LABEL(label), TRUE); /* Set label font attributes */ attrs = pango_attr_list_new(); size_attr = pango_attr_size_new_absolute(list->text_size << 10); pango_attr_list_insert(attrs, size_attr); gtk_label_set_attributes(GTK_LABEL(label), attrs); /* Get position */ gtk_widget_get_preferred_size(label, &req, NULL); last = 0; if (x > 0 && x + req.width >= width) { x = 0; y += req.height; if (y + 2 * req.height >= height && i < count - 1) { snprintf(str1, sizeof str1, "+ %d more", count - i); gtk_label_set_text(GTK_LABEL(label), str1); gtk_widget_get_preferred_size(label, &req, NULL); last = 1; } } /* Create event box */ event_box = gtk_event_box_new(); gtk_widget_modify_bg(event_box, GTK_STATE_NORMAL, &color); gtk_container_add(GTK_CONTAINER(event_box), label); gtk_widget_add_events(event_box, GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_BUTTON_PRESS_MASK); /* Events for event box */ g_signal_connect(G_OBJECT(event_box), "enter-notify-event", G_CALLBACK(vi_list_item_enter_notify_event), item); g_signal_connect(G_OBJECT(event_box), "leave-notify-event", G_CALLBACK(vi_list_item_leave_notify_event), item); if (last) g_signal_connect(G_OBJECT(event_box), "button-press-event", G_CALLBACK(vi_list_item_more_press_event), item); else g_signal_connect(G_OBJECT(event_box), "button-press-event", G_CALLBACK(vi_list_item_button_press_event), item); /* Insert event box in 'list' layout */ gtk_layout_put(GTK_LAYOUT(list->widget), event_box, x, y); /* Initialize item */ item->list = list; item->elem = elem; item->event_box = event_box; item->label = label; list_add(list->item_list, item); /* Advance */ x += req.width + 5; if (last) break; } /* Show all new widgets */ gtk_widget_show_all(list->widget); gtk_container_check_resize(GTK_CONTAINER(list->widget)); }
void glade_gtk_box_set_child_property (GladeWidgetAdaptor * adaptor, GObject * container, GObject * child, const gchar * property_name, GValue * value) { GladeWidget *gbox, *gchild, *gchild_iter; GList *children, *list; gboolean is_position; gint old_position, iter_position, new_position; static gboolean recursion = FALSE; g_return_if_fail (GTK_IS_BOX (container)); g_return_if_fail (GTK_IS_WIDGET (child)); g_return_if_fail (property_name != NULL || value != NULL); gbox = glade_widget_get_from_gobject (container); gchild = glade_widget_get_from_gobject (child); g_return_if_fail (GLADE_IS_WIDGET (gbox)); if (gtk_widget_get_parent (GTK_WIDGET (child)) != GTK_WIDGET (container)) return; /* Get old position */ if ((is_position = (strcmp (property_name, "position") == 0)) != FALSE) { gtk_container_child_get (GTK_CONTAINER (container), GTK_WIDGET (child), property_name, &old_position, NULL); /* Get the real value */ new_position = g_value_get_int (value); } if (is_position && recursion == FALSE) { children = glade_widget_get_children (gbox); children = g_list_sort (children, (GCompareFunc) sort_box_children); for (list = children; list; list = list->next) { gchild_iter = glade_widget_get_from_gobject (list->data); if (gchild_iter == gchild) { gtk_box_reorder_child (GTK_BOX (container), GTK_WIDGET (child), new_position); continue; } /* Get the old value from glade */ glade_widget_pack_property_get (gchild_iter, "position", &iter_position); /* Search for the child at the old position and update it */ if (iter_position == new_position && glade_property_superuser () == FALSE) { /* Update glade with the real value */ recursion = TRUE; glade_widget_pack_property_set (gchild_iter, "position", old_position); recursion = FALSE; continue; } else { gtk_box_reorder_child (GTK_BOX (container), GTK_WIDGET (list->data), iter_position); } } for (list = children; list; list = list->next) { gchild_iter = glade_widget_get_from_gobject (list->data); /* Refresh values yet again */ glade_widget_pack_property_get (gchild_iter, "position", &iter_position); gtk_box_reorder_child (GTK_BOX (container), GTK_WIDGET (list->data), iter_position); } if (children) g_list_free (children); } /* Chain Up */ if (!is_position) GWA_GET_CLASS (GTK_TYPE_CONTAINER)->child_set_property (adaptor, container, child, property_name, value); gtk_container_check_resize (GTK_CONTAINER (container)); }