static GtkWidget* create_type_list(void){ GtkListStore *store; GtkCellRenderer *renderer; GtkWidget *widget; store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); widget = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store)); gtk_combo_box_set_add_tearoffs(GTK_COMBO_BOX(widget), 0); renderer = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget), renderer, 0); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget), renderer, "text", 0, nullptr); g_object_unref(GTK_TREE_MODEL(store)); GtkTreeIter iter1; struct { const char *name; int type; } types[] = { {_("Protanomaly"), ColorVisionDeficiency::PROTANOMALY}, {_("Deuteranomaly"), ColorVisionDeficiency::DEUTERANOMALY}, {_("Tritanomaly"), ColorVisionDeficiency::TRITANOMALY}, {_("Protanopia"), ColorVisionDeficiency::PROTANOPIA}, {_("Deuteranopia"), ColorVisionDeficiency::DEUTERANOPIA}, {_("Tritanopia"), ColorVisionDeficiency::TRITANOPIA}, }; for (int i = 0; i < ColorVisionDeficiency::DEFICIENCY_TYPE_COUNT; ++i){ gtk_list_store_append(store, &iter1); gtk_list_store_set(store, &iter1, 0, types[i].name, 1, types[i].type, -1); } return widget; }
int clip_GTK_COMBOBOXSETADDTEAROFFS(ClipMachine * cm) { C_widget *ccmb = _fetch_cw_arg(cm); gboolean set = _clip_parl(cm, 2); CHECKCWID(ccmb,GTK_IS_COMBO_BOX); CHECKARG(2, LOGICAL_t); gtk_combo_box_set_add_tearoffs(GTK_COMBO_BOX(ccmb->widget), set); return 0; err: return 1; }
/* * Sets the properties of the widget. This is used for both applying the * properties changed in the property editor, and also for loading. */ static void gb_combo_box_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { gchar *items; gboolean add_tearoffs, focus_on_click; items = gb_widget_input_text (data, Items); if (data->apply) { GtkTreeModel *model; gchar *pos = items; gchar *items_end = &items[strlen (items)]; /* Save a copy so it is easy to get out later. */ gtk_object_set_data_full (GTK_OBJECT (widget), Items, g_strdup (items), g_free); /* Clear the list. */ model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget)); gtk_list_store_clear (GTK_LIST_STORE (model)); /* Now add the items one at a time. */ while (pos < items_end) { gchar *item_end = strchr (pos, '\n'); if (item_end == NULL) item_end = items_end; *item_end = '\0'; gtk_combo_box_append_text (GTK_COMBO_BOX (widget), pos); if (item_end != items_end) *item_end = '\n'; pos = item_end + 1; } } if (data->action == GB_APPLYING) g_free (items); add_tearoffs = gb_widget_input_bool (data, AddTearoffs); if (data->apply) gtk_combo_box_set_add_tearoffs (GTK_COMBO_BOX (widget), add_tearoffs); focus_on_click = gb_widget_input_bool (data, FocusOnClick); if (data->apply) gtk_combo_box_set_focus_on_click (GTK_COMBO_BOX (widget), focus_on_click); }
static Tcs3_diag *css_diag(Tcs3_destination dest, Tcs3_style style, GtkWidget *transient_win, gboolean grab) { Tcs3_diag *diag; GtkWidget *scrolwin, *table, *but, *vbox, *hbox, *vbox2; GList *tmplist = NULL; Tcs3_arr tmp; gint count=0; GtkTreeSelection *selection; GtkCellRenderer *renderer; GtkTreeViewColumn *column; diag = g_slice_new(Tcs3_diag); diag->win = window_full2(_("Cascading Style Sheet Builder"), GTK_WIN_POS_CENTER_ON_PARENT, 12, G_CALLBACK(cs3d_destroy_lcb), diag, TRUE, transient_win); gtk_window_set_role(GTK_WINDOW(diag->win), "css"); diag->dest = dest; diag->styletype = style; diag->grab = grab; diag->selected_row = -1; vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(diag->win),vbox); table = gtk_table_new(3, 6, TRUE); gtk_table_set_row_spacings(GTK_TABLE(table), 12); gtk_table_set_col_spacings(GTK_TABLE(table), 12); gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); tmplist = NULL; if (diag->styletype == multistyle) { tmplist = glist_with_html_tags(0); diag->selector = combobox_with_popdown("", tmplist,1); dialog_mnemonic_label_in_table(_("_Selector(s):"), diag->selector, table, 0, 1, 0, 1); gtk_table_attach_defaults(GTK_TABLE(table), diag->selector, 1 ,5 , 0, 1); gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(diag->selector), 5); gtk_combo_box_set_add_tearoffs(GTK_COMBO_BOX(diag->selector), 1); diag->html5 = gtk_check_button_new_with_mnemonic("_html 5"); gtk_table_attach_defaults(GTK_TABLE(table), diag->html5, 5,6, 0,1); g_signal_connect(diag->html5, "clicked", G_CALLBACK(cs3d_html5_clicked_lcb), diag); g_list_free(tmplist); tmplist = NULL; } tmp = cs3_arr[count]; while (tmp.property) { tmplist = g_list_append(tmplist, tmp.property); count++; tmp = cs3_arr[count]; } diag->property = combobox_with_popdown("", tmplist,1); g_list_free(tmplist); tmplist = NULL; g_signal_connect(gtk_bin_get_child(GTK_BIN(diag->property)), "activate", G_CALLBACK(cs3d_prop_activate_lcb), diag); g_signal_connect(gtk_bin_get_child(GTK_BIN(diag->property)), "changed", G_CALLBACK(cs3d_prop_activate_lcb), diag); diag->value = combobox_with_popdown("", tmplist,1); dialog_mnemonic_label_in_table(_("_Property:"), diag->property, table, 0, 1, 1, 2); gtk_table_attach_defaults(GTK_TABLE(table), diag->property, 1, 5, 1, 2); gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(diag->property), 4); gtk_combo_box_set_add_tearoffs(GTK_COMBO_BOX(diag->property), 1); dialog_mnemonic_label_in_table(_("_Value:"), diag->value, table, 0, 1, 2, 3); gtk_table_attach_defaults(GTK_TABLE(table), diag->value, 1, 4, 2, 3); gtk_widget_realize(diag->win); diag->extra_but = color_but_new(GTK_WIDGET(gtk_bin_get_child(GTK_BIN(diag->value))), diag->win); gtk_table_attach(GTK_TABLE(table), diag->extra_but, 4, 5, 2, 3, GTK_EXPAND, GTK_EXPAND, 0, 0); /* the list widget and the buttons are in a horizontal box */ hbox = gtk_hbox_new(FALSE, 12); gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 18); diag->lstore = gtk_list_store_new(3, G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING); gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(diag->lstore),0,GTK_SORT_ASCENDING); diag->lview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(diag->lstore)); g_object_unref(G_OBJECT(diag->lstore)); if (diag->styletype == multistyle) { renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes (_("Selector(s)"),renderer,"text", 0,NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(diag->lview), column); } renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes (_("Property"),renderer,"text", 1,NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(diag->lview), column); renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes (_("Value"),renderer,"text", 2,NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(diag->lview), column); selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(diag->lview)); gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); g_signal_connect(G_OBJECT(selection), "changed",G_CALLBACK(cs3d_selection_changed_cb),diag); scrolwin = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolwin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_widget_set_size_request(scrolwin, 400, 300); gtk_box_pack_start(GTK_BOX(hbox), scrolwin, TRUE, TRUE, 0); gtk_container_add(GTK_CONTAINER(scrolwin), diag->lview); /*if (diag->styletype == multistyle) { gchar *titles[] = {_("Selector"), _("Property"), _("Value"), NULL}; diag->clist = gtk_clist_new_with_titles(3, titles); } else { gchar *titles[] = {_("Property"), _("Value"), NULL}; diag->clist = gtk_clist_new_with_titles(2, titles); } gtk_clist_set_sort_column(GTK_CLIST(diag->clist), 0); gtk_clist_set_auto_sort(GTK_CLIST(diag->clist), TRUE); g_signal_connect(diag->clist, "select_row", G_CALLBACK(cs3d_select_row_lcb), diag); g_signal_connect(diag->clist, "unselect_row", G_CALLBACK(cs3d_unselect_row_lcb), diag); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolwin), diag->lview); */ vbox2 = gtk_vbox_new(FALSE, 6); gtk_box_pack_start(GTK_BOX(hbox), vbox2, FALSE, FALSE, 0); but = gtk_button_new_with_mnemonic(_(" _Add ")); g_signal_connect(but, "clicked", G_CALLBACK(cs3d_add_clicked_lcb), diag); gtk_box_pack_start(GTK_BOX(vbox2), but, FALSE, FALSE, 0); but = gtk_button_new_with_mnemonic(_(" _Update ")); g_signal_connect(but, "clicked", G_CALLBACK(cs3d_update_clicked_lcb), diag); gtk_box_pack_start(GTK_BOX(vbox2), but, FALSE, FALSE, 0); but = gtk_button_new_with_mnemonic(_(" _Delete ")); g_signal_connect(but, "clicked", G_CALLBACK(cs3d_del_clicked_lcb), diag); gtk_box_pack_start(GTK_BOX(vbox2), but, FALSE, FALSE, 0); /* the ok and cancel button are in a horizontal box below */ hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 12); #if GTK_CHECK_VERSION(3,0,0) hbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL); #else hbox = gtk_hbutton_box_new(); #endif gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_END); gtk_box_set_spacing(GTK_BOX(hbox), 12); but = bf_stock_cancel_button(G_CALLBACK(cs3d_cancel_clicked_lcb), diag); gtk_box_pack_start(GTK_BOX(hbox), but, FALSE, FALSE, 0); but = bf_stock_ok_button(G_CALLBACK(cs3d_ok_clicked_lcb), diag); gtk_box_pack_start(GTK_BOX(hbox), but, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); gtk_widget_show_all(diag->win); cs3d_prop_activate_lcb(NULL, diag); if (diag->grab) { gtk_grab_add(diag->win); } return diag; }