static void gtk_app_chooser_button_build_ui (GtkAppChooserButton *self) { GtkCellRenderer *cell; GtkCellArea *area; gtk_combo_box_set_model (GTK_COMBO_BOX (self), GTK_TREE_MODEL (self->priv->store)); area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (self)); gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (self), row_separator_func, NULL, NULL); cell = gtk_cell_renderer_pixbuf_new (); gtk_cell_area_add_with_properties (area, cell, "align", FALSE, "expand", FALSE, "fixed-size", FALSE, NULL); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (self), cell, "gicon", COLUMN_ICON, NULL); cell = gtk_cell_renderer_text_new (); gtk_cell_area_add_with_properties (area, cell, "align", FALSE, "expand", TRUE, NULL); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (self), cell, "text", COLUMN_LABEL, NULL); gtk_app_chooser_button_populate (self); }
static void close_dialog (GtkWidget *button, gpointer data) { PagerData *pager = data; GtkTreeViewColumn *col; GtkCellArea *area; GtkCellEditable *edit_widget; /* This is a hack. The "editable" signal for GtkCellRenderer is emitted only on button press or focus cycle. Hence when the user changes the name and closes the preferences dialog without a button-press he would lose the name changes. So, we call the gtk_cell_editable_editing_done to stop the editing. Thanks to Paolo for a better crack than the one I had. */ col = gtk_tree_view_get_column (GTK_TREE_VIEW (pager->workspaces_tree), 0); area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (col)); edit_widget = gtk_cell_area_get_edit_widget (area); if (edit_widget) gtk_cell_editable_editing_done (edit_widget); gtk_widget_destroy (pager->properties_dialog); }
static void align_cell_2_toggled (GtkToggleButton *toggle, GtkIconView *iconview) { GtkCellArea *area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview)); gboolean align = gtk_toggle_button_get_active (toggle); gtk_cell_area_cell_set (area, cell_2, "align", align, NULL); }
static void expand_cell_3_toggled (GtkToggleButton *toggle, GtkIconView *iconview) { GtkCellArea *area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview)); gboolean expand = gtk_toggle_button_get_active (toggle); gtk_cell_area_cell_set (area, cell_3, "expand", expand, NULL); }
/******************************************************* * Background Area * *******************************************************/ static void cell_spacing_changed (GtkSpinButton *spin_button, GtkIconView *iconview) { GtkCellArea *area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview)); gint value; value = (gint)gtk_spin_button_get_value (spin_button); gtk_cell_area_box_set_spacing (GTK_CELL_AREA_BOX (area), value); }
/* test that new_with_area() keeps the provided area */ static void test_column_new_with_area (void) { GtkTreeViewColumn *col; GtkCellArea *area; area = gtk_cell_area_box_new (); col = gtk_tree_view_column_new_with_area (area); g_assert (gtk_cell_layout_get_area (GTK_CELL_LAYOUT (col)) == area); g_object_ref_sink (col); g_object_unref (col); }
/* test that new_with_area() keeps the provided area */ static void test_completion_new_with_area (void) { GtkEntryCompletion *c; GtkCellArea *area; area = gtk_cell_area_box_new (); c = gtk_entry_completion_new_with_area (area); g_assert (gtk_cell_layout_get_area (GTK_CELL_LAYOUT (c)) == area); g_object_ref_sink (c); g_object_unref (c); }
/* test that new_with_area() keeps the provided area */ static void test_iconview_new_with_area (void) { GtkWidget *view; GtkCellArea *area; area = gtk_cell_area_box_new (); view = gtk_icon_view_new_with_area (area); g_assert (gtk_cell_layout_get_area (GTK_CELL_LAYOUT (view)) == area); g_object_ref_sink (view); g_object_unref (view); }
/* test that we have a cell area after new() */ static void test_cellview_new (void) { GtkWidget *view; GtkCellArea *area; view = gtk_cell_view_new (); area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (view)); g_assert (GTK_IS_CELL_AREA_BOX (area)); g_object_ref_sink (view); g_object_unref (view); }
/* test that g_object_new keeps the provided area */ static void test_completion_object_new (void) { GtkEntryCompletion *c; GtkCellArea *area; area = gtk_cell_area_box_new (); gtk_orientable_set_orientation (GTK_ORIENTABLE (area), GTK_ORIENTATION_HORIZONTAL); c = g_object_new (GTK_TYPE_ENTRY_COMPLETION, "cell-area", area, NULL); g_assert (gtk_cell_layout_get_area (GTK_CELL_LAYOUT (c)) == area); g_object_ref_sink (c); g_object_unref (c); }
/* test that we have a cell area after new() */ static void test_completion_new (void) { GtkEntryCompletion *c; GtkCellArea *area; c = gtk_entry_completion_new (); area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (c)); g_assert (GTK_IS_CELL_AREA_BOX (area)); g_object_ref_sink (c); g_object_unref (c); }
static void focus_sibling_toggled (GtkToggleButton *toggle, GtkIconView *iconview) { GtkCellArea *area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview)); gboolean active = gtk_toggle_button_get_active (toggle); if (active) gtk_cell_area_add_focus_sibling (area, focus_renderer, sibling_renderer); else gtk_cell_area_remove_focus_sibling (area, focus_renderer, sibling_renderer); gtk_widget_queue_draw (GTK_WIDGET (iconview)); }
/* test that g_object_new keeps the provided area */ static void test_column_object_new (void) { GtkTreeViewColumn *col; GtkCellArea *area; area = gtk_cell_area_box_new (); gtk_orientable_set_orientation (GTK_ORIENTABLE (area), GTK_ORIENTATION_HORIZONTAL); col = g_object_new (GTK_TYPE_TREE_VIEW_COLUMN, "cell-area", area, NULL); g_assert (gtk_cell_layout_get_area (GTK_CELL_LAYOUT (col)) == area); g_object_ref_sink (col); g_object_unref (col); }
/* test that we have a cell area after new() */ static void test_column_new (void) { GtkTreeViewColumn *col; GtkCellArea *area; col = gtk_tree_view_column_new (); area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (col)); g_assert (GTK_IS_CELL_AREA_BOX (area)); g_object_ref_sink (col); g_object_unref (col); }
/* test that g_object_new keeps the provided area */ static void test_cellview_object_new (void) { GtkWidget *view; GtkCellArea *area; area = gtk_cell_area_box_new (); gtk_orientable_set_orientation (GTK_ORIENTABLE (area), GTK_ORIENTATION_HORIZONTAL); view = g_object_new (GTK_TYPE_CELL_VIEW, "cell-area", area, NULL); g_assert (gtk_cell_layout_get_area (GTK_CELL_LAYOUT (view)) == area); g_object_ref_sink (view); g_object_unref (view); }
static void preferences_response (MCPrefsDialog *dialog, int id, MCData *mc) { switch (id) { case GTK_RESPONSE_HELP: show_help_section (GTK_WINDOW (dialog), "command-line-prefs-0"); break; case GTK_RESPONSE_CLOSE: default: { GtkTreeViewColumn *col; GtkCellArea *area; GtkCellEditable *edit_widget; dialog = &mc->prefs_dialog; /* A hack to make sure 'edited' on the renderer if we * close the dialog while editing. */ col = gtk_tree_view_get_column (GTK_TREE_VIEW (dialog->macros_tree), 0); area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (col)); edit_widget = gtk_cell_area_get_edit_widget (area); if (edit_widget) gtk_cell_editable_editing_done (edit_widget); col = gtk_tree_view_get_column (GTK_TREE_VIEW (dialog->macros_tree), 1); area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (col)); edit_widget = gtk_cell_area_get_edit_widget (area); if (edit_widget) gtk_cell_editable_editing_done (edit_widget); gtk_widget_hide (dialog->dialog); } break; } }
/* test that new_with_context() keeps the provided area */ static void test_cellview_new_with_context (void) { GtkWidget *view; GtkCellArea *area; GtkCellAreaContext *context; area = gtk_cell_area_box_new (); context = gtk_cell_area_create_context (area); view = gtk_cell_view_new_with_context (area, context); g_assert (gtk_cell_layout_get_area (GTK_CELL_LAYOUT (view)) == area); g_object_ref_sink (view); g_object_unref (view); }
/* test that we have a cell area after new() */ static void test_iconview_new (void) { GtkWidget *view; GtkCellArea *area; view = gtk_icon_view_new (); area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (view)); g_assert (GTK_IS_CELL_AREA_BOX (area)); g_assert (gtk_orientable_get_orientation (GTK_ORIENTABLE (area)) == gtk_icon_view_get_item_orientation (GTK_ICON_VIEW (view))); g_object_ref_sink (view); g_object_unref (view); }
/* test that a completion subclass keeps the provided area */ static void test_completion_subclass1 (void) { GtkEntryCompletion *c; GtkCellArea *area; subclass_init = 0; area = gtk_cell_area_box_new (); c = g_object_new (my_entry_completion_get_type (), "cell-area", area, NULL); g_assert (area == gtk_cell_layout_get_area (GTK_CELL_LAYOUT (c))); g_assert (gtk_orientable_get_orientation (GTK_ORIENTABLE (area)) == GTK_ORIENTATION_HORIZONTAL); g_object_ref_sink (c); g_object_unref (c); }
/* test that a cellview subclass keeps the provided area */ static void test_cellview_subclass1 (void) { GtkWidget *view; GtkCellArea *area; subclass_init = 0; area = gtk_cell_area_box_new (); view = g_object_new (my_cell_view_get_type (), "cell-area", area, NULL); g_assert (area == gtk_cell_layout_get_area (GTK_CELL_LAYOUT (view))); g_assert (gtk_orientable_get_orientation (GTK_ORIENTABLE (area)) == GTK_ORIENTATION_HORIZONTAL); g_object_ref_sink (view); g_object_unref (view); }
/* test we can access the area in subclass init */ static void test_cellview_subclass2 (void) { GtkWidget *view; GtkCellArea *area; subclass_init = 1; view = g_object_new (my_cell_view_get_type (), NULL); area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (view)); g_assert (GTK_IS_CELL_AREA_BOX (area)); g_assert (gtk_orientable_get_orientation (GTK_ORIENTABLE (area)) == GTK_ORIENTATION_VERTICAL); g_object_ref_sink (view); g_object_unref (view); }
/* test that a column subclass keeps the provided area */ static void test_column_subclass1 (void) { GtkTreeViewColumn *col; GtkCellArea *area; subclass_init = 0; area = gtk_cell_area_box_new (); col = g_object_new (my_tree_view_column_get_type (), "cell-area", area, NULL); g_assert (area == gtk_cell_layout_get_area (GTK_CELL_LAYOUT (col))); g_assert (gtk_orientable_get_orientation (GTK_ORIENTABLE (area)) == GTK_ORIENTATION_HORIZONTAL); g_object_ref_sink (col); g_object_unref (col); }
/* test we can access the area in subclass init */ static void test_column_subclass2 (void) { GtkTreeViewColumn *col; GtkCellArea *area; subclass_init = 1; col = g_object_new (my_tree_view_column_get_type (), NULL); area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (col)); g_assert (GTK_IS_CELL_AREA_BOX (area)); g_assert (gtk_orientable_get_orientation (GTK_ORIENTABLE (area)) == GTK_ORIENTATION_VERTICAL); g_object_ref_sink (col); g_object_unref (col); }
/* test we can access the area in subclass init */ static void test_completion_subclass2 (void) { GtkEntryCompletion *c; GtkCellArea *area; subclass_init = 1; c = g_object_new (my_entry_completion_get_type (), NULL); area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (c)); g_assert (GTK_IS_CELL_AREA_BOX (area)); g_assert (gtk_orientable_get_orientation (GTK_ORIENTABLE (area)) == GTK_ORIENTATION_VERTICAL); g_object_ref_sink (c); g_object_unref (c); }
static void my_icon_view_init (MyIconView *view) { GtkCellArea *area; if (subclass_init == 0) { /* do nothing to area */ } else if (subclass_init == 1) { area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (view)); g_assert (GTK_IS_CELL_AREA_BOX (area)); g_assert (gtk_orientable_get_orientation (GTK_ORIENTABLE (area)) == GTK_ORIENTATION_VERTICAL); gtk_orientable_set_orientation (GTK_ORIENTABLE (area), GTK_ORIENTATION_HORIZONTAL); } }
static void cell_packing_end_element (GMarkupParseContext *context, const gchar *element_name, gpointer user_data, GError **error) { CellPackingSubParserData *data = (CellPackingSubParserData*)user_data; GtkCellArea *area; area = gtk_cell_layout_get_area (data->cell_layout); if (area) { /* translate the string */ if (data->string->len && data->translatable) { const gchar *translated; const gchar* domain; domain = gtk_builder_get_translation_domain (data->builder); translated = _gtk_builder_parser_translate (domain, data->context, data->string->str); g_string_assign (data->string, translated); } if (data->cell_prop_name) gtk_cell_layout_buildable_set_cell_property (area, data->builder, data->renderer, data->cell_prop_name, data->string->str); } else g_warning ("%s does not have an internal GtkCellArea class and cannot apply child cell properties", g_type_name (G_OBJECT_TYPE (data->cell_layout))); g_string_set_size (data->string, 0); g_free (data->cell_prop_name); g_free (data->context); data->cell_prop_name = NULL; data->context = NULL; data->translatable = FALSE; }
static gchar * get_text_from_label_widget (GtkWidget *label) { if (GTK_IS_LABEL (label)) return g_strdup (gtk_label_get_text (GTK_LABEL (label))); else if (GTK_IS_CELL_VIEW (label)) { GList *cells, *l; GtkTreeModel *model; GtkTreeIter iter; GtkTreePath *path; GtkCellArea *area; gchar *text; model = gtk_cell_view_get_model (GTK_CELL_VIEW (label)); path = gtk_cell_view_get_displayed_row (GTK_CELL_VIEW (label)); gtk_tree_model_get_iter (model, &iter, path); gtk_tree_path_free (path); area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (label)); gtk_cell_area_apply_attributes (area, model, &iter, FALSE, FALSE); cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (label)); text = NULL; for (l = cells; l; l = l->next) { GtkCellRenderer *cell = l->data; if (GTK_IS_CELL_RENDERER_TEXT (cell)) { g_object_get (cell, "text", &text, NULL); break; } } g_list_free (cells); return text; } return NULL; }
static void attribute_mapping_changed (GtkComboBox *combo, GtkInspectorPropEditor *editor) { gint col; gpointer layout; GtkCellRenderer *cell; GtkCellArea *area; col = gtk_combo_box_get_active (combo) - 1; layout = g_object_get_data (editor->priv->object, "gtk-inspector-cell-layout"); if (GTK_IS_CELL_LAYOUT (layout)) { cell = GTK_CELL_RENDERER (editor->priv->object); area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (layout)); gtk_cell_area_attribute_disconnect (area, cell, editor->priv->name); if (col != -1) gtk_cell_area_attribute_connect (area, cell, editor->priv->name, col); gtk_widget_set_sensitive (editor->priv->editor, col == -1); notify_property (editor->priv->object, find_property (editor)); gtk_widget_queue_draw (gtk_cell_layout_get_widget (GTK_CELL_LAYOUT (layout))); } }
/* test we get a warning if an area is provided, but ignored */ static void test_completion_subclass3 (void) { subclass_init = 1; if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) { GtkEntryCompletion *c; GtkCellArea *area; area = gtk_cell_area_box_new (); c = g_object_new (my_entry_completion_get_type (), "cell-area", area, NULL); g_assert (area == gtk_cell_layout_get_area (GTK_CELL_LAYOUT (c))); g_assert (gtk_orientable_get_orientation (GTK_ORIENTABLE (area)) == GTK_ORIENTATION_VERTICAL); g_object_ref_sink (c); g_object_unref (c); exit (0); } g_test_trap_assert_failed (); g_test_trap_assert_stderr ("*ignoring construct property*"); }
static GtkWidget * simple_iconview (void) { GtkTreeModel *model; GtkWidget *iconview; GtkCellArea *area; GtkCellRenderer *renderer; iconview = gtk_icon_view_new (); gtk_widget_show (iconview); model = simple_list_model (); gtk_icon_view_set_model (GTK_ICON_VIEW (iconview), model); gtk_icon_view_set_item_orientation (GTK_ICON_VIEW (iconview), GTK_ORIENTATION_HORIZONTAL); area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview)); cell_1 = renderer = gtk_cell_renderer_text_new (); gtk_cell_area_box_pack_start (GTK_CELL_AREA_BOX (area), renderer, FALSE, FALSE, FALSE); gtk_cell_area_attribute_connect (area, renderer, "text", SIMPLE_COLUMN_NAME); cell_2 = renderer = gtk_cell_renderer_pixbuf_new (); g_object_set (G_OBJECT (renderer), "xalign", 0.0F, NULL); gtk_cell_area_box_pack_start (GTK_CELL_AREA_BOX (area), renderer, TRUE, FALSE, FALSE); gtk_cell_area_attribute_connect (area, renderer, "icon-name", SIMPLE_COLUMN_ICON); cell_3 = renderer = gtk_cell_renderer_text_new (); g_object_set (G_OBJECT (renderer), "wrap-mode", PANGO_WRAP_WORD, "wrap-width", 215, NULL); gtk_cell_area_box_pack_start (GTK_CELL_AREA_BOX (area), renderer, FALSE, TRUE, FALSE); gtk_cell_area_attribute_connect (area, renderer, "text", SIMPLE_COLUMN_DESCRIPTION); return iconview; }