static gboolean on_focus_in( GtkWidget *entry, GdkEventFocus* evt, gpointer user_data ) { GtkEntryCompletion* completion = gtk_entry_completion_new(); GtkListStore* list = gtk_list_store_new( COUNT_COLS, G_TYPE_STRING, G_TYPE_STRING ); GtkCellRenderer* render; gtk_entry_completion_set_minimum_key_length( completion, 1 ); gtk_entry_completion_set_model( completion, GTK_TREE_MODEL(list) ); g_object_unref( list ); // gtk_entry_completion_set_text_column( completion, COL_PATH ); // g_object_set( completion, "text-column", COL_PATH, NULL );VV g_object_set( completion, "text-column", COL_NAME, NULL ); render = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start( (GtkCellLayout*)completion, render, TRUE ); gtk_cell_layout_add_attribute( (GtkCellLayout*)completion, render, "text", COL_NAME ); gtk_entry_completion_set_inline_completion( completion, TRUE ); #if GTK_CHECK_VERSION( 2, 8, 0) // gtk+ prior to 2.8.0 doesn't have this API gtk_entry_completion_set_popup_set_width( completion, TRUE ); #endif gtk_entry_set_completion( GTK_ENTRY(entry), completion ); g_signal_connect( G_OBJECT(entry), "changed", G_CALLBACK(on_changed), NULL ); g_object_unref( completion ); return FALSE; }
static GtkEntryCompletion * _new_bin_completion (void) { const gchar *path_env = g_getenv ("PATH"); gchar **pathdirs = g_strsplit (path_env, G_SEARCHPATH_SEPARATOR_S, 0); gchar **pathiter = pathdirs; GList *cmds_p[] = {NULL}; for (; *pathiter != NULL; pathiter++) { gchar *path = *pathiter; ol_traverse_dir (path, FALSE, _prepend_cmd_to_list, cmds_p); } GList *cmds = cmds_p[0]; cmds = g_list_sort (cmds, (GCompareFunc)strcasecmp); GtkListStore *list = gtk_list_store_new (1, G_TYPE_STRING); for (; cmds != NULL; cmds = cmds->next) { GtkTreeIter iter; gtk_list_store_append (list, &iter); gtk_list_store_set (list, &iter, 0, cmds->data, -1); } for (; cmds != NULL; cmds = g_list_delete_link (cmds, cmds)) g_free (cmds->data); GtkEntryCompletion *comp = gtk_entry_completion_new (); gtk_entry_completion_set_model (comp, GTK_TREE_MODEL (list)); gtk_entry_completion_set_text_column (comp, 0); gtk_entry_completion_set_inline_completion (comp, TRUE); gtk_entry_completion_set_inline_selection (comp, TRUE); return comp; }
static void setup_auto_complete_with_data(ThreadData* data) { GtkListStore* store; GSList *l; GtkEntryCompletion* comp = gtk_entry_completion_new(); gtk_entry_completion_set_minimum_key_length( comp, 2 ); gtk_entry_completion_set_inline_completion( comp, TRUE ); #if GTK_CHECK_VERSION( 2, 8, 0 ) gtk_entry_completion_set_popup_set_width( comp, TRUE ); gtk_entry_completion_set_popup_single_match( comp, FALSE ); #endif store = gtk_list_store_new( 1, G_TYPE_STRING ); for( l = data->files; l; l = l->next ) { const char *name = (const char*)l->data; GtkTreeIter it; gtk_list_store_append( store, &it ); gtk_list_store_set( store, &it, 0, name, -1 ); } gtk_entry_completion_set_model( comp, (GtkTreeModel*)store ); g_object_unref( store ); gtk_entry_completion_set_text_column( comp, 0 ); gtk_entry_set_completion( (GtkEntry*)data->entry, comp ); /* trigger entry completion */ gtk_entry_completion_complete(comp); g_object_unref( comp ); }
static GtkWidget * ekiga_window_uri_entry_new (EkigaWindow *mw) { GtkWidget *entry = NULL; GtkEntryCompletion *completion = NULL; g_return_val_if_fail (EKIGA_IS_WINDOW (mw), NULL); /* URI Entry */ entry = gm_entry_new (BASIC_URI_REGEX); gm_entry_set_activate_icon (GM_ENTRY (entry), "call-start"); mw->priv->completion = gtk_list_store_new (1, G_TYPE_STRING); completion = gtk_entry_completion_new (); gtk_entry_completion_set_model (GTK_ENTRY_COMPLETION (completion), GTK_TREE_MODEL (mw->priv->completion)); gtk_entry_completion_set_text_column (GTK_ENTRY_COMPLETION (completion), 0); gtk_entry_set_completion (GTK_ENTRY (entry), completion); gtk_entry_set_text (GTK_ENTRY (entry), "sip:"); gtk_entry_completion_set_inline_completion (GTK_ENTRY_COMPLETION (completion), true); gtk_entry_completion_set_popup_completion (GTK_ENTRY_COMPLETION (completion), true); gtk_widget_add_accelerator (entry, "grab-focus", mw->priv->accel, GDK_KEY_L, (GdkModifierType) GDK_CONTROL_MASK, (GtkAccelFlags) 0); gtk_editable_set_position (GTK_EDITABLE (entry), -1); g_signal_connect (entry, "changed", G_CALLBACK (url_changed_cb), mw); g_signal_connect (entry, "activated", G_CALLBACK (place_call_cb), mw); return entry; }
GtkWidget * terminal_search_dialog_new (GtkWindow *parent) { GtkWidget *dialog; TerminalSearchDialogPrivate *priv; GtkListStore *store; GtkEntryCompletion *completion; priv = g_new0 (TerminalSearchDialogPrivate, 1); if (!terminal_util_load_builder_file ("find-dialog.ui", "find-dialog", &dialog, "search-label", &priv->search_label, "search-entry", &priv->search_entry, "match-case-checkbutton", &priv->match_case_checkbutton, "entire-word-checkbutton", &priv->entire_word_checkbutton, "regex-checkbutton", &priv->regex_checkbutton, "search-backwards-checkbutton", &priv->backwards_checkbutton, "wrap-around-checkbutton", &priv->wrap_around_checkbutton, NULL)) { g_free (priv); return NULL; } g_object_set_qdata_full (G_OBJECT (dialog), get_quark (), priv, (GDestroyNotify) terminal_search_dialog_private_destroy); priv->search_text_entry = gtk_bin_get_child (GTK_BIN (priv->search_entry)); gtk_widget_set_size_request (priv->search_entry, 300, -1); priv->store = store = gtk_list_store_new (1, G_TYPE_STRING); g_object_set (G_OBJECT (priv->search_entry), "model", store, "text-column", 0, NULL); priv->completion = completion = gtk_entry_completion_new (); gtk_entry_completion_set_model (completion, GTK_TREE_MODEL (store)); gtk_entry_completion_set_text_column (completion, 0); gtk_entry_completion_set_minimum_key_length (completion, HISTORY_MIN_ITEM_LEN); gtk_entry_completion_set_popup_completion (completion, FALSE); gtk_entry_completion_set_inline_completion (completion, TRUE); gtk_entry_set_completion (GTK_ENTRY (priv->search_text_entry), completion); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT); gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT, FALSE); gtk_entry_set_activates_default (GTK_ENTRY (priv->search_text_entry), TRUE); g_signal_connect (priv->search_text_entry, "changed", G_CALLBACK (update_sensitivity), dialog); g_signal_connect (priv->regex_checkbutton, "toggled", G_CALLBACK (update_sensitivity), dialog); g_signal_connect (dialog, "response", G_CALLBACK (response_handler), NULL); if (parent) gtk_window_set_transient_for (GTK_WINDOW (dialog), parent); return GTK_WIDGET (dialog); }
/* * Create completion in entry */ static void dialog_entry_completion_new(const GtkWidget *container, GtkEntryCompletionMatchFunc completion_func, gpointer completion_data) { GtkListStore *list_store = NULL; GtkEntryCompletion *completion = NULL; /* Create a tree model and use it as the completion model */ list_store = gtk_list_store_new(1, G_TYPE_STRING); /* Create the completion object */ completion = gtk_entry_completion_new(); gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(list_store)); gtk_entry_completion_set_text_column(completion, 0); gtk_entry_completion_set_minimum_key_length(completion, AV_WIDGET_ENTRY_COMPLETION_KEY_LEN_MIN); gtk_entry_completion_set_popup_completion(completion, FALSE); gtk_entry_completion_set_inline_completion(completion, TRUE); gtk_entry_completion_set_match_func(completion, completion_func, completion_data, NULL); /* Assign the completion to the entry */ gtk_entry_set_completion(GTK_ENTRY(container), completion); g_object_unref (completion); }
static void fm_path_entry_init(FmPathEntry *entry) { FmPathEntryPrivate *priv = FM_PATH_ENTRY_GET_PRIVATE(entry); GtkEntryCompletion* completion = gtk_entry_completion_new(); GtkCellRenderer* render; priv->model = NULL; priv->completion_model = NULL; priv->completion_len = 0; priv->in_change = FALSE; priv->completion = completion; priv->highlight_completion_match = TRUE; priv->common_suffix_append_idle_id = -1; priv->common_suffix[0] = 0; gtk_entry_completion_set_minimum_key_length(completion, 1); gtk_entry_completion_set_match_func(completion, fm_path_entry_match_func, NULL, NULL); g_signal_connect(G_OBJECT(completion), "match-selected", G_CALLBACK(fm_path_entry_match_selected), (gpointer)NULL); g_object_set(completion, "text-column", COL_FILE_NAME, NULL); render = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start( (GtkCellLayout*)completion, render, TRUE ); gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(completion), render, fm_path_entry_completion_render_func, entry, NULL); gtk_entry_completion_set_inline_completion(completion, TRUE); gtk_entry_completion_set_popup_set_width(completion, TRUE); g_signal_connect(G_OBJECT(entry), "key-press-event", G_CALLBACK(fm_path_entry_key_press), NULL); gtk_entry_set_completion(GTK_ENTRY(entry), completion); }
int clip_GTK_ENTRYCOMPLETIONSETINLINECOMPLETION(ClipMachine * ClipMachineMemory) { C_object *ccompletion = _fetch_co_arg(ClipMachineMemory); gboolean set = _clip_parl(ClipMachineMemory, 2); CHECKCOBJ(ccompletion, GTK_IS_ENTRY_COMPLETION(ccompletion->object)); CHECKARG(2, LOGICAL_type_of_ClipVarType); gtk_entry_completion_set_inline_completion(GTK_ENTRY_COMPLETION(ccompletion->object), set); return 0; err: return 1; }
static void hotssh_tab_init (HotSshTab *self) { HotSshTabPrivate *priv = hotssh_tab_get_instance_private (self); priv->settings = g_settings_new ("org.gnome.hotssh"); gtk_widget_init_template (GTK_WIDGET (self)); gtk_notebook_set_show_tabs ((GtkNotebook*)self, FALSE); g_signal_connect (priv->create_and_connect_button, "clicked", G_CALLBACK (on_create_and_connect), self); g_signal_connect (priv->add_new_connection_button, "clicked", G_CALLBACK (on_add_new_connection), self); g_signal_connect (priv->connect_cancel_button, "clicked", G_CALLBACK (on_connect_cancel), self); g_signal_connect (priv->error_disconnect, "clicked", G_CALLBACK (on_connect_cancel), self); g_signal_connect (priv->auth_cancel_button, "clicked", G_CALLBACK (on_connect_cancel), self); g_signal_connect (priv->approve_hostkey_button, "clicked", G_CALLBACK (on_approve_hostkey_clicked), self); g_signal_connect (priv->disapprove_hostkey_button, "clicked", G_CALLBACK (on_connect_cancel), self); g_signal_connect_swapped (priv->password_entry, "activate", G_CALLBACK (submit_password), self); g_signal_connect_swapped (priv->password_submit, "clicked", G_CALLBACK (submit_password), self); g_signal_connect (priv->connections_treeview, "row-activated", G_CALLBACK (on_connection_row_activated), self); priv->password_interaction = hotssh_password_interaction_new ((GtkEntry*)priv->password_entry); priv->terminal = vte_terminal_new (); g_signal_connect (priv->terminal, "realize", G_CALLBACK (on_vte_realize), self); vte_terminal_set_audible_bell ((VteTerminal*)priv->terminal, FALSE); /* Audible bell is a terrible idea */ g_signal_connect ((GObject*)priv->terminal, "size-allocate", G_CALLBACK (on_terminal_size_allocate), self); g_signal_connect ((GObject*)priv->terminal, "commit", G_CALLBACK (on_terminal_commit), self); gtk_box_pack_start ((GtkBox*)priv->terminal_box, priv->terminal, TRUE, TRUE, 0); gtk_range_set_adjustment ((GtkRange*)priv->terminal_vscrollbar, gtk_scrollable_get_vadjustment ((GtkScrollable*)priv->terminal)); gtk_widget_show_all (priv->terminal_box); g_queue_init (&priv->write_queue); { gs_unref_object HotSshHostDB *hostdb = hotssh_hostdb_get_instance (); gs_unref_object GtkTreeModel *hostdb_model = hotssh_hostdb_get_model (hostdb); priv->host_completion = gtk_entry_completion_new (); gtk_entry_completion_set_match_func (priv->host_completion, host_entry_match, self, NULL); gtk_entry_completion_set_model (priv->host_completion, hostdb_model); gtk_entry_completion_set_text_column (priv->host_completion, 0); gtk_entry_completion_set_inline_completion (priv->host_completion, TRUE); gtk_entry_set_completion ((GtkEntry*)priv->host_entry, priv->host_completion); } }
/* --------------------------------------------------------------------- * Create the dialog, return the entry * --------------------------------------------------------------------- */ static GtkWidget* create_dialog(GtkWidget **dialog, GtkTreeModel *completion_model) { GtkWidget *entry; GtkWidget *label; GtkWidget *vbox; GtkEntryCompletion *completion; *dialog = gtk_dialog_new_with_buttons("Go to File...", GTK_WINDOW(geany->main_widgets->window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); gtk_dialog_set_default_response(GTK_DIALOG(*dialog), GTK_RESPONSE_ACCEPT); gtk_widget_set_name(*dialog, "GotoFile"); vbox = ui_dialog_vbox_new(GTK_DIALOG(*dialog)); label = gtk_label_new(_("Enter the file you want to open:")); gtk_container_add(GTK_CONTAINER(vbox), label); /* Entry definition */ entry = gtk_entry_new(); gtk_container_add(GTK_CONTAINER(vbox), entry); gtk_entry_set_text(GTK_ENTRY(entry), ""); gtk_entry_set_max_length(GTK_ENTRY(entry), MAX_FILENAME_LENGTH); gtk_entry_set_width_chars(GTK_ENTRY(entry), 40); gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); /* 'enter' key */ /* Completion definition */ completion = gtk_entry_completion_new(); gtk_entry_set_completion(GTK_ENTRY(entry), completion); gtk_entry_completion_set_model (completion, completion_model); /* Completion options */ gtk_entry_completion_set_inline_completion(completion, 1); gtk_entry_completion_set_text_column (completion, 0); /* Signals */ g_signal_connect_after(GTK_ENTRY(entry), "changed", G_CALLBACK(directory_check), completion); gtk_widget_show_all(*dialog); return entry; }
static void fm_path_entry_init(FmPathEntry *entry) { FmPathEntryPrivate *priv = FM_PATH_ENTRY_GET_PRIVATE(entry); GtkEntryCompletion* completion = gtk_entry_completion_new(); GtkCellRenderer* render; priv->model = fm_path_entry_model_new(entry); priv->completion = completion; priv->cancellable = g_cancellable_new(); priv->highlight_completion_match = TRUE; gtk_entry_completion_set_minimum_key_length(completion, 1); gtk_entry_completion_set_match_func(completion, fm_path_entry_match_func, NULL, NULL); g_object_set(completion, "text_column", COL_FULL_PATH, NULL); gtk_entry_completion_set_model(completion, priv->model); render = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start( (GtkCellLayout*)completion, render, TRUE ); gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(completion), render, fm_path_entry_completion_render_func, entry, NULL); /* NOTE: this is to avoid a bug of gtk+. * The inline selection provided by GtkEntry is buggy. * If we change the content of the entry, it still stores * the old prefix sometimes so things don't work as expected. * So, unfortunately, we're not able to use this nice feature. * * Please see gtk_entry_completion_key_press() of gtk/gtkentry.c * and look for completion->priv->completion_prefix. */ gtk_entry_completion_set_inline_selection(completion, FALSE); gtk_entry_completion_set_inline_completion(completion, TRUE); gtk_entry_completion_set_popup_set_width(completion, TRUE); /* gtk_entry_completion_set_popup_single_match(completion, FALSE); */ /* connect to these signals rather than overriding default handlers since * we want to invoke our handlers before the default ones provided by Gtk. */ g_signal_connect(entry, "key-press-event", G_CALLBACK(fm_path_entry_key_press), NULL); g_signal_connect(entry, "activate", G_CALLBACK(fm_path_entry_on_activate), NULL); g_signal_connect(entry, "populate-popup", G_CALLBACK(fm_path_entry_populate_popup), NULL); }
static void setup_combo (VinagreConnectDialog *dialog) { GtkListStore *store; GtkEntryCompletion *completion; GPtrArray *history; gint i, size; GtkEntry *entry; entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (dialog->host_entry))); store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING); history = saved_history (); g_object_get (vinagre_prefs_get_default (), "history-size", &size, NULL); if (size <= 0) size = G_MAXINT; for (i=history->len-1; i>=0 && i>=(gint)history->len-size; i--) { GtkTreeIter iter; gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, COLUMN_TEXT, g_ptr_array_index (history, i), -1); } g_ptr_array_free (history, TRUE); gtk_combo_box_set_model (GTK_COMBO_BOX (dialog->host_entry), GTK_TREE_MODEL (store)); gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (dialog->host_entry), 0); completion = gtk_entry_completion_new (); gtk_entry_completion_set_model (completion, GTK_TREE_MODEL (store)); gtk_entry_completion_set_text_column (completion, 0); gtk_entry_completion_set_inline_completion (completion, TRUE); gtk_entry_set_completion (entry, completion); g_object_unref (completion); gtk_entry_set_activates_default (entry, TRUE); g_signal_connect (entry, "changed", G_CALLBACK (control_connect_button), dialog); }
void gnc_cbwe_add_completion (GtkComboBox *cbwe) { GtkEntry *entry; GtkEntryCompletion *completion; GtkTreeModel *model; entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(cbwe))); completion = gtk_entry_get_completion(entry); if (completion) return; /* No completion yet? Set one up. */ completion = gtk_entry_completion_new(); model = gtk_combo_box_get_model(GTK_COMBO_BOX(cbwe)); gtk_entry_completion_set_model(completion, model); gtk_entry_completion_set_text_column(completion, 0); gtk_entry_completion_set_inline_completion(completion, TRUE); gtk_entry_set_completion(entry, completion); g_object_unref(completion); }
/** * gpk_package_entry_completion_new: * * Creates a %GtkEntryCompletion containing completions from the system package list **/ GtkEntryCompletion * gpk_package_entry_completion_new (void) { GtkEntryCompletion *completion; GtkTreeModel *model; /* create a tree model and use it as the completion model */ completion = gtk_entry_completion_new (); model = gpk_package_entry_completion_model_new (); if (model == NULL) return completion; /* set the model for our completion model */ gtk_entry_completion_set_model (completion, model); g_object_unref (model); /* use model column 0 as the text column */ gtk_entry_completion_set_text_column (completion, 0); gtk_entry_completion_set_inline_completion (completion, TRUE); return completion; }
static void hildon_touch_selector_entry_init (HildonTouchSelectorEntry *self) { HildonTouchSelectorEntryPrivate *priv; GtkEntryCompletion *completion; HildonGtkInputMode input_mode; priv = HILDON_TOUCH_SELECTOR_ENTRY_GET_PRIVATE (self); priv->converter = g_iconv_open ("ascii//translit", "utf-8"); priv->entry = hildon_entry_new (HILDON_SIZE_FINGER_HEIGHT); gtk_entry_set_activates_default (GTK_ENTRY (priv->entry), TRUE); input_mode = hildon_gtk_entry_get_input_mode (GTK_ENTRY (priv->entry)); /* Disable unsupported input modes. */ input_mode &= ~HILDON_GTK_INPUT_MODE_MULTILINE; input_mode &= ~HILDON_GTK_INPUT_MODE_INVISIBLE; input_mode &= ~HILDON_GTK_INPUT_MODE_DICTIONARY; hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry), input_mode); completion = gtk_entry_completion_new (); gtk_entry_completion_set_inline_completion (completion, TRUE); gtk_entry_completion_set_popup_completion (completion, FALSE); gtk_entry_set_completion (GTK_ENTRY (priv->entry), completion); g_object_unref (completion); gtk_widget_show (priv->entry); g_signal_connect (G_OBJECT (priv->entry), "changed", G_CALLBACK (entry_on_text_changed), self); priv->signal_id = g_signal_connect (G_OBJECT (self), "changed", G_CALLBACK (hildon_touch_selector_entry_changed), NULL); hildon_touch_selector_set_print_func (HILDON_TOUCH_SELECTOR (self), hildon_touch_selector_entry_print_func); gtk_box_pack_start (GTK_BOX (self), priv->entry, FALSE, FALSE, 0); }
static gboolean _lib_tagging_tag_show(GtkAccelGroup *accel_group, GObject *acceleratable, guint keyval, GdkModifierType modifier, dt_lib_module_t* self) { int mouse_over_id = -1; int zoom = dt_conf_get_int("plugins/lighttable/images_in_row"); // the order is: // if(zoom == 1) => currently shown image // else if(selection not empty) => selected images // else if(cursor over image) => hovered image // else => return if(zoom == 1 || dt_collection_get_selected_count(darktable.collection) == 0) { DT_CTL_GET_GLOBAL(mouse_over_id, lib_image_mouse_over_id); if(mouse_over_id < 0) return TRUE; } dt_lib_tagging_t *d = (dt_lib_tagging_t*)self->data; d->floating_tag_imgid = mouse_over_id; gint x, y; gint px, py, w, h; GtkWidget *window = dt_ui_main_window(darktable.gui->ui); GtkWidget *center = dt_ui_center(darktable.gui->ui); gdk_window_get_origin(gtk_widget_get_window(center), &px, &py); w = gdk_window_get_width(gtk_widget_get_window(center)); h = gdk_window_get_height(gtk_widget_get_window(center)); x = px + 0.5*(w-FLOATING_ENTRY_WIDTH); y = py + h - 50; /* put the floating box at the mouse pointer */ // gint pointerx, pointery; // gtk_widget_get_pointer(center, &pointerx, &pointery); // x = px + pointerx + 1; // y = py + pointery + 1; d->floating_tag_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); /* stackoverflow.com/questions/1925568/how-to-give-keyboard-focus-to-a-pop-up-gtk-window */ gtk_widget_set_can_focus(d->floating_tag_window, TRUE); gtk_window_set_decorated(GTK_WINDOW(d->floating_tag_window), FALSE); gtk_window_set_type_hint(GTK_WINDOW(d->floating_tag_window), GDK_WINDOW_TYPE_HINT_POPUP_MENU); gtk_window_set_transient_for(GTK_WINDOW(d->floating_tag_window), GTK_WINDOW(window)); gtk_window_set_opacity(GTK_WINDOW(d->floating_tag_window), 0.8); gtk_window_move(GTK_WINDOW(d->floating_tag_window), x, y); GtkWidget *entry = gtk_entry_new(); gtk_widget_set_size_request(entry, FLOATING_ENTRY_WIDTH, -1); gtk_widget_add_events(entry, GDK_FOCUS_CHANGE_MASK); GtkEntryCompletion *completion = gtk_entry_completion_new(); gtk_entry_completion_set_model(completion, gtk_tree_view_get_model(GTK_TREE_VIEW(d->related))); gtk_entry_completion_set_text_column(completion, 0); gtk_entry_completion_set_inline_completion(completion, TRUE); gtk_entry_completion_set_popup_set_width(completion, FALSE); gtk_entry_set_completion(GTK_ENTRY(entry), completion); gtk_editable_select_region(GTK_EDITABLE(entry), 0, -1); gtk_container_add(GTK_CONTAINER(d->floating_tag_window), entry); g_signal_connect_swapped(entry, "focus-out-event", G_CALLBACK(gtk_widget_destroy), d->floating_tag_window); g_signal_connect(entry, "key-press-event", G_CALLBACK(_lib_tagging_tag_key_press), self); gtk_widget_show_all(d->floating_tag_window); gtk_widget_grab_focus(entry); gtk_window_present(GTK_WINDOW(d->floating_tag_window)); return TRUE; }
void gui_init (dt_lib_module_t *self) { dt_lib_tagging_t *d = (dt_lib_tagging_t *)malloc(sizeof(dt_lib_tagging_t)); self->data = (void *)d; d->imgsel = -1; self->widget = gtk_vbox_new(TRUE, 5); gtk_widget_set_size_request(self->widget,100,-1); GtkBox *box, *hbox; GtkWidget *button; GtkWidget *w; GtkListStore *liststore; // left side, current box = GTK_BOX(gtk_vbox_new(FALSE, 0)); gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(box), TRUE, TRUE, 0); w = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(w), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_start(box, w, TRUE, TRUE, 0); d->current = GTK_TREE_VIEW(gtk_tree_view_new()); gtk_tree_view_set_headers_visible(d->current, FALSE); liststore = gtk_list_store_new(DT_LIB_TAGGING_NUM_COLS, G_TYPE_STRING, G_TYPE_UINT); GtkTreeViewColumn *col = gtk_tree_view_column_new(); gtk_tree_view_append_column(d->current, col); GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_add_attribute(col, renderer, "text", DT_LIB_TAGGING_COL_TAG); gtk_tree_selection_set_mode(gtk_tree_view_get_selection(d->current), GTK_SELECTION_SINGLE); gtk_tree_view_set_model(d->current, GTK_TREE_MODEL(liststore)); g_object_unref(liststore); g_object_set(G_OBJECT(d->current), "tooltip-text", _("attached tags,\ndoubleclick to detach"), (char *)NULL); g_signal_connect(G_OBJECT (d->current), "row-activated", G_CALLBACK (detach_activated), (gpointer)self); gtk_container_add(GTK_CONTAINER(w), GTK_WIDGET(d->current)); // attach/detach buttons hbox = GTK_BOX(gtk_hbox_new(TRUE, 5)); button = gtk_button_new_with_label(_("attach")); d->attach_button = button; g_object_set(G_OBJECT(button), "tooltip-text", _("attach tag to all selected images"), (char *)NULL); gtk_box_pack_start(hbox, button, FALSE, TRUE, 0); g_signal_connect(G_OBJECT (button), "clicked", G_CALLBACK (attach_button_clicked), (gpointer)self); button = gtk_button_new_with_label(_("detach")); d->detach_button = button; g_object_set(G_OBJECT(button), "tooltip-text", _("detach tag from all selected images"), (char *)NULL); g_signal_connect(G_OBJECT (button), "clicked", G_CALLBACK (detach_button_clicked), (gpointer)self); gtk_box_pack_start(hbox, button, FALSE, TRUE, 0); gtk_box_pack_start(box, GTK_WIDGET(hbox), FALSE, TRUE, 0); // right side, related box = GTK_BOX(gtk_vbox_new(FALSE, 5)); gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(box), TRUE, TRUE, 5); // text entry and new button w = gtk_entry_new(); g_object_set(G_OBJECT(w), "tooltip-text", _("enter tag name"), (char *)NULL); gtk_box_pack_start(box, w, TRUE, TRUE, 0); gtk_widget_add_events(GTK_WIDGET(w), GDK_KEY_RELEASE_MASK); // g_signal_connect(G_OBJECT(w), "key-release-event", g_signal_connect(G_OBJECT(w), "changed", G_CALLBACK(tag_name_changed), (gpointer)self); g_signal_connect(G_OBJECT (w), "activate", G_CALLBACK (entry_activated), (gpointer)self); d->entry = GTK_ENTRY(w); dt_gui_key_accel_block_on_focus_connect(GTK_WIDGET(d->entry)); // related tree view w = gtk_scrolled_window_new(NULL, NULL); gtk_widget_set_size_request(w,-1,100); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(w), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_start(box, w, TRUE, TRUE, 0); d->related = GTK_TREE_VIEW(gtk_tree_view_new()); gtk_tree_view_set_headers_visible(d->related, FALSE); liststore = gtk_list_store_new(DT_LIB_TAGGING_NUM_COLS, G_TYPE_STRING, G_TYPE_UINT); col = gtk_tree_view_column_new(); gtk_tree_view_append_column(d->related, col); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_add_attribute(col, renderer, "text", DT_LIB_TAGGING_COL_TAG); gtk_tree_selection_set_mode(gtk_tree_view_get_selection(d->related), GTK_SELECTION_SINGLE); gtk_tree_view_set_model(d->related, GTK_TREE_MODEL(liststore)); g_object_unref(liststore); g_object_set(G_OBJECT(d->related), "tooltip-text", _("related tags,\ndoubleclick to attach"), (char *)NULL); g_signal_connect(G_OBJECT (d->related), "row-activated", G_CALLBACK (attach_activated), (gpointer)self); gtk_container_add(GTK_CONTAINER(w), GTK_WIDGET(d->related)); // attach and delete buttons hbox = GTK_BOX(gtk_hbox_new(TRUE, 5)); button = gtk_button_new_with_label(_("new")); d->new_button = button; g_object_set(G_OBJECT(button), "tooltip-text", _("create a new tag with the\nname you entered"), (char *)NULL); gtk_box_pack_start(hbox, button, FALSE, TRUE, 0); g_signal_connect(G_OBJECT (button), "clicked", G_CALLBACK (new_button_clicked), (gpointer)self); button = gtk_button_new_with_label(_("delete")); d->delete_button = button; g_object_set(G_OBJECT(button), "tooltip-text", _("delete selected tag"), (char *)NULL); gtk_box_pack_start(hbox, button, FALSE, TRUE, 0); g_signal_connect(G_OBJECT (button), "clicked", G_CALLBACK (delete_button_clicked), (gpointer)self); gtk_box_pack_start(box, GTK_WIDGET(hbox), FALSE, TRUE, 0); // add entry completion GtkEntryCompletion *completion = gtk_entry_completion_new(); gtk_entry_completion_set_model(completion, gtk_tree_view_get_model(GTK_TREE_VIEW(d->related))); gtk_entry_completion_set_text_column(completion, 0); gtk_entry_completion_set_inline_completion(completion, TRUE); gtk_entry_set_completion(d->entry, completion); /* connect to mouse over id */ dt_control_signal_connect(darktable.signals, DT_SIGNAL_MOUSE_OVER_IMAGE_CHANGE, G_CALLBACK(_lib_tagging_redraw_callback), self); dt_control_signal_connect(darktable.signals, DT_SIGNAL_TAG_CHANGED, G_CALLBACK(_lib_tagging_tags_changed_callback), self); set_keyword(self, d); }
static void create_children (GNCGeneralSearch *gsl, const char *label, gboolean text_editable, QofIdTypeConst type, QofBook *book) { GtkListStore * list_store; QofQuery * q; GtkTreeIter iter; GList * list, * it; GtkEntryCompletion *completion; /* Add a text entry box */ gsl->entry = gtk_entry_new (); if (!text_editable) gtk_editable_set_editable (GTK_EDITABLE (gsl->entry), FALSE); gtk_box_pack_start (GTK_BOX (gsl), gsl->entry, TRUE, TRUE, 0); /* Setup a GtkEntryCompletion auxiliary widget for our Entry box * This requires an internal table ("model") with the possible * auto-completion text entries */ /* Query for the requested object type */ q = qof_query_create_for (type); qof_query_add_boolean_match(q, g_slist_prepend (NULL, QOF_PARAM_ACTIVE), TRUE, QOF_QUERY_AND); qof_query_set_book (q, book); list = qof_query_run(q); /* Setup the internal model */ list_store = gtk_list_store_new (GSL_N_COLUMNS, G_TYPE_STRING, G_TYPE_OBJECT); for (it = list; it != NULL ; it = it->next) { char * name; name = g_strdup(qof_object_printable(type, it->data)); /* Add a new row to the model */ if (name) { gtk_list_store_append (list_store, &iter); gtk_list_store_set (list_store, &iter, GSL_COLUMN_TEXT, name, GSL_COLUMN_QOFOBJECT, G_OBJECT(it->data), -1); g_free(name); } } qof_query_destroy(q); /* Add the GtkEntryCompletion widget */ completion = gtk_entry_completion_new(); gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(list_store)); gtk_entry_completion_set_text_column(completion, 0); gtk_entry_completion_set_inline_completion(completion, TRUE); gtk_entry_set_completion(GTK_ENTRY(gsl->entry), completion); g_signal_connect (G_OBJECT (completion), "match_selected", G_CALLBACK (gnc_gsl_match_selected_cb), gsl); g_signal_connect (G_OBJECT (gsl->entry), "focus-out-event", G_CALLBACK (gnc_gsl_focus_out_cb), gsl); g_object_unref(completion); gtk_widget_show (gsl->entry); /* Add the search button */ gsl->button = gtk_button_new_with_label (label); gtk_box_pack_start (GTK_BOX (gsl), gsl->button, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (gsl->button), "clicked", G_CALLBACK (search_cb), gsl); gtk_widget_show (gsl->button); }
void gui_init(dt_lib_module_t *self) { dt_lib_styles_t *d = (dt_lib_styles_t *)malloc(sizeof(dt_lib_styles_t)); self->data = (void *)d; d->edit_button = NULL; self->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); GtkWidget *w; GtkWidget *scrolled; /* list */ d->list = GTK_TREE_VIEW(gtk_tree_view_new()); gtk_tree_view_set_headers_visible(d->list, FALSE); GtkListStore *liststore = gtk_list_store_new(DT_STYLES_NUM_COLS, G_TYPE_STRING, G_TYPE_STRING); GtkTreeViewColumn *col = gtk_tree_view_column_new(); gtk_tree_view_append_column(GTK_TREE_VIEW(d->list), col); GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_add_attribute(col, renderer, "text", DT_STYLES_COL_NAME); gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(d->list)), GTK_SELECTION_SINGLE); gtk_tree_view_set_model(GTK_TREE_VIEW(d->list), GTK_TREE_MODEL(liststore)); g_object_unref(liststore); g_object_set(G_OBJECT(d->list), "tooltip-text", _("available styles,\ndoubleclick to apply"), (char *)NULL); g_signal_connect(d->list, "row-activated", G_CALLBACK(_styles_row_activated_callback), d); /* filter entry */ w = gtk_entry_new(); d->entry = GTK_ENTRY(w); g_object_set(G_OBJECT(w), "tooltip-text", _("enter style name"), (char *)NULL); g_signal_connect(d->entry, "changed", G_CALLBACK(entry_callback), d); g_signal_connect(d->entry, "activate", G_CALLBACK(entry_activated), d); dt_gui_key_accel_block_on_focus_connect(GTK_WIDGET(d->entry)); scrolled = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(scrolled), DT_PIXEL_APPLY_DPI(150)); gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(d->entry), TRUE, FALSE, 0); gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(scrolled), TRUE, FALSE, 0); gtk_container_add(GTK_CONTAINER(scrolled), GTK_WIDGET(d->list)); d->duplicate = gtk_check_button_new_with_label(_("create duplicate")); gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(d->duplicate), TRUE, FALSE, 0); g_signal_connect(d->duplicate, "toggled", G_CALLBACK(duplicate_callback), d); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(d->duplicate), dt_conf_get_bool("ui_last/styles_create_duplicate")); g_object_set(d->duplicate, "tooltip-text", _("creates a duplicate of the image before applying style"), (char *)NULL); GtkWidget *hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5); GtkWidget *hbox2 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5); gtk_box_pack_start(GTK_BOX(self->widget), hbox1, TRUE, FALSE, 0); gtk_box_pack_start(GTK_BOX(self->widget), hbox2, TRUE, FALSE, 0); // create GtkWidget *cbutton = gtk_button_new_with_label(_("create")); g_signal_connect(G_OBJECT(cbutton), "clicked", G_CALLBACK(create_clicked), d); g_object_set(G_OBJECT(cbutton), "tooltip-text", _("create styles from history stack of selected images"), (char *)NULL); gtk_box_pack_start(GTK_BOX(hbox1), cbutton, TRUE, TRUE, 0); // edit GtkWidget *widget = gtk_button_new_with_label(_("edit")); d->edit_button = widget; g_signal_connect(widget, "clicked", G_CALLBACK(edit_clicked), d); g_object_set(widget, "tooltip-text", _("edit the selected style in list above"), (char *)NULL); gtk_box_pack_start(GTK_BOX(hbox1), widget, TRUE, TRUE, 0); // delete widget = gtk_button_new_with_label(_("delete")); d->delete_button = widget; g_signal_connect(widget, "clicked", G_CALLBACK(delete_clicked), d); g_object_set(widget, "tooltip-text", _("deletes the selected style in list above"), (char *)NULL); gtk_box_pack_start(GTK_BOX(hbox1), widget, TRUE, TRUE, 0); // import button GtkWidget *importButton = gtk_button_new_with_label(C_("styles", "import")); d->import_button = importButton; g_object_set(importButton, "tooltip-text", _("import style from a style file"), (char *)NULL); g_signal_connect(importButton, "clicked", G_CALLBACK(import_clicked), d); gtk_box_pack_start(GTK_BOX(hbox2), importButton, TRUE, TRUE, 0); // export button GtkWidget *exportButton = gtk_button_new_with_label(_("export")); d->export_button = exportButton; g_object_set(exportButton, "tooltip-text", _("export the selected style into a style file"), (char *)NULL); g_signal_connect(exportButton, "clicked", G_CALLBACK(export_clicked), d); gtk_box_pack_start(GTK_BOX(hbox2), exportButton, TRUE, TRUE, 0); // add entry completion GtkEntryCompletion *completion = gtk_entry_completion_new(); gtk_entry_completion_set_model(completion, gtk_tree_view_get_model(GTK_TREE_VIEW(d->list))); gtk_entry_completion_set_text_column(completion, 0); gtk_entry_completion_set_inline_completion(completion, TRUE); gtk_entry_set_completion(d->entry, completion); /* update filtered list */ _gui_styles_update_view(d); }
GtkWidget* create_tool_item( GtkAction* action ) { GtkWidget* item = 0; if ( IS_EGE_SELECT_ONE_ACTION(action) && EGE_SELECT_ONE_ACTION(action)->private_data->model ) { EgeSelectOneAction* act = EGE_SELECT_ONE_ACTION(action); item = GTK_WIDGET( gtk_tool_item_new() ); if ( act->private_data->appearanceMode == APPEARANCE_FULL ) { #if GTK_CHECK_VERSION(3,0,0) GtkWidget* holder = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous(GTK_BOX(holder), FALSE); #else GtkWidget* holder = gtk_hbox_new( FALSE, 0 ); #endif GtkRadioAction* ract = 0; GSList* group = 0; GtkTreeIter iter; gboolean valid = FALSE; gint index = 0; { gchar* sss = 0; g_object_get( G_OBJECT(action), "short_label", &sss, NULL ); // If short_label not defined, g_object_get will return label. // This hack allows a label to be used with a drop-down menu when // no label is used with a set of icons that are self-explanatory. if (sss && strcmp( sss, "NotUsed" ) != 0 ) { GtkWidget* lbl = gtk_label_new(sss); gtk_box_pack_start( GTK_BOX(holder), lbl, FALSE, FALSE, 4 ); } g_free( sss ); sss = 0; } valid = gtk_tree_model_get_iter_first( act->private_data->model, &iter ); while ( valid ) { gchar* str = 0; gchar* tip = 0; gchar* iconId = 0; gboolean sens = true; /* gint size = 0; */ gtk_tree_model_get( act->private_data->model, &iter, act->private_data->labelColumn, &str, -1 ); if ( act->private_data->iconColumn >= 0 ) { gtk_tree_model_get( act->private_data->model, &iter, act->private_data->iconColumn, &iconId, -1 ); } if ( act->private_data->tooltipColumn >= 0 ) { gtk_tree_model_get( act->private_data->model, &iter, act->private_data->tooltipColumn, &tip, -1 ); } if ( act->private_data->sensitiveColumn >= 0 ) { gtk_tree_model_get( act->private_data->model, &iter, act->private_data->sensitiveColumn, &sens, -1 ); } if ( act->private_data->radioActionType ) { void* obj = g_object_new( act->private_data->radioActionType, "name", "Name 1", "label", str, "tooltip", tip, "value", index, /* "iconId", iconId, "iconSize", size, */ NULL ); if ( iconId ) { g_object_set( G_OBJECT(obj), act->private_data->iconProperty, iconId, NULL ); } if ( act->private_data->iconProperty ) { /* TODO get this string to be set instead of hardcoded */ if ( act->private_data->iconSize >= 0 ) { g_object_set( G_OBJECT(obj), "iconSize", act->private_data->iconSize, NULL ); } } ract = GTK_RADIO_ACTION(obj); } else { ract = gtk_radio_action_new( "Name 1", str, tip, iconId, index ); } if ( act->private_data->sensitiveColumn >= 0 ) { gtk_action_set_sensitive( GTK_ACTION(ract), sens ); } gtk_radio_action_set_group( ract, group ); group = gtk_radio_action_get_group( ract ); if ( index == act->private_data->active ) { gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(ract), TRUE ); } g_signal_connect( G_OBJECT(ract), "changed", G_CALLBACK( proxy_action_chagned_cb ), act ); GtkWidget* sub = gtk_action_create_tool_item( GTK_ACTION(ract) ); gtk_activatable_set_related_action( GTK_ACTIVATABLE (sub), GTK_ACTION(ract) ); gtk_tool_item_set_tooltip_text( GTK_TOOL_ITEM(sub), tip ); gtk_box_pack_start( GTK_BOX(holder), sub, FALSE, FALSE, 0 ); g_free( str ); g_free( tip ); g_free( iconId ); index++; valid = gtk_tree_model_iter_next( act->private_data->model, &iter ); } g_object_set_data( G_OBJECT(holder), "ege-proxy_action-group", group ); gtk_container_add( GTK_CONTAINER(item), holder ); } else { #if GTK_CHECK_VERSION(3,0,0) GtkWidget* holder = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4); gtk_box_set_homogeneous(GTK_BOX(holder), FALSE); #else GtkWidget *holder = gtk_hbox_new( FALSE, 4 ); #endif GtkEntry *entry = 0; GtkWidget *normal; if (act->private_data->selectionMode == SELECTION_OPEN) { normal = gtk_combo_box_new_with_model_and_entry (act->private_data->model); gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (normal), act->private_data->labelColumn); GtkWidget *child = gtk_bin_get_child( GTK_BIN(normal) ); if (GTK_IS_ENTRY(child)) { int maxUsed = scan_max_width( act->private_data->model, act->private_data->labelColumn ); GtkEntryCompletion *complete = 0; entry = GTK_ENTRY(child); gtk_entry_set_width_chars(entry, maxUsed); /* replace with property */ complete = gtk_entry_completion_new(); gtk_entry_completion_set_model( complete, act->private_data->model ); gtk_entry_completion_set_text_column( complete, act->private_data->labelColumn ); gtk_entry_completion_set_inline_completion( complete, FALSE ); gtk_entry_completion_set_inline_selection( complete, FALSE ); gtk_entry_completion_set_popup_completion( complete, TRUE ); gtk_entry_completion_set_popup_set_width( complete, FALSE ); gtk_entry_set_completion( entry, complete ); g_signal_connect( G_OBJECT(child), "activate", G_CALLBACK(combo_entry_changed_cb), act ); g_signal_connect( G_OBJECT(child), "focus-out-event", G_CALLBACK(combo_entry_focus_lost_cb), act ); } } else { GtkCellRenderer * renderer = NULL; normal = gtk_combo_box_new_with_model( act->private_data->model ); if ( act->private_data->iconColumn >= 0 ) { renderer = gtk_cell_renderer_pixbuf_new(); gtk_cell_layout_pack_start( GTK_CELL_LAYOUT(normal), renderer, TRUE ); /* "icon-name" */ gtk_cell_layout_add_attribute( GTK_CELL_LAYOUT(normal), renderer, "stock-id", act->private_data->iconColumn ); } renderer = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start( GTK_CELL_LAYOUT(normal), renderer, TRUE ); gtk_cell_layout_add_attribute( GTK_CELL_LAYOUT(normal), renderer, "text", act->private_data->labelColumn ); } gtk_combo_box_set_active( GTK_COMBO_BOX(normal), act->private_data->active ); if ( entry && (act->private_data->active == -1) ) { gtk_entry_set_text( entry, act->private_data->activeText ); } g_signal_connect( G_OBJECT(normal), "changed", G_CALLBACK(combo_changed_cb), action ); g_object_set_data( G_OBJECT(holder), "ege-combo-box", normal ); g_object_set_data( G_OBJECT(act), "ege-combo-box", normal ); if (act->private_data->appearanceMode == APPEARANCE_COMPACT) { gchar* sss = 0; g_object_get( G_OBJECT(action), "short_label", &sss, NULL ); if (sss) { GtkWidget* lbl = gtk_label_new(sss); gtk_box_pack_start( GTK_BOX(holder), lbl, FALSE, FALSE, 4 ); g_free( sss ); sss = 0; } } gtk_box_pack_start( GTK_BOX(holder), normal, FALSE, FALSE, 0 ); { #if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_halign(holder, GTK_ALIGN_START); gtk_container_add(GTK_CONTAINER(item), holder); #else GtkWidget *align = gtk_alignment_new(0, 0.5, 0, 0); gtk_container_add( GTK_CONTAINER(align), holder); gtk_container_add( GTK_CONTAINER(item), align ); #endif } } gtk_widget_show_all( item ); } else { item = GTK_ACTION_CLASS(ege_select_one_action_parent_class)->create_tool_item( action ); } return item; }
void gui_init(dt_lib_module_t *self) { GtkBox *hbox; GtkWidget *button; GtkWidget *label; GtkEntryCompletion *completion; int line = 0; dt_lib_metadata_t *d = (dt_lib_metadata_t *)calloc(1, sizeof(dt_lib_metadata_t)); self->data = (void *)d; d->imgsel = -1; self->widget = gtk_grid_new(); gtk_grid_set_row_spacing(GTK_GRID(self->widget), DT_PIXEL_APPLY_DPI(5)); gtk_grid_set_column_spacing(GTK_GRID(self->widget), DT_PIXEL_APPLY_DPI(10)); g_signal_connect(self->widget, "draw", G_CALLBACK(draw), self); struct { char *name; GtkComboBox **box; } entries[] = { // clang-format off {N_("title"), &d->title}, {N_("description"), &d->description}, {N_("creator"), &d->creator}, {N_("publisher"), &d->publisher}, {N_("rights"), &d->rights} // clang-format on }; for(line = 0; line < sizeof(entries) / sizeof(entries[0]); line++) { label = gtk_label_new(_(entries[line].name)); g_object_set(G_OBJECT(label), "xalign", 0.0, (gchar *)0); GtkWidget *combobox = gtk_combo_box_text_new_with_entry(); *(entries[line].box) = GTK_COMBO_BOX(combobox); gtk_widget_set_hexpand(combobox, TRUE); GtkWidget *entry = gtk_bin_get_child(GTK_BIN(combobox)); dt_gui_key_accel_block_on_focus_connect(entry); completion = gtk_entry_completion_new(); gtk_entry_completion_set_model(completion, gtk_combo_box_get_model(GTK_COMBO_BOX(combobox))); gtk_entry_completion_set_text_column(completion, 0); gtk_entry_completion_set_inline_completion(completion, TRUE); gtk_entry_set_completion(GTK_ENTRY(entry), completion); g_object_unref(completion); g_signal_connect(entry, "key-press-event", G_CALLBACK(key_pressed), self); gtk_entry_set_width_chars(GTK_ENTRY(entry), 0); gtk_grid_attach(GTK_GRID(self->widget), label, 0, line, 1, 1); gtk_grid_attach_next_to(GTK_GRID(self->widget), combobox, label, GTK_POS_RIGHT, 1, 1); } // reset/apply buttons hbox = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5)); button = gtk_button_new_with_label(_("clear")); d->clear_button = button; gtk_widget_set_hexpand(GTK_WIDGET(button), TRUE); gtk_widget_set_tooltip_text(button, _("remove metadata from selected images")); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(clear_button_clicked), (gpointer)self); gtk_box_pack_start(hbox, button, FALSE, TRUE, 0); button = gtk_button_new_with_label(_("apply")); d->apply_button = button; gtk_widget_set_hexpand(GTK_WIDGET(button), TRUE); gtk_widget_set_tooltip_text(button, _("write metadata for selected images")); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(apply_button_clicked), (gpointer)self); gtk_box_pack_start(hbox, button, FALSE, TRUE, 0); gtk_widget_set_margin_top(GTK_WIDGET(hbox), DT_PIXEL_APPLY_DPI(5)); gtk_grid_attach(GTK_GRID(self->widget), GTK_WIDGET(hbox), 0, line, 2, 1); /* lets signup for mouse over image change signals */ dt_control_signal_connect(darktable.signals, DT_SIGNAL_MOUSE_OVER_IMAGE_CHANGE, G_CALLBACK(_mouse_over_image_callback), self); }
/*! \brief sets up and populates the MS2-Extra combo for output choice \param widget is the pointer to the combo to initialize */ G_MODULE_EXPORT void ms2_output_combo_setup(GtkWidget *widget) { guint i = 0; GtkWidget *parent = NULL; gchar * lower = NULL; gchar * upper = NULL; gfloat * multiplier = NULL; gfloat * adder = NULL; gfloat * testmult = NULL; gchar * range = NULL; gint bitval = 0; gint width = 0; DataSize size = MTX_U08; gint precision = 0; gconstpointer * object = NULL; gint raw_lower = 0; gint raw_upper = 0; gboolean freelower = FALSE; gboolean freeupper = FALSE; gchar *raw_lower_str = NULL; gchar *raw_upper_str = NULL; gfloat real_lower = 0.0; gfloat real_upper = 0.0; gfloat tmpf = 0.0; gchar * name = NULL; gchar *internal_names = NULL; GtkWidget *entry = NULL; GtkEntryCompletion *completion = NULL; GtkListStore *store = NULL; GtkTreeIter iter; ENTER(); Rtv_Map *rtv_map = NULL; rtv_map = (Rtv_Map *)DATA_GET(global_data,"rtv_map"); if (!rtv_map) { EXIT(); return; } /* Create the store for the combo, with severla hidden values */ store = gtk_list_store_new(UO_COMBO_COLS,G_TYPE_STRING,G_TYPE_UCHAR,G_TYPE_POINTER,G_TYPE_POINTER,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_UCHAR,G_TYPE_UCHAR); /* Iterate across valid variables */ for (i=0;i<rtv_map->rtv_list->len;i++) { freelower = FALSE; freeupper = FALSE; object = NULL; name = NULL; object = (gconstpointer *)g_ptr_array_index(rtv_map->rtv_list,i); if (!object) continue; name = (gchar *) DATA_GET(object,"dlog_gui_name"); if (!name) continue; if (DATA_GET(object,"fromecu_complex")) continue; if (DATA_GET(object,"special")) continue; internal_names = (gchar *) DATA_GET(object,"internal_names"); if (!find_in_list(rtv_map->raw_list,internal_names)) continue; size = (DataSize)(GINT)DATA_GET(object,"size"); multiplier = (gfloat *)DATA_GET(object,"fromecu_mult"); adder = (gfloat *)DATA_GET(object,"fromecu_add"); precision = (GINT) DATA_GET(object,"precision"); bitval = (GINT) DATA_GET(object,"offset"); if (DATA_GET(object,"real_lower")) { lower = (gchar *)DATA_GET(object,"real_lower"); real_lower = g_strtod(lower,NULL); raw_lower = calc_value_f(real_lower,multiplier,adder,TOECU); } else { raw_lower = get_extreme_from_size_f(size,LOWER); tmpf = calc_value_f(raw_lower,multiplier,adder,FROMECU); lower = g_strdup_printf("%i",(gint)tmpf); freelower = TRUE; } if (DATA_GET(object,"real_upper")) { upper = (gchar *)DATA_GET(object,"real_upper"); real_upper = g_strtod(upper,NULL); raw_upper = calc_value_f(real_upper,multiplier,adder,TOECU); } else { raw_upper = get_extreme_from_size_f(size,UPPER); tmpf = calc_value_f(raw_upper,multiplier,adder,FROMECU); upper = g_strdup_printf("%i",(gint)tmpf); freeupper = TRUE; } range = g_strdup_printf("Valid Range: %s <-> %s",lower,upper); if (freelower) g_free(lower); if (freeupper) g_free(upper); if ((multiplier) && (adder)) { raw_lower = (GINT)((real_lower - (*adder))/(*multiplier)); raw_upper = (GINT)((real_upper - (*adder))/(*multiplier)); } else if (multiplier) { raw_lower = (GINT)(real_lower/(*multiplier)); raw_upper = (GINT)(real_upper/(*multiplier)); } else { raw_lower = (GINT)real_lower; raw_upper = (GINT)real_upper; } raw_lower_str = g_strdup_printf("%i",raw_lower); raw_upper_str = g_strdup_printf("%i",raw_upper); gtk_list_store_append(store,&iter); gtk_list_store_set(store,&iter, UO_CHOICE_COL,name, UO_BITVAL_COL,bitval, UO_FROMECU_MULT_COL,multiplier, UO_FROMECU_ADD_COL,adder, UO_RAW_LOWER_COL,raw_lower_str, UO_RAW_UPPER_COL,raw_upper_str, UO_RANGE_COL,range, UO_SIZE_COL,size, UO_PRECISION_COL,precision, -1); g_free(raw_lower_str); g_free(raw_upper_str); g_free(range); } /*#if GTK_MINOR_VERSION < 24 */ if (GTK_IS_COMBO_BOX_ENTRY(widget)) { gtk_combo_box_entry_set_text_column(GTK_COMBO_BOX_ENTRY(widget),UO_CHOICE_COL); /* #else if (GTK_IS_COMBO_BOX(widget)) { gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(widget),UO_CHOICE_COL); #endif */ gtk_combo_box_set_model(GTK_COMBO_BOX(widget),GTK_TREE_MODEL(store)); g_object_unref(store); entry = gtk_bin_get_child(GTK_BIN(widget)); /* Nasty hack, but otherwise the entry is an obnoxious size.. */ if ((width = (GINT)OBJ_GET((GtkWidget *)widget,"max_chars")) > 0) gtk_entry_set_width_chars(GTK_ENTRY(entry),width); else gtk_entry_set_width_chars(GTK_ENTRY(entry),12); gtk_widget_set_size_request(GTK_WIDGET(widget),-1,(3*(GINT)DATA_GET(global_data,"font_size"))); // gtk_container_remove (GTK_CONTAINER (widget), gtk_bin_get_child(GTK_BIN(widget))); // gtk_container_add (GTK_CONTAINER (widget), entry); completion = gtk_entry_completion_new(); gtk_entry_set_completion(GTK_ENTRY(entry),completion); g_object_unref(completion); gtk_entry_completion_set_model(completion,GTK_TREE_MODEL(store)); gtk_entry_completion_set_text_column(completion,UO_CHOICE_COL); gtk_entry_completion_set_inline_completion(completion,TRUE); gtk_entry_completion_set_inline_selection(completion,TRUE); gtk_entry_completion_set_popup_single_match(completion,FALSE); OBJ_SET(widget,"arrow-size",GINT_TO_POINTER(1)); } EXIT(); return; }
void gui_init(dt_lib_module_t *self) { GtkBox *hbox; GtkWidget *button; GtkWidget *label; GtkEntryCompletion *completion; dt_lib_metadata_t *d = (dt_lib_metadata_t *)calloc(1, sizeof(dt_lib_metadata_t)); self->data = (void *)d; d->imgsel = -1; self->widget = gtk_table_new(6, 2, FALSE); gtk_table_set_row_spacings(GTK_TABLE(self->widget), 5); g_signal_connect(self->widget, "expose-event", G_CALLBACK(expose), self); label = gtk_label_new(_("title")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(self->widget), label, 0, 1, 0, 1, GTK_EXPAND|GTK_FILL, 0, 0, 0); d->title = GTK_COMBO_BOX(gtk_combo_box_text_new_with_entry()); dt_gui_key_accel_block_on_focus_connect(GTK_WIDGET(gtk_bin_get_child(GTK_BIN(d->title)))); completion = gtk_entry_completion_new(); gtk_entry_completion_set_model(completion, gtk_combo_box_get_model(GTK_COMBO_BOX(d->title))); gtk_entry_completion_set_text_column(completion, 0); gtk_entry_completion_set_inline_completion(completion, TRUE); gtk_entry_set_completion(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(d->title))), completion); g_signal_connect (GTK_WIDGET(gtk_bin_get_child(GTK_BIN(d->title))), "key-press-event", G_CALLBACK (key_pressed), self); gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(d->title), 1, 2, 0, 1, GTK_EXPAND|GTK_FILL, 0, 0, 0); label = gtk_label_new(_("description")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(self->widget), label, 0, 1, 1, 2, GTK_EXPAND|GTK_FILL, 0, 0, 0); d->description = GTK_COMBO_BOX(gtk_combo_box_text_new_with_entry()); dt_gui_key_accel_block_on_focus_connect(GTK_WIDGET(gtk_bin_get_child(GTK_BIN(d->description)))); completion = gtk_entry_completion_new(); gtk_entry_completion_set_model(completion, gtk_combo_box_get_model(GTK_COMBO_BOX(d->description))); gtk_entry_completion_set_text_column(completion, 0); gtk_entry_completion_set_inline_completion(completion, TRUE); gtk_entry_set_completion(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(d->description))), completion); g_signal_connect (GTK_WIDGET(gtk_bin_get_child(GTK_BIN(d->description))), "key-press-event", G_CALLBACK (key_pressed), self); gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(d->description), 1, 2, 1, 2, GTK_EXPAND|GTK_FILL, 0, 0, 0); label = gtk_label_new(_("creator")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(self->widget), label, 0, 1, 2, 3, GTK_EXPAND|GTK_FILL, 0, 0, 0); d->creator = GTK_COMBO_BOX(gtk_combo_box_text_new_with_entry()); dt_gui_key_accel_block_on_focus_connect(GTK_WIDGET(gtk_bin_get_child(GTK_BIN(d->creator)))); completion = gtk_entry_completion_new(); gtk_entry_completion_set_model(completion, gtk_combo_box_get_model(GTK_COMBO_BOX(d->creator))); gtk_entry_completion_set_text_column(completion, 0); gtk_entry_completion_set_inline_completion(completion, TRUE); gtk_entry_set_completion(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(d->creator))), completion); g_signal_connect (GTK_WIDGET(gtk_bin_get_child(GTK_BIN(d->creator))), "key-press-event", G_CALLBACK (key_pressed), self); gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(d->creator), 1, 2, 2, 3, GTK_EXPAND|GTK_FILL, 0, 0, 0); label = gtk_label_new(_("publisher")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(self->widget), label, 0, 1, 3, 4, GTK_EXPAND|GTK_FILL, 0, 0, 0); d->publisher = GTK_COMBO_BOX(gtk_combo_box_text_new_with_entry()); dt_gui_key_accel_block_on_focus_connect(GTK_WIDGET(gtk_bin_get_child(GTK_BIN(d->publisher)))); completion = gtk_entry_completion_new(); gtk_entry_completion_set_model(completion, gtk_combo_box_get_model(GTK_COMBO_BOX(d->publisher))); gtk_entry_completion_set_text_column(completion, 0); gtk_entry_completion_set_inline_completion(completion, TRUE); gtk_entry_set_completion(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(d->publisher))), completion); g_signal_connect (GTK_WIDGET(gtk_bin_get_child(GTK_BIN(d->publisher))), "key-press-event", G_CALLBACK (key_pressed), self); gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(d->publisher), 1, 2, 3, 4, GTK_EXPAND|GTK_FILL, 0, 0, 0); label = gtk_label_new(_("rights")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(self->widget), label, 0, 1, 4, 5, GTK_EXPAND|GTK_FILL, 0, 0, 0); d->rights = GTK_COMBO_BOX(gtk_combo_box_text_new_with_entry()); dt_gui_key_accel_block_on_focus_connect(GTK_WIDGET(gtk_bin_get_child(GTK_BIN(d->rights)))); completion = gtk_entry_completion_new(); gtk_entry_completion_set_model(completion, gtk_combo_box_get_model(GTK_COMBO_BOX(d->rights))); gtk_entry_completion_set_text_column(completion, 0); gtk_entry_completion_set_inline_completion(completion, TRUE); gtk_entry_set_completion(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(d->rights))), completion); g_signal_connect (GTK_WIDGET(gtk_bin_get_child(GTK_BIN(d->rights))), "key-press-event", G_CALLBACK (key_pressed), self); gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(d->rights), 1, 2, 4, 5, GTK_EXPAND|GTK_FILL, 0, 0, 0); g_object_unref(completion); // reset/apply buttons hbox = GTK_BOX(gtk_hbox_new(TRUE, 5)); button = gtk_button_new_with_label(_("clear")); d->clear_button = button; g_object_set(G_OBJECT(button), "tooltip-text", _("remove metadata from selected images"), (char *)NULL); gtk_box_pack_start(hbox, button, FALSE, TRUE, 0); g_signal_connect(G_OBJECT (button), "clicked", G_CALLBACK (clear_button_clicked), (gpointer)self); button = gtk_button_new_with_label(_("apply")); d->apply_button = button; g_object_set(G_OBJECT(button), "tooltip-text", _("write metadata for selected images"), (char *)NULL); g_signal_connect(G_OBJECT (button), "clicked", G_CALLBACK (apply_button_clicked), (gpointer)self); gtk_box_pack_start(hbox, button, FALSE, TRUE, 0); gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(hbox), 0, 2, 5, 6, GTK_EXPAND|GTK_FILL, 0, 0, 0); /* lets signup for mouse over image change signals */ dt_control_signal_connect(darktable.signals,DT_SIGNAL_MOUSE_OVER_IMAGE_CHANGE, G_CALLBACK(_mouse_over_image_callback), self); }
/*! \brief sets up and populates the MS2-Extra combo for output choice \param widget is the pointer to the combo to initialize */ G_MODULE_EXPORT void ms2_output_combo_setup(GtkWidget *widget) { guint i = 0; GtkWidget *parent = NULL; gchar * lower = NULL; gchar * upper = NULL; gfloat * multiplier = NULL; gfloat * adder = NULL; gfloat * testmult = NULL; gchar * range = NULL; gint bitval = 0; gint width = 0; DataSize size = MTX_U08; gint precision = 0; gconstpointer * object = NULL; gint raw_lower = 0; gint raw_upper = 0; gboolean temp_dep = FALSE; gchar *raw_lower_str = NULL; gchar *raw_upper_str = NULL; gchar *tempc_range = NULL; gchar *tempf_range = NULL; gchar *tempk_range = NULL; gfloat real_lower = 0.0; gfloat real_upper = 0.0; gfloat tmpf = 0.0; gchar * name = NULL; gchar *internal_names = NULL; GtkWidget *entry = NULL; GtkEntryCompletion *completion = NULL; GtkListStore *store = NULL; GtkTreeIter iter; ENTER(); Rtv_Map *rtv_map = NULL; rtv_map = (Rtv_Map *)DATA_GET(global_data,"rtv_map"); if (!rtv_map) { EXIT(); return; } /* Create the store for the combo, with severla hidden values */ store = gtk_list_store_new(UO_COMBO_COLS, G_TYPE_STRING, /* Choice */ G_TYPE_UCHAR, /* BITval */ G_TYPE_POINTER, /* FromECU Multiplier (gfloat *) */ G_TYPE_POINTER, /* FromECU Adder (gfloat *) */ G_TYPE_STRING, /* Raw Lower clamp limit */ G_TYPE_STRING, /* Raw Upper clamp limit */ G_TYPE_STRING, /* Range widget string (non temp ctrls) */ G_TYPE_STRING, /* Range widget string (Celsius) */ G_TYPE_STRING, /* Range widget string (Fahrenheit) */ G_TYPE_STRING, /* Range widget string (Kelvin) */ G_TYPE_INT, /* Size enumeration (_U08_, _U16_, etc.) */ G_TYPE_UCHAR, /* Precision (floating point precision) */ G_TYPE_BOOLEAN);/* Temp dependent flag */ /* Iterate across valid variables */ for (i=0;i<rtv_map->rtv_list->len;i++) { object = NULL; name = NULL; object = (gconstpointer *)g_ptr_array_index(rtv_map->rtv_list,i); if (!object) continue; name = (gchar *) DATA_GET(object,"dlog_gui_name"); if (!name) continue; if (DATA_GET(object,"fromecu_complex")) continue; if (DATA_GET(object,"special")) continue; internal_names = (gchar *) DATA_GET(object,"internal_names"); if (!find_in_list(rtv_map->raw_list,internal_names)) continue; temp_dep = (GBOOLEAN)DATA_GET(object,"temp_dep"); size = (DataSize)(GINT)DATA_GET(object,"size"); multiplier = (gfloat *)DATA_GET(object,"fromecu_mult"); adder = (gfloat *)DATA_GET(object,"fromecu_add"); precision = (GINT) DATA_GET(object,"precision"); bitval = (GINT) DATA_GET(object,"offset"); if (DATA_GET(object,"real_lower")) { lower = (gchar *)DATA_GET(object,"real_lower"); real_lower = g_strtod(lower,NULL); raw_lower = calc_value_f(real_lower,multiplier,adder,TOECU); } else raw_lower = get_extreme_from_size_f(size,LOWER); if (DATA_GET(object,"real_upper")) { upper = (gchar *)DATA_GET(object,"real_upper"); real_upper = g_strtod(upper,NULL); raw_upper = calc_value_f(real_upper,multiplier,adder,TOECU); } else raw_upper = get_extreme_from_size_f(size,UPPER); range = g_strdup_printf("Valid Range: %.1f <-> %.1f",real_lower,real_upper); if (temp_dep) { tempc_range = g_strdup_printf("Valid Range: %.1f\302\260C <-> %.1f\302\260C",f_to_c_f(real_lower),f_to_c_f(real_upper)); tempf_range = g_strdup_printf("Valid Range: %.1f\302\260F <-> %.1f\302\260F",real_lower,real_upper); tempk_range = g_strdup_printf("Valid Range: %.1f\302\260K <-> %.1f\302\260K",f_to_k_f(real_lower),f_to_k_f(real_upper)); } else { tempc_range = g_strdup(range); tempf_range = g_strdup(range); tempk_range = g_strdup(range); } raw_lower_str = g_strdup_printf("%i",raw_lower); raw_upper_str = g_strdup_printf("%i",raw_upper); gtk_list_store_append(store,&iter); gtk_list_store_set(store,&iter, UO_CHOICE_COL,name, UO_BITVAL_COL,bitval, UO_FROMECU_MULT_COL,multiplier, UO_FROMECU_ADD_COL,adder, UO_RAW_LOWER_COL,raw_lower_str, UO_RAW_UPPER_COL,raw_upper_str, UO_RANGE_COL,range, UO_RANGE_TEMPC_COL,tempc_range, UO_RANGE_TEMPF_COL,tempf_range, UO_RANGE_TEMPK_COL,tempk_range, UO_SIZE_COL,size, UO_PRECISION_COL,precision, UO_TEMP_DEP_COL,temp_dep, -1); g_free(raw_lower_str); g_free(raw_upper_str); g_free(range); g_free(tempc_range); g_free(tempf_range); g_free(tempk_range); } if (GTK_IS_COMBO_BOX_ENTRY(widget)) { gtk_combo_box_entry_set_text_column(GTK_COMBO_BOX_ENTRY(widget),UO_CHOICE_COL); gtk_combo_box_set_model(GTK_COMBO_BOX(widget),GTK_TREE_MODEL(store)); g_object_unref(store); entry = gtk_bin_get_child(GTK_BIN(widget)); /* Nasty hack, but otherwise the entry is an obnoxious size.. */ if ((width = (GINT)OBJ_GET((GtkWidget *)widget,"max_chars")) > 0) gtk_entry_set_width_chars(GTK_ENTRY(entry),width); else gtk_entry_set_width_chars(GTK_ENTRY(entry),12); gtk_widget_set_size_request(GTK_WIDGET(widget),-1,(3*(GINT)DATA_GET(global_data,"font_size"))); // gtk_container_remove (GTK_CONTAINER (widget), gtk_bin_get_child(GTK_BIN(widget))); // gtk_container_add (GTK_CONTAINER (widget), entry); completion = gtk_entry_completion_new(); gtk_entry_set_completion(GTK_ENTRY(entry),completion); g_object_unref(completion); gtk_entry_completion_set_model(completion,GTK_TREE_MODEL(store)); gtk_entry_completion_set_text_column(completion,UO_CHOICE_COL); gtk_entry_completion_set_inline_completion(completion,TRUE); gtk_entry_completion_set_inline_selection(completion,TRUE); gtk_entry_completion_set_popup_single_match(completion,FALSE); OBJ_SET(widget,"arrow-size",GINT_TO_POINTER(1)); } EXIT(); return; }
static void inline_radio_toggled(GtkToggleButton *button, gpointer data) { gtk_entry_completion_set_popup_completion(g_completion, FALSE); gtk_entry_completion_set_inline_completion(g_completion, TRUE); }
int main (int argc, char *argv[]) { GtkWidget *vbox; GtkWidget *label; GtkWidget *entry; GtkEntryCompletion *completion; GtkTreeModel *completion_model; GtkCellRenderer *cell; gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_container_set_border_width (GTK_CONTAINER (window), 5); g_signal_connect (window, "delete_event", gtk_main_quit, NULL); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); gtk_container_add (GTK_CONTAINER (window), vbox); gtk_container_set_border_width (GTK_CONTAINER (vbox), 5); label = gtk_label_new (NULL); gtk_label_set_markup (GTK_LABEL (label), "Completion demo, try writing <b>total</b> or <b>gnome</b> for example."); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); /* Create our first entry */ entry = gtk_entry_new (); /* Create the completion object */ completion = gtk_entry_completion_new (); gtk_entry_completion_set_inline_completion (completion, TRUE); /* Assign the completion to the entry */ gtk_entry_set_completion (GTK_ENTRY (entry), completion); g_object_unref (completion); add_with_prop_edit_button (vbox, entry, completion); /* Create a tree model and use it as the completion model */ completion_model = create_simple_completion_model (); gtk_entry_completion_set_model (completion, completion_model); g_object_unref (completion_model); /* Use model column 0 as the text column */ gtk_entry_completion_set_text_column (completion, 0); /* Create our second entry */ entry = gtk_entry_new (); /* Create the completion object */ completion = gtk_entry_completion_new (); /* Assign the completion to the entry */ gtk_entry_set_completion (GTK_ENTRY (entry), completion); g_object_unref (completion); add_with_prop_edit_button (vbox, entry, completion); /* Create a tree model and use it as the completion model */ completion_model = create_completion_model (); gtk_entry_completion_set_model (completion, completion_model); gtk_entry_completion_set_minimum_key_length (completion, 2); g_object_unref (completion_model); /* Use model column 1 as the text column */ cell = gtk_cell_renderer_pixbuf_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (completion), cell, FALSE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (completion), cell, "pixbuf", 0, NULL); cell = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (completion), cell, FALSE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (completion), cell, "text", 1, NULL); gtk_entry_completion_set_match_func (completion, match_func, NULL, NULL); g_signal_connect (completion, "match-selected", G_CALLBACK (match_selected_cb), NULL); gtk_entry_completion_insert_action_text (completion, 100, "action!"); gtk_entry_completion_insert_action_text (completion, 101, "'nother action!"); g_signal_connect (completion, "action_activated", G_CALLBACK (activated_cb), NULL); /* Create our third entry */ entry = gtk_entry_new (); /* Create the completion object */ completion = gtk_entry_completion_new (); /* Assign the completion to the entry */ gtk_entry_set_completion (GTK_ENTRY (entry), completion); g_object_unref (completion); add_with_prop_edit_button (vbox, entry, completion); /* Create a tree model and use it as the completion model */ completion_model = GTK_TREE_MODEL (gtk_list_store_new (1, G_TYPE_STRING)); gtk_entry_completion_set_model (completion, completion_model); g_object_unref (completion_model); /* Use model column 0 as the text column */ gtk_entry_completion_set_text_column (completion, 0); /* Fill the completion dynamically */ gdk_threads_add_timeout (1000, (GSourceFunc) animation_timer, completion); /* Fourth entry */ gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new ("Model-less entry completion"), FALSE, FALSE, 0); entry = gtk_entry_new (); /* Create the completion object */ completion = gtk_entry_completion_new (); /* Assign the completion to the entry */ gtk_entry_set_completion (GTK_ENTRY (entry), completion); g_object_unref (completion); add_with_prop_edit_button (vbox, entry, completion); gtk_widget_show_all (window); gtk_main (); return 0; }
/*------------------------------main-----------------------------------*/ int main(int argc, char const *argv[]) { debug("main"); /*command line args*/ if(argc > 1) { if(!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) { printf("%s\n", HELPMSG); return 0; } if(!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version")) { printf("%s\n", VERSION); return 0; } printf("Unknown args [%s], continue to GUI...\n", argv[1]); } /*gtk start*/ gtk_init(NULL, NULL); debug("gtk init"); /*init char*/ mark = malloc(2); word = malloc(MAX_LENGTH); /* init curl */ curl_global_init(CURL_GLOBAL_ALL); debug("curl init"); /*window*/ window = (GtkWidget *)gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_decorated(GTK_WINDOW(window), FALSE); gtk_window_set_icon_name(GTK_WINDOW(window),"accessories-dictionary"); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER_ALWAYS); gtk_window_set_gravity(GTK_WINDOW(window), GDK_GRAVITY_CENTER); g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL); g_signal_connect(window, "key_press_event", G_CALLBACK(checkEsc), NULL); debug("window"); /* entry */ make_entry(); /*button*/ make_button1(); /*assemble*/ vbox1 = gtk_vbox_new(FALSE, 2); /*h**o, pad*/ hbox1 = gtk_hbox_new(FALSE, 2); hboxmain = gtk_hbox_new(FALSE, 5); gtk_widget_set_no_show_all(hboxmain, TRUE); gtk_container_add((GtkContainer *)window, vbox1); gtk_container_add((GtkContainer *)vbox1, hbox1); gtk_container_add((GtkContainer *)vbox1, hboxmain); gtk_container_add((GtkContainer *)hbox1, entry); gtk_container_add((GtkContainer *)hbox1, button1); gtk_box_set_child_packing(GTK_BOX(hbox1), GTK_WIDGET(entry), 1,/*expand*/ 1,/*fill*/ 2,/*pad*/ GTK_PACK_START/*pack type*/ ); gtk_box_set_child_packing(GTK_BOX(vbox1), hbox1, 0, 0, 1, GTK_PACK_START); gtk_box_set_child_packing(GTK_BOX(hbox1), button1, 0, 0, 1, GTK_PACK_START); debug("assemble initial view"); gtk_widget_show_all(window); debug("start the show"); #ifdef MinGW /*volatino*/ volatino = (GtkWidget *) gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_decorated(GTK_WINDOW(volatino), FALSE); gtk_widget_set_size_request(volatino, 450, 24); gtk_window_set_icon_name(GTK_WINDOW(volatino),"accessories-dictionary"); gtk_window_set_position(GTK_WINDOW(volatino), GTK_WIN_POS_CENTER_ALWAYS); gtk_window_set_gravity(GTK_WINDOW(volatino), GDK_GRAVITY_CENTER); gtk_widget_show(volatino); gtk_widget_destroy(volatino); #endif /*auto-completion*/ store = gtk_list_store_new(1, G_TYPE_STRING); model = GTK_TREE_MODEL(store); /*completion model*/ completion = gtk_entry_completion_new(); gtk_entry_completion_set_model(completion, model); gtk_entry_completion_set_text_column(completion, 0); /*completion style*/ gtk_entry_completion_set_inline_completion(completion, TRUE); gtk_entry_completion_set_inline_selection(completion, TRUE); /*commands*/ append_list(store, ":about"); append_list(store, ":help"); /*connect completion*/ gtk_entry_set_completion(GTK_ENTRY(entry), completion); debug("completion"); debug("gtk main entering"); gtk_main(); /*gtk end*/ debug("Sure."); /*clean up*/ if(curl_handle) curl_easy_cleanup(curl_handle); curl_global_cleanup(); free(s); free(rslt); free(mark); free(word); if(searchStr) free(searchStr); return 0; }
/*! \brief Sets up a megatunix comboboxentry widget. Reads the data from the passed ConfigFile *, and sets up the choices as well as the combo model and an entry completion/regex alloing textual based entry. \param object is the pointer to combo widget object \param cfgfile is the pointer to datamap file assocated with this widget \param section is the section within the cfgfile */ G_MODULE_EXPORT void combo_setup(GObject *object, ConfigFile *cfgfile, gchar * section) { gchar *tmpbuf = NULL; gchar ** choices = NULL; gchar ** vector = NULL; gint num_choices = 0; gint num_bitvals = 0; gint i = 0; gchar *tmpstr = NULL; gchar *regex = NULL; const gchar *name = NULL; GtkListStore *store = NULL; GtkTreeIter iter; GtkEntryCompletion *completion = NULL; GtkWidget *entry = NULL; extern gconstpointer *global_data; cfg_read_string(cfgfile,section,"choices",&tmpbuf); choices = parse_keys(tmpbuf,&num_choices,","); tmpbuf = g_strdelimit(tmpbuf,",",'|'); tmpstr = g_utf8_normalize(tmpbuf,-1,G_NORMALIZE_DEFAULT); regex = g_utf8_casefold(tmpbuf,-1); g_free(tmpbuf); g_free(tmpstr); if (!cfg_read_string(cfgfile,section,"bitvals",&tmpbuf)) { MTXDBG(CRITICAL,_("\"bitvals\" key is MISSING, critical fault, not setting up control \n")); return; } vector = parse_keys(tmpbuf,&num_bitvals,","); g_free(tmpbuf); if (num_bitvals != num_choices) { name = glade_get_widget_name(GTK_WIDGET(object)); MTXDBG(CRITICAL,_("\"bitvals\" BIG PROBLEM, combobox %s choices %i and bits %i don't match up\n"),(name == NULL ? "undefined" : name),num_choices,num_bitvals); return; } store = gtk_list_store_new(COMBO_COLS,G_TYPE_STRING,G_TYPE_UCHAR); for (i=0;i<num_choices;i++) { gtk_list_store_append(store,&iter); assert(choices[i]); assert(vector[i]); gtk_list_store_set(store,&iter,CHOICE_COL,choices[i],BITVAL_COL,(guchar)g_ascii_strtoull(vector[i],NULL,10),-1); } OBJ_SET_FULL(object,"model",store,gtk_list_store_clear); g_strfreev(vector); g_strfreev(choices); gtk_combo_box_set_model(GTK_COMBO_BOX(object),GTK_TREE_MODEL(store)); if (GTK_IS_COMBO_BOX_ENTRY(object)) { gint width = 0; gtk_combo_box_entry_set_text_column(GTK_COMBO_BOX_ENTRY(object),CHOICE_COL); entry = mask_entry_new_with_mask(regex); /* Nasty hack, but otherwise the entry is an obnoxious size.. */ if ((width = (GINT)OBJ_GET((GtkWidget *)object,"max_chars")) > 0) gtk_entry_set_width_chars(GTK_ENTRY(entry),width); else gtk_entry_set_width_chars(GTK_ENTRY(entry),12); gtk_widget_set_size_request(GTK_WIDGET(object),-1,(3*(GINT)DATA_GET(global_data,"font_size"))); gtk_container_remove (GTK_CONTAINER (object), gtk_bin_get_child(GTK_BIN (object))); gtk_container_add (GTK_CONTAINER (object), entry); completion = gtk_entry_completion_new(); OBJ_SET_FULL(object,"completion",completion,g_object_unref); gtk_entry_set_completion(GTK_ENTRY(entry),completion); gtk_entry_completion_set_model(completion,GTK_TREE_MODEL(store)); gtk_entry_completion_set_text_column(completion,CHOICE_COL); gtk_entry_completion_set_inline_completion(completion,TRUE); gtk_entry_completion_set_inline_selection(completion,TRUE); gtk_entry_completion_set_popup_single_match(completion,FALSE); OBJ_SET(object,"arrow-size",GINT_TO_POINTER(1)); } g_free(regex); }
void gui_init (dt_lib_module_t *self) { dt_lib_styles_t *d = (dt_lib_styles_t *)malloc (sizeof (dt_lib_styles_t)); self->data = (void *)d; d->edit_button = NULL; self->widget = gtk_vbox_new (FALSE, 5); GtkWidget *w; /* list */ d->list = GTK_TREE_VIEW (gtk_tree_view_new ()); gtk_tree_view_set_headers_visible(d->list,FALSE); GtkListStore *liststore = gtk_list_store_new (DT_STYLES_NUM_COLS, G_TYPE_STRING, G_TYPE_STRING); GtkTreeViewColumn *col = gtk_tree_view_column_new (); gtk_tree_view_append_column (GTK_TREE_VIEW (d->list), col); GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (col, renderer, TRUE); gtk_tree_view_column_add_attribute (col, renderer, "text", DT_STYLES_COL_NAME); int ht = get_font_height( GTK_WIDGET (d->list), "Dreggn"); gtk_widget_set_size_request (GTK_WIDGET (d->list), -1, 5*ht); gtk_tree_selection_set_mode (gtk_tree_view_get_selection(GTK_TREE_VIEW(d->list)), GTK_SELECTION_SINGLE); gtk_tree_view_set_model (GTK_TREE_VIEW(d->list), GTK_TREE_MODEL(liststore)); g_object_unref (liststore); g_object_set(G_OBJECT(d->list), "tooltip-text", _("available styles,\ndoubleclick to apply"), (char *)NULL); g_signal_connect (d->list, "row-activated", G_CALLBACK(_styles_row_activated_callback), d); /* filter entry */ w = gtk_entry_new(); d->entry=GTK_ENTRY(w); g_object_set(G_OBJECT(w), "tooltip-text", _("enter style name"), (char *)NULL); g_signal_connect (d->entry, "changed", G_CALLBACK(entry_callback),d); g_signal_connect (d->entry, "activate", G_CALLBACK(entry_activated),d); dt_gui_key_accel_block_on_focus ( GTK_WIDGET (d->entry)); gtk_box_pack_start(GTK_BOX (self->widget),GTK_WIDGET (d->entry),TRUE,FALSE,0); gtk_box_pack_start(GTK_BOX (self->widget),GTK_WIDGET (d->list),TRUE,FALSE,0); GtkWidget *hbox=gtk_hbox_new (FALSE,5); GtkWidget *widget; d->duplicate = gtk_check_button_new_with_label(_("create duplicate")); gtk_box_pack_start(GTK_BOX (self->widget),GTK_WIDGET (d->duplicate),TRUE,FALSE,0); g_signal_connect (d->duplicate, "toggled", G_CALLBACK(duplicate_callback),d); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (d->duplicate), dt_conf_get_bool("ui_last/styles_create_duplicate")); g_object_set (d->duplicate, "tooltip-text", _("creates a duplicate of the image before applying style"), (char *)NULL); #if 0 // TODO: Unfinished stuff GtkWidget *widget=gtk_button_new_with_label(_("edit")); d->edit_button = widget; also add to the init function g_signal_connect (widget, "clicked", G_CALLBACK(edit_clicked),d); gtk_box_pack_start(GTK_BOX (hbox),widget,TRUE,TRUE,0); #endif widget=gtk_button_new_with_label(_("delete")); d->delete_button = widget; g_signal_connect (widget, "clicked", G_CALLBACK(delete_clicked),d); g_object_set (widget, "tooltip-text", _("deletes the selected style in list above"), (char *)NULL); gtk_box_pack_start(GTK_BOX (hbox),widget,TRUE,TRUE,0); gtk_box_pack_start(GTK_BOX (self->widget),hbox,TRUE,FALSE,0); // Export Button GtkWidget *exportButton = gtk_button_new_with_label(_("export")); d->export_button = exportButton; g_object_set (exportButton, "tooltip-text", _("export the selected style into a style file"), (char *)NULL); g_signal_connect (exportButton, "clicked", G_CALLBACK(export_clicked),d); gtk_box_pack_start(GTK_BOX (hbox),exportButton,TRUE,TRUE,0); // Import Button GtkWidget *importButton = gtk_button_new_with_label(C_("styles", "import")); d->import_button = importButton; g_object_set (importButton, "tooltip-text", _("import style from a style file"), (char *)NULL); g_signal_connect (importButton, "clicked", G_CALLBACK(import_clicked),d); gtk_box_pack_start(GTK_BOX (hbox),importButton,TRUE,TRUE,0); // add entry completion GtkEntryCompletion *completion = gtk_entry_completion_new(); gtk_entry_completion_set_model(completion, gtk_tree_view_get_model(GTK_TREE_VIEW(d->list))); gtk_entry_completion_set_text_column(completion, 0); gtk_entry_completion_set_inline_completion(completion, TRUE); gtk_entry_set_completion(d->entry, completion); /* update filtered list */ _gui_styles_update_view(d); }
/* A browser window was added */ static void _interface_tweaks_on_add_browser(InterfaceTweaks *self, MidoriBrowser *inBrowser, gpointer inUserData) { g_return_if_fail(IS_INTERFACE_TWEAKS(self)); g_return_if_fail(MIDORI_IS_BROWSER(inBrowser)); InterfaceTweaksPrivate *priv=self->priv; GtkNotebook *notebook; GList *tabs, *iter; InterfaceTweaksLocationbarLookup locationbar; GtkEntryCompletion *completion; guint keyPressSignalID; gulong hookID; /* Set up all current available tabs in browser */ tabs=midori_browser_get_tabs(inBrowser); for(iter=tabs; iter; iter=g_list_next(iter)) { _interface_tweaks_on_add_tab(self, iter->data, inBrowser); } g_list_free(tabs); /* Listen to new tabs opened in browser */ g_signal_connect_swapped(inBrowser, "add-tab", G_CALLBACK(_interface_tweaks_on_add_tab), self); notebook=NULL; g_object_get(inBrowser, "notebook", ¬ebook, NULL); if(notebook) { g_signal_connect_swapped(notebook, "page-added", G_CALLBACK(_interface_tweaks_on_tab_reordered), self); g_signal_connect_swapped(notebook, "page-reordered", G_CALLBACK(_interface_tweaks_on_tab_reordered), self); g_object_unref(notebook); } /* Listen to locationbar signals */ _interface_tweaks_find_browser_locationbar(inBrowser, &locationbar); if(locationbar.widget) { /* Add completion to location entry and setup signals */ completion=gtk_entry_completion_new(); gtk_entry_completion_set_inline_completion(completion, TRUE); gtk_entry_completion_set_inline_selection(completion, FALSE); gtk_entry_completion_set_popup_completion(completion, FALSE); gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(priv->completionModel)); gtk_entry_completion_set_text_column(completion, 0); gtk_entry_set_completion(GTK_ENTRY(locationbar.widget), completion); g_signal_connect_swapped(completion, "insert-prefix", G_CALLBACK(_interface_tweaks_on_insert_prefix), self); g_object_unref(completion); /* Add emission handler to entry if it does not exist to ensure that * our "key-press-event" handler gets called first */ hookID=GPOINTER_TO_SIZE(g_object_get_data(G_OBJECT(locationbar.widget), "interface-tweaks-hook-id")); if(hookID==0) { keyPressSignalID=g_signal_lookup("key-press-event", GTK_TYPE_ENTRY); hookID=g_signal_add_emission_hook(keyPressSignalID, 0, _interface_tweaks_on_key_press_event, locationbar.widget, NULL); g_object_set_data(G_OBJECT(locationbar.widget), "interface-tweaks-hook-id", GSIZE_TO_POINTER(hookID)) ; } /* Add signal to recognize widget destruction to release emission hook */ g_signal_connect_swapped(locationbar.widget, "destroy", G_CALLBACK(_interface_tweaks_on_destroyed), self); } }