/** * ppg_animation_load_begin_values: * @animation: (in): A #PpgAnimation. * * Load the begin values for all the properties we are about to * animate. * * Returns: None. * Side effects: None. */ static void ppg_animation_load_begin_values (PpgAnimation *animation) { PpgAnimationPrivate *priv; GtkContainer *container; Tween *tween; gint i; g_return_if_fail(PPG_IS_ANIMATION(animation)); priv = animation->priv; for (i = 0; i < priv->tweens->len; i++) { tween = &g_array_index(priv->tweens, Tween, i); g_value_reset(&tween->begin); if (tween->is_child) { container = GTK_CONTAINER(gtk_widget_get_parent(priv->target)); gtk_container_child_get_property(container, priv->target, tween->pspec->name, &tween->begin); } else { g_object_get_property(priv->target, tween->pspec->name, &tween->begin); } } }
void glade_gtk_container_replace_child (GladeWidgetAdaptor * adaptor, GtkWidget * container, GtkWidget * current, GtkWidget * new_widget) { GParamSpec **param_spec; GladePropertyClass *pclass; GValue *value; guint nproperties; guint i; g_return_if_fail (gtk_widget_get_parent (current) == container); param_spec = gtk_container_class_list_child_properties (G_OBJECT_GET_CLASS (container), &nproperties); value = g_malloc0 (sizeof (GValue) * nproperties); for (i = 0; i < nproperties; i++) { g_value_init (&value[i], param_spec[i]->value_type); gtk_container_child_get_property (GTK_CONTAINER (container), current, param_spec[i]->name, &value[i]); } gtk_container_remove (GTK_CONTAINER (container), current); gtk_container_add (GTK_CONTAINER (container), new_widget); for (i = 0; i < nproperties; i++) { /* If the added widget is a placeholder then we * want to keep all the "tranfer-on-paste" properties * as default so that it looks fresh (transfer-on-paste * properties dont effect the position/slot inside a * contianer) */ if (GLADE_IS_PLACEHOLDER (new_widget)) { pclass = glade_widget_adaptor_get_pack_property_class (adaptor, param_spec[i]->name); if (pclass && glade_property_class_transfer_on_paste (pclass)) continue; } gtk_container_child_set_property (GTK_CONTAINER (container), new_widget, param_spec[i]->name, &value[i]); } for (i = 0; i < nproperties; i++) g_value_unset (&value[i]); g_free (param_spec); g_free (value); }
void glade_gtk_container_get_child_property (GladeWidgetAdaptor * adaptor, GObject * container, GObject * child, const gchar * property_name, GValue * value) { if (gtk_widget_get_parent (GTK_WIDGET (child)) == GTK_WIDGET (container)) gtk_container_child_get_property (GTK_CONTAINER (container), GTK_WIDGET (child), property_name, value); }
static void gui_move(GtkWidget* window, GtkLayout* screen, gint x, gint y) { if(GTK_IS_WINDOW(window)) { gtk_window_move(GTK_WINDOW(window), x, y); } else { if(gtk_widget_get_parent(window) != GTK_WIDGET(screen)) //gtk_layout_put(screen, window, x, y); g_assert(0 && "gui_move not a child"); else { GValue value_x; GValue value_y; memset(&value_x, 0, sizeof(GValue)); memset(&value_y, 0, sizeof(GValue)); g_value_init(&value_x, G_TYPE_INT); g_value_init(&value_y, G_TYPE_INT); gtk_container_child_get_property(GTK_CONTAINER(screen), window, "x", &value_x); gtk_container_child_get_property(GTK_CONTAINER(screen), window, "y", &value_y); if(x != g_value_get_int (&value_x) || y != g_value_get_int(&value_y)) gtk_layout_move(screen, window, x, y); } } }
static void get_property_value (GObject *object, GParamSpec *pspec, GValue *value) { if (is_child_property (pspec)) { GtkWidget *widget = GTK_WIDGET (object); GtkWidget *parent = gtk_widget_get_parent (widget); gtk_container_child_get_property (GTK_CONTAINER (parent), widget, pspec->name, value); } else g_object_get_property (object, pspec->name, value); }
/** /brief /author Peter G Baum, William J Giddings **/ static void getMaxChildProperty ( GtkWidget *child, gpointer data ) { MaxChildStruct *ms = ( MaxChildStruct * ) data; guint val; GValue gValue = { 0 }; g_value_init ( &gValue, G_TYPE_UINT ); gtk_container_child_get_property ( ms->container, child, ms->property, &gValue ); val = g_value_get_uint ( &gValue ); if ( ms->val < val ) ms->val = val; }
void ags_machine_popup_move_down_activate_callback(GtkWidget *widget, AgsMachine *machine) { GValue val={0,}; g_value_init (&val, G_TYPE_INT); gtk_container_child_get_property(GTK_CONTAINER(GTK_WIDGET(machine)->parent), GTK_WIDGET(machine), "position", &val); if(g_value_get_int (&val) < g_list_length(gtk_container_get_children((GtkContainer *) GTK_WIDGET(machine)->parent)) - 1){ gtk_box_reorder_child(GTK_BOX(GTK_WIDGET(machine)->parent), GTK_WIDGET(machine), g_value_get_int (&val) + 1); } g_value_unset (&val); }
OOP container_get_child_property (GtkContainer *aParent, GtkWidget *aChild, const char *aProperty) { GParamSpec *spec; GValue result = {0,}; g_return_val_if_fail (GTK_WIDGET (aParent) == gtk_widget_get_parent (GTK_WIDGET (aChild)), _gtk_vm_proxy->nilOOP); spec = gtk_container_class_find_child_property (G_OBJECT_GET_CLASS (aParent), aProperty); g_value_init (&result, spec->value_type); gtk_container_child_get_property (aParent, aChild, aProperty, &result); return (g_value_convert_to_oop (&result)); }
/** * get_box_widget_at_pos: * @box: #GtkBox to extract child from * @pos: index of the child to retrieve * * Extracts a child widget from a #GtkBox. * * Return value: (transfer none): child widget from the box */ GtkWidget * get_box_widget_at_pos (GtkBox *box, guint pos) { GtkWidget *ret = NULL; GList *children = gtk_container_get_children (GTK_CONTAINER (box)); GList *tem; for (tem = children; tem; tem = tem->next) { GValue thispos = { 0, }; g_value_init (&thispos, G_TYPE_INT); gtk_container_child_get_property (GTK_CONTAINER (box), GTK_WIDGET (tem->data), "position", &thispos); if (g_value_get_int (&thispos) == pos) { ret = tem->data; break; } } g_list_free (children); return GTK_WIDGET (ret); }
int ags_machine_popup_move_up_activate_callback(GtkWidget *widget, AgsMachine *machine) { GValue val={0,}; g_value_init (&val, G_TYPE_INT); gtk_container_child_get_property(GTK_CONTAINER(GTK_WIDGET(machine)->parent), GTK_WIDGET(machine), "position\0", &val); if(g_value_get_int (&val) > 0){ gtk_box_reorder_child(GTK_BOX(GTK_WIDGET(machine)->parent), GTK_WIDGET(machine), g_value_get_int (&val) - 1); } g_value_unset (&val); return(0); }
void dt_dev_reload_history_items(dt_develop_t *dev) { dt_dev_pop_history_items(dev, 0); // remove unused history items: GList *history = g_list_nth(dev->history, dev->history_end); while(history) { GList *next = g_list_next(history); dt_dev_history_item_t *hist = (dt_dev_history_item_t *)(history->data); free(hist->params); free(hist->blend_params); free(history->data); dev->history = g_list_delete_link(dev->history, history); history = next; } dt_dev_read_history(dev); //we have to add new module instances first GList *modules = dev->iop; while(modules) { dt_iop_module_t *module = (dt_iop_module_t *)(modules->data); if (module->multi_priority > 0) { if (!dt_iop_is_hidden(module) && !module->expander) { module->gui_init(module); dt_iop_reload_defaults(module); //we search the base iop corresponding GList *mods = g_list_first(dev->iop); dt_iop_module_t *base = NULL; int pos_module = 0; int pos_base = 0; int pos = 0; while (mods) { dt_iop_module_t *mod = (dt_iop_module_t *)(mods->data); if (mod->multi_priority == 0 && mod->instance == module->instance) { base = mod; pos_base = pos; } else if (mod == module) pos_module = pos; mods = g_list_next(mods); pos++; } if (!base) continue; /* add module to right panel */ GtkWidget *expander = dt_iop_gui_get_expander(module); dt_ui_container_add_widget(darktable.gui->ui, DT_UI_CONTAINER_PANEL_RIGHT_CENTER, expander); GValue gv = { 0, { { 0 } } }; g_value_init(&gv,G_TYPE_INT); gtk_container_child_get_property(GTK_CONTAINER(dt_ui_get_container(darktable.gui->ui, DT_UI_CONTAINER_PANEL_RIGHT_CENTER)),base->expander,"position",&gv); gtk_box_reorder_child (dt_ui_get_container(darktable.gui->ui, DT_UI_CONTAINER_PANEL_RIGHT_CENTER),expander,g_value_get_int(&gv)+pos_base-pos_module); dt_iop_gui_set_expanded(module, TRUE); dt_iop_gui_update_blending(module); //the pipe need to be reconstruct dev->pipe->changed |= DT_DEV_PIPE_REMOVE; dev->preview_pipe->changed |= DT_DEV_PIPE_REMOVE; } } modules = g_list_next(modules); } dt_dev_pop_history_items(dev, dev->history_end); }
static void device_changed_cb(const gchar *name, PurplePrefType type, gconstpointer value, gpointer data) { GtkSizeGroup *sg = data; GtkWidget *parent, *widget; GSList *widgets; GList *devices; GValue gvalue; gint position; gchar *label, *pref; widgets = gtk_size_group_get_widgets(GTK_SIZE_GROUP(sg)); for (; widgets; widgets = g_slist_next(widgets)) { const gchar *widget_name = gtk_widget_get_name(GTK_WIDGET(widgets->data)); if (!strcmp(widget_name, name)) { gchar *temp_str; gchar delimiters[3] = {0, 0, 0}; const gchar *text; gint keyval, pos; widget = widgets->data; /* Get label with _ from the GtkLabel */ text = gtk_label_get_text(GTK_LABEL(widget)); keyval = gtk_label_get_mnemonic_keyval(GTK_LABEL(widget)); delimiters[0] = g_ascii_tolower(keyval); delimiters[1] = g_ascii_toupper(keyval); pos = strcspn(text, delimiters); if (pos != -1) { temp_str = g_strndup(text, pos); label = g_strconcat(temp_str, "_", text + pos, NULL); g_free(temp_str); } else { label = g_strdup(text); } break; } } if (widgets == NULL) return; parent = gtk_widget_get_parent(widget); widget = parent; parent = gtk_widget_get_parent(GTK_WIDGET(widget)); gvalue.g_type = 0; g_value_init(&gvalue, G_TYPE_INT); gtk_container_child_get_property(GTK_CONTAINER(parent), GTK_WIDGET(widget), "position", &gvalue); position = g_value_get_int(&gvalue); g_value_unset(&gvalue); gtk_widget_destroy(widget); pref = g_strdup(name); strcpy(pref + strlen(pref) - strlen("plugin"), "device"); devices = get_element_devices(value); if (g_list_find_custom(devices, purple_prefs_get_string(pref), (GCompareFunc)strcmp) == NULL) purple_prefs_set_string(pref, g_list_next(devices)->data); widget = pidgin_prefs_dropdown_from_list(parent, label, PURPLE_PREF_STRING, pref, devices); g_list_free(devices); g_signal_connect_swapped(widget, "destroy", G_CALLBACK(g_free), pref); g_free(label); gtk_misc_set_alignment(GTK_MISC(widget), 0, 0.5); gtk_widget_set_name(widget, name); gtk_size_group_add_widget(sg, widget); gtk_box_reorder_child(GTK_BOX(parent), gtk_widget_get_parent(GTK_WIDGET(widget)), position); }
static void af_transition_set_progress (AfTransition *transition, gdouble progress, gpointer user_data) { GValue value = { 0, }; GArray *properties; guint i; AfTypeTransformationFunc func; properties = transition->properties; progress = af_timeline_calculate_progress (progress, transition->type); for (i = 0; i < properties->len; i++) { AfPropertyRange *property_range; gboolean handled = FALSE; GType type; property_range = &g_array_index (properties, AfPropertyRange, i); if (G_UNLIKELY (G_VALUE_TYPE (&property_range->from) == G_TYPE_INVALID)) { g_value_init (&property_range->from, property_range->pspec->value_type); if (!transition->child) g_object_get_property (transition->object, property_range->pspec->name, &property_range->from); else gtk_container_child_get_property (GTK_CONTAINER (transition->object), GTK_WIDGET (transition->child), property_range->pspec->name, &property_range->from); } g_value_init (&value, property_range->pspec->value_type); type = property_range->pspec->value_type; func = transition->func; if (!func && transformable_types) func = g_hash_table_lookup (transformable_types, GSIZE_TO_POINTER (type)); if (!func) { switch (type) { case G_TYPE_INT: { gint from, to, val; from = g_value_get_int (&property_range->from); to = g_value_get_int (&property_range->to); val = from + ((to - from) * progress); g_value_set_int (&value, val); handled = TRUE; } break; case G_TYPE_DOUBLE: { gdouble from, to, val; from = g_value_get_double (&property_range->from); to = g_value_get_double (&property_range->to); val = from + ((to - from) * progress); g_value_set_double (&value, val); handled = TRUE; } break; case G_TYPE_FLOAT: { gfloat from, to, val; from = g_value_get_float (&property_range->from); to = g_value_get_float (&property_range->to); val = from + ((to - from) * progress); g_value_set_float (&value, val); handled = TRUE; } break; default: g_warning ("Property of type '%s' not handled", g_type_name (type)); } } else { (func) (&property_range->from, &property_range->to, progress, user_data, &value); handled = TRUE; } if (handled) { if (!transition->child) g_object_set_property (transition->object, property_range->pspec->name, &value); else gtk_container_child_set_property (GTK_CONTAINER (transition->object), GTK_WIDGET (transition->child), property_range->pspec->name, &value); } g_value_unset (&value); } }
static void dt_dev_change_image(dt_develop_t *dev, const uint32_t imgid) { // stop crazy users from sleeping on key-repeat spacebar: if(dev->image_loading) return; // get last active plugin, make sure focus out is called: gchar *active_plugin = dt_conf_get_string("plugins/darkroom/active"); dt_iop_request_focus(NULL); // store last active group dt_conf_set_int("plugins/darkroom/groups", dt_dev_modulegroups_get(dev)); // store last active plugin: if(darktable.develop->gui_module) dt_conf_set_string("plugins/darkroom/active", darktable.develop->gui_module->op); else dt_conf_set_string("plugins/darkroom/active", ""); g_assert(dev->gui_attached); // commit image ops to db dt_dev_write_history(dev); // be sure light table will update the thumbnail // TODO: only if image changed! // if() { dt_mipmap_cache_remove(darktable.mipmap_cache, dev->image_storage.id); dt_image_synch_xmp(dev->image_storage.id); } select_this_image(imgid); while(dev->history) { // clear history of old image free(((dt_dev_history_item_t *)dev->history->data)->params); free( (dt_dev_history_item_t *)dev->history->data); dev->history = g_list_delete_link(dev->history, dev->history); } // get new image: dt_dev_reload_image(dev, imgid); // make sure no signals propagate here: darktable.gui->reset = 1; GList *modules = g_list_last(dev->iop); int nb_iop = g_list_length(dev->iop); dt_dev_pixelpipe_cleanup_nodes(dev->pipe); dt_dev_pixelpipe_cleanup_nodes(dev->preview_pipe); for (int i=nb_iop-1; i>0; i--) { dt_iop_module_t *module = (dt_iop_module_t *)(g_list_nth_data(dev->iop,i)); if (module->multi_priority == 0) //if the module is the "base" instance, we keep it { dt_iop_reload_defaults(module); dt_iop_gui_update(module); } else //else we delete it and remove it from the panel { if (!dt_iop_is_hidden(module)) { gtk_container_remove (GTK_CONTAINER(dt_ui_get_container(darktable.gui->ui, DT_UI_CONTAINER_PANEL_RIGHT_CENTER)),module->expander); dt_iop_gui_cleanup_module(module); } //we remove the module from the list dev->iop = g_list_remove_link(dev->iop,g_list_nth(dev->iop,i)); //we cleanup the module dt_accel_disconnect_list(module->accel_closures); dt_accel_cleanup_locals_iop(module); module->accel_closures = NULL; dt_iop_cleanup_module(module); free(module); } } dt_dev_pixelpipe_create_nodes(dev->pipe, dev); dt_dev_pixelpipe_create_nodes(dev->preview_pipe, dev); dt_dev_read_history(dev); //we have to init all module instances other than "base" instance modules = dev->iop; while(modules) { dt_iop_module_t *module = (dt_iop_module_t *)(modules->data); if(module->multi_priority > 0) { if (!dt_iop_is_hidden(module)) { module->gui_init(module); dt_iop_reload_defaults(module); //we search the base iop corresponding GList *mods = g_list_first(dev->iop); dt_iop_module_t *base = NULL; int pos_module = 0; int pos_base = 0; int pos = 0; while (mods) { dt_iop_module_t *mod = (dt_iop_module_t *)(mods->data); if (mod->multi_priority == 0 && mod->instance == module->instance) { base = mod; pos_base = pos; } else if (mod == module) pos_module = pos; mods = g_list_next(mods); pos++; } if (!base) continue; /* add module to right panel */ GtkWidget *expander = dt_iop_gui_get_expander(module); dt_ui_container_add_widget(darktable.gui->ui, DT_UI_CONTAINER_PANEL_RIGHT_CENTER, expander); GValue gv = { 0, { { 0 } } }; g_value_init(&gv,G_TYPE_INT); gtk_container_child_get_property(GTK_CONTAINER(dt_ui_get_container(darktable.gui->ui, DT_UI_CONTAINER_PANEL_RIGHT_CENTER)),base->expander,"position",&gv); gtk_box_reorder_child (dt_ui_get_container(darktable.gui->ui, DT_UI_CONTAINER_PANEL_RIGHT_CENTER),expander,g_value_get_int(&gv)+pos_base-pos_module); dt_iop_gui_set_expanded(module, TRUE); dt_iop_gui_update_blending(module); } /* setup key accelerators */ module->accel_closures = NULL; if(module->connect_key_accels) module->connect_key_accels(module); dt_iop_connect_common_accels(module); //we update show params for multi-instances for each other instances dt_dev_modules_update_multishow(module->dev); } modules = g_list_next(modules); } dt_dev_pop_history_items(dev, dev->history_end); if(active_plugin) { modules = dev->iop; while(modules) { dt_iop_module_t *module = (dt_iop_module_t *)(modules->data); if(!strcmp(module->op, active_plugin)) dt_iop_request_focus(module); modules = g_list_next(modules); } g_free(active_plugin); } /* last set the group to update visibility of iop modules for new pipe */ dt_dev_modulegroups_set(dev,dt_conf_get_int("plugins/darkroom/groups")); // make signals work again, but only after focus event, // to avoid crop/rotate for example to add another history item. darktable.gui->reset = 0; // Signal develop initialize dt_control_signal_raise(darktable.signals, DT_SIGNAL_DEVELOP_IMAGE_CHANGED); // prefetch next few from first selected image on. dt_view_filmstrip_prefetch(); }