/** Creates a gconf widget. */ _camera_gconf_widget_t *_camera_import_gconf_widget(_camera_import_dialog_t *dlg,gchar *label,gchar *confstring) { _camera_gconf_widget_t *gcw=malloc(sizeof(_camera_gconf_widget_t)); memset(gcw,0,sizeof(_camera_gconf_widget_t)); GtkWidget *vbox,*hbox; gcw->widget=vbox=GTK_WIDGET(gtk_vbox_new(FALSE,0)); hbox=GTK_WIDGET(gtk_hbox_new(FALSE,0)); g_object_set_data(G_OBJECT(vbox),"gconf:string",confstring); gcw->dialog=dlg; gcw->entry=gtk_entry_new(); char* value = dt_conf_get_string(confstring); if(value) { gtk_entry_set_text( GTK_ENTRY( gcw->entry ), value); if(gcw->value) g_free(gcw->value); gcw->value = value; } gtk_box_pack_start(GTK_BOX(hbox),GTK_WIDGET(gcw->entry),TRUE,TRUE,0); GtkWidget *button=dtgtk_button_new(dtgtk_cairo_paint_store,CPF_STYLE_FLAT|CPF_DO_NOT_USE_BORDER); g_object_set(button,"tooltip-text",_("store value as default"),(char *)NULL); gtk_widget_set_size_request(button,13,13); gtk_box_pack_start(GTK_BOX(hbox),button,FALSE,FALSE,0); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (_gcw_store_callback), gcw); button=dtgtk_button_new(dtgtk_cairo_paint_reset,CPF_STYLE_FLAT|CPF_DO_NOT_USE_BORDER); g_object_set(button,"tooltip-text",_("reset value to default"),(char *)NULL); gtk_widget_set_size_request(button,13,13); gtk_box_pack_start(GTK_BOX(hbox),button,FALSE,FALSE,0); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (_gcw_reset_callback), gcw); GtkWidget *l=gtk_label_new(label); gtk_misc_set_alignment(GTK_MISC(l), 0.0, 0.0); gtk_box_pack_start(GTK_BOX(vbox),l,FALSE,FALSE,0); gtk_box_pack_start(GTK_BOX(vbox),GTK_WIDGET(hbox),FALSE,FALSE,0); g_signal_connect (G_OBJECT(gtk_entry_get_buffer(GTK_ENTRY(gcw->entry))), "inserted-text", G_CALLBACK (entry_it_callback), gcw); g_signal_connect (G_OBJECT(gtk_entry_get_buffer(GTK_ENTRY(gcw->entry))), "deleted-text", G_CALLBACK (entry_dt_callback), gcw); return gcw; }
void access_token_ok_button_clicked(GtkButton *button, gpointer userdata) { GtkEntry *entry = GTK_ENTRY(userdata); GtkEntryBuffer *buffer = gtk_entry_get_buffer(entry); strncpy(accesstoken, gtk_entry_buffer_get_text(buffer), strlen(gtk_entry_buffer_get_text(buffer))); }
void comma_clicked(GtkButton*w, GtkEntry *entry){ GtkEntryBuffer *buffer = gtk_entry_get_buffer(entry); gtk_entry_buffer_insert_text (buffer, -1,",", 1); gtk_entry_set_buffer(entry, buffer); }
/***************************************************** *主页面 设置过滤规则 *****************************************************/ void on_main_filter_entry_activate(GtkWidget * gw, gpointer data) { GtkEntry *filter_entry; filter_entry = GTK_ENTRY(gtk_builder_get_object(builder, "main_filter_entry")); gtk_entry_buffer_set_text(gtk_entry_get_buffer(filter_entry), "", 0); }
int _gui_sns_people_dialog(void *self) { /* * create a people create/edit dialog, do some input check, then apply create/edit to param `self` * * */ People **people=(People**)self; int rws=1; char title[100]; char argi[rws*2+1][100]; if(people == NULL) { strcpy(title, "新建用户"); strcpy(argi[rws+1], ""); } else { strcpy(title, "编辑用户"); strcpy(argi[rws+1], (*people)->name); } strcpy(argi[0], title); strcpy(argi[1], "用户名"); GtkWidget **dialog_result = (GtkWidget **)malloc(sizeof(GtkWidget *)*(rws*2+2)); dialog_result = gui_create_edit_dialog(window, rws, argi, dialog_result); gtk_widget_show_all(dialog_result[0]); char validate_message[100]; validate_message[0] = '\0'; int result; GtkEntryBuffer *buffer; char name[100]; while(gtk_dialog_run(GTK_DIALOG(dialog_result[0])) == GTK_RESPONSE_ACCEPT) { validate_message[0] = '\0'; buffer = gtk_entry_get_buffer(GTK_ENTRY(dialog_result[2*1+1])); if(gtk_entry_buffer_get_length(buffer) >= 100) { strcpy(validate_message, "用户名过长"); } else { strcpy(name, gtk_entry_buffer_get_text(buffer)); } if(validate_message[0] != '\0') { gui_show_message(validate_message, GTK_MESSAGE_WARNING); continue; } if(people == NULL) { People *_people_tmp=NULL; people = &_people_tmp; result = people_init(SNS, people, name, 0, 0); } else { strcpy((*people)->name, name); result = PEOPLE_OP_SUCCESS; } break; } gtk_widget_destroy(GTK_WIDGET(dialog_result[0])); free(dialog_result); return result; }
static void screen_sharing_password_insert_text_cb (GtkEditable *editable, gchar *new_text, gint new_text_length, gpointer position, gpointer user_data) { int l, available_size; l = gtk_entry_buffer_get_bytes (gtk_entry_get_buffer (GTK_ENTRY (editable))); if (l + new_text_length <= MAX_PASSWORD_SIZE) return; g_signal_stop_emission_by_name (editable, "insert-text"); gtk_widget_error_bell (GTK_WIDGET (editable)); available_size = g_utf8_strlen (new_text, MAX_PASSWORD_SIZE - l); if (available_size == 0) return; g_signal_handlers_block_by_func (editable, (gpointer) screen_sharing_password_insert_text_cb, user_data); gtk_editable_insert_text (editable, new_text, available_size, position); g_signal_handlers_unblock_by_func (editable, (gpointer) screen_sharing_password_insert_text_cb, user_data); }
/** Creates a gconf widget. */ static _camera_gconf_widget_t *_camera_import_gconf_widget(_camera_import_dialog_t *dlg, gchar *label, gchar *confstring) { _camera_gconf_widget_t *gcw = calloc(1, sizeof(_camera_gconf_widget_t)); GtkWidget *vbox, *hbox; gcw->widget = vbox = GTK_WIDGET(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0)); hbox = GTK_WIDGET(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0)); g_object_set_data(G_OBJECT(vbox), "gconf:string", confstring); gcw->dialog = dlg; gcw->entry = gtk_entry_new(); char *value = dt_conf_get_string(confstring); if(value) { gtk_entry_set_text(GTK_ENTRY(gcw->entry), value); g_free(gcw->value); gcw->value = value; } gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(gcw->entry), TRUE, TRUE, 0); GtkWidget *button = dtgtk_button_new(dtgtk_cairo_paint_store, CPF_STYLE_FLAT | CPF_DO_NOT_USE_BORDER); gtk_widget_set_tooltip_text(button, _("store value as default")); gtk_widget_set_size_request(button, DT_PIXEL_APPLY_DPI(13), DT_PIXEL_APPLY_DPI(13)); gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(_gcw_store_callback), gcw); button = dtgtk_button_new(dtgtk_cairo_paint_reset, CPF_STYLE_FLAT | CPF_DO_NOT_USE_BORDER); gtk_widget_set_tooltip_text(button, _("reset value to default")); gtk_widget_set_size_request(button, DT_PIXEL_APPLY_DPI(13), DT_PIXEL_APPLY_DPI(13)); gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(_gcw_reset_callback), gcw); GtkWidget *l = gtk_label_new(label); gtk_widget_set_halign(l, GTK_ALIGN_START); gtk_box_pack_start(GTK_BOX(vbox), l, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(hbox), FALSE, FALSE, 0); g_signal_connect(G_OBJECT(gtk_entry_get_buffer(GTK_ENTRY(gcw->entry))), "inserted-text", G_CALLBACK(entry_it_callback), gcw); g_signal_connect(G_OBJECT(gtk_entry_get_buffer(GTK_ENTRY(gcw->entry))), "deleted-text", G_CALLBACK(entry_dt_callback), gcw); return gcw; }
int _gui_sns_tag_dialog(void *self) { Tag **tag = (Tag **) self; int rws = 1; char title[100]; char argi[rws * 2 + 1][100]; if (tag == NULL) { strcpy(title, "新建爱好"); strcpy(argi[rws + 1], ""); } else { strcpy(title, "编辑爱好"); strcpy(argi[rws + 1], (*tag)->name); } strcpy(argi[0], title); strcpy(argi[1], "爱好名"); GtkWidget **dialog_result = (GtkWidget **) malloc(sizeof(GtkWidget *) * (rws * 2 + 2)); dialog_result = gui_create_edit_dialog(window, rws, argi, dialog_result); gtk_widget_show_all(dialog_result[0]); char validate_message[100]; validate_message[0] = '\0'; int result; GtkEntryBuffer *buffer; char name[100]; while (gtk_dialog_run(GTK_DIALOG(dialog_result[0])) == GTK_RESPONSE_ACCEPT) { validate_message[0] = '\0'; buffer = gtk_entry_get_buffer(GTK_ENTRY(dialog_result[2 * 1 + 1])); if (gtk_entry_buffer_get_length(buffer) >= 100) { strcpy(validate_message, "爱好名过长"); } else { strcpy(name, gtk_entry_buffer_get_text(buffer)); } if (validate_message[0] != '\0') { gui_show_message(validate_message, GTK_MESSAGE_WARNING); continue; } if (tag == NULL) { Tag *_tag_tmp = NULL; tag = &_tag_tmp; result = tag_init(SNS, tag, name, 0, 0); } else { strcpy((*tag)->name, name); result = PEOPLE_OP_SUCCESS; } break; } gtk_widget_destroy(GTK_WIDGET(dialog_result[0])); free(dialog_result); return result; }
static int Gtk3Gui_WLineEdit_Setup(GWEN_WIDGET *w) { GtkWidget *g; const char *s; uint32_t flags; GWEN_WIDGET *wParent; gulong deleted_text_handler_id; gulong inserted_text_handler_id; gboolean text_is_visible; flags=GWEN_Widget_GetFlags(w); text_is_visible = (flags & GWEN_WIDGET_FLAGS_PASSWORD) == 0; wParent=GWEN_Widget_Tree_GetParent(w); s=GWEN_Widget_GetText(w, 0); /* create widget */ g=gtk_entry_new(); if (s && *s) gtk_entry_set_text(GTK_ENTRY(g), s); gtk_entry_set_visibility(GTK_ENTRY(g), text_is_visible); GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_REAL, (void*) g); GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_CONTENT, (void*) g); GWEN_Widget_SetSetIntPropertyFn(w, Gtk3Gui_WLineEdit_SetIntProperty); GWEN_Widget_SetGetIntPropertyFn(w, Gtk3Gui_WLineEdit_GetIntProperty); GWEN_Widget_SetSetCharPropertyFn(w, Gtk3Gui_WLineEdit_SetCharProperty); GWEN_Widget_SetGetCharPropertyFn(w, Gtk3Gui_WLineEdit_GetCharProperty); deleted_text_handler_id=g_signal_connect(gtk_entry_get_buffer(GTK_ENTRY(g)), "deleted-text", G_CALLBACK (Gtk3Gui_WLineEdit_Deleted_text_handler), w); inserted_text_handler_id=g_signal_connect(gtk_entry_get_buffer(GTK_ENTRY(g)), "inserted-text", G_CALLBACK (Gtk3Gui_WLineEdit_Inserted_text_handler), w); if (wParent) GWEN_Widget_AddChildGuiWidget(wParent, w); return 0; }
void num6_clicked(GtkButton*w, GtkEntry *entry){ if(sign){ gtk_entry_set_text(entry, ""); } GtkEntryBuffer *buffer = gtk_entry_get_buffer(entry); gtk_entry_buffer_insert_text (buffer, -1,"6", 1); gtk_entry_set_buffer(entry, buffer); sign = 0; }
/* Get entry box text */ static void get_entry_text(struct elyapp *app, char **str) { GtkEntryBuffer *buf = gtk_entry_get_buffer(GTK_ENTRY(app->gui.widg)); const gchar *text = gtk_entry_buffer_get_text(buf); printf("~%s~\n", text); buf = gtk_entry_buffer_new(0, -1); gtk_entry_buffer_set_max_length(buf, app->text.maxchars); gtk_entry_set_buffer(GTK_ENTRY(app->gui.widg), buf); gtk_widget_destroy(app->gui.widg); *str = (char*)text; }
void post_blog_ok_button_clicked(GtkButton *button, gpointer userdata) { GtkEntry *title_entry, *password_entry; GtkTextView *text_view; GtkEntryBuffer *title_buffer, *password_buffer; GtkTextBuffer *context_buffer; GtkTextIter start, end; GtkComboBoxText *permission; GList *list = (GList*)userdata; const gchar *title_string; const gchar *password; gchar *content_string, *blog_permission; title_entry = (GtkEntry*)list->data; list = list->next; text_view = (GtkTextView*)list->data; title_buffer = gtk_entry_get_buffer(title_entry); title_string = gtk_entry_buffer_get_text(title_buffer); context_buffer = gtk_text_view_get_buffer(text_view); gtk_text_buffer_get_start_iter(context_buffer, &start); gtk_text_buffer_get_end_iter(context_buffer, &end); content_string = gtk_text_buffer_get_text(context_buffer, &start, &end, TRUE); puts(title_string); puts("\n\n\n"); puts(content_string); puts(accesstoken); list = list->next; permission = (GtkComboBoxText*)list->data; list = list->next; password_entry = (GtkEntry*)list->data; blog_permission = gtk_combo_box_text_get_active_text(permission); password_buffer = gtk_entry_get_buffer(password_entry); password = gtk_entry_buffer_get_text(password_buffer); g_print("password is %s\n", password); g_print("permission is %s\n", blog_permission); xiaonei_gtk_create_one_blog(accesstoken, blog_permission, title_string, content_string, password); }
GtkWidget* PythonCompletionFramework::create_config_widget(GtkDialog* dialog) { g_debug("code complete: plugin_configure"); JediCompletePluginPref* pref = JediCompletePluginPref::instance(); GError* err = NULL; GtkBuilder* builder = gtk_builder_new(); // here defines prefpy_ui, prefpy_ui_len #include "data/prefpy_ui.hpp" gint ret = gtk_builder_add_from_string(builder, (gchar*)prefpy_ui, prefpy_ui_len, &err); if (err) { printf("fail to load preference ui: %s\n", err->message); GtkWidget* vbox = gtk_vbox_new(FALSE, 5); return vbox; } // suggestion window pref_widgets.row_text_max_spinbtn = GETOBJ("spin_rowtextmax"); gtk_spin_button_set_value(GTK_SPIN_BUTTON(pref_widgets.row_text_max_spinbtn), pref->row_text_max); pref_widgets.swin_height_max_spinbtn = GETOBJ("spin_sugwinheight"); gtk_spin_button_set_value(GTK_SPIN_BUTTON(pref_widgets.swin_height_max_spinbtn), pref->suggestion_window_height_max); pref_widgets.page_up_down_skip_amount_spinbtn = GETOBJ("spin_pageupdownskipamount"); gtk_spin_button_set_value(GTK_SPIN_BUTTON(pref_widgets.page_up_down_skip_amount_spinbtn), pref->page_up_down_skip_amount); // python pref_widgets.start_with_dot = GETOBJ("cbtn_dot"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pref_widgets.start_with_dot), pref->start_completion_with_dot); GtkWidget* pypath_entry = GETOBJ("te_pypath"); pref_widgets.pypath_buffer = gtk_entry_get_buffer(GTK_ENTRY(pypath_entry)); gtk_entry_set_text(GTK_ENTRY(pypath_entry), pref->python_path.c_str()); GtkWidget* file_choose_button = GETOBJ("btn_filesel"); g_signal_connect(file_choose_button, "clicked", G_CALLBACK(on_click_file_choose_button), NULL); pref_widgets.port_spinbtn = GETOBJ("spin_port"); gtk_spin_button_set_value(GTK_SPIN_BUTTON(pref_widgets.port_spinbtn), pref->jedi_server_port); GtkWidget* reinstall_button = GETOBJ("btn_reinstall"); g_signal_connect(reinstall_button, "clicked", G_CALLBACK(on_click_exec_button), NULL); g_signal_connect(dialog, "response", G_CALLBACK(on_configure_response), this); GtkWidget* vbox = GETOBJ("box_prefpy"); return vbox; }
static void gtkhash_properties_on_button_hash_clicked(struct page_s *page) { gtkhash_properties_busy(page); gtkhash_properties_list_clear_digests(page); if (gtk_toggle_button_get_active(page->togglebutton_hmac)) { const uint8_t *hmac_key = (uint8_t *)gtk_entry_get_text( page->entry_hmac); GtkEntryBuffer *buffer = gtk_entry_get_buffer(page->entry_hmac); const size_t key_size = gtk_entry_buffer_get_bytes(buffer); gtkhash_properties_hash_start(page, hmac_key, key_size); } else gtkhash_properties_hash_start(page, NULL, 0); }
int _gui_sns_get_tag_by_id_dialog(char *messages, Tag **result_tag) { /* * create a dialog to get tag by input id * * */ int rws=1; char title[100]; char argi[rws*2+1][100]; strcpy(title, messages); strcpy(argi[0], title); strcpy(argi[1], "爱好ID"); strcpy(argi[rws+1], ""); GtkWidget **dialog_result = (GtkWidget **)malloc(sizeof(GtkWidget *)*(rws*2+2)); dialog_result = gui_create_edit_dialog(window, rws, argi, dialog_result); gtk_widget_show_all(dialog_result[0]); char validate_message[100]; validate_message[0] = '\0'; int result; GtkEntryBuffer *buffer; char id_string[10]; int id; while(gtk_dialog_run(GTK_DIALOG(dialog_result[0])) == GTK_RESPONSE_ACCEPT) { validate_message[0] = '\0'; buffer = gtk_entry_get_buffer(GTK_ENTRY(dialog_result[2*1+1])); if(gtk_entry_buffer_get_length(buffer) >= 10) { strcpy(validate_message, "爱好ID过长"); } else { strcpy(id_string, gtk_entry_buffer_get_text(buffer)); id = atoi(id_string); } if(validate_message[0] != '\0') { gui_show_message(validate_message, GTK_MESSAGE_WARNING); continue; } result = sns_search_tag(SNS, id, result_tag); break; } gtk_widget_destroy(GTK_WIDGET(dialog_result[0])); free(dialog_result); return result; }
int main (int argc, char *argv[]) { /*FIXME Clean this main */ GtkWidget *window, *entry, *grid, *frame, *combo1, *combo2, *combo3; gtk_init(&argc, &argv); /* Creates main window */ window = gtk_window_new(GTK_WINDOW_TOPLEVEL); initialize_window(window); /* Creates a grid */ grid = gtk_grid_new (); gtk_container_add(GTK_CONTAINER(window), grid); /* Creates a text entry and attaches to grid */ entry = new_entry_with_buffer(NULL, 0); GtkEntryBuffer *buffer = gtk_entry_get_buffer((GtkEntry *)entry); gtk_grid_attach(GTK_GRID(grid), entry, 0, 0, 3, 1); /*FIXME Regulate paramaters via xml */ /* Creates favorite bands' combo and attaches to grid */ combo1 = new_combo_box_with_text("Velvet Underground", "Joy Division", "My Bloody Valentine"); g_signal_connect( G_OBJECT(combo1), "changed", G_CALLBACK( cb_changed ), GTK_ENTRY_BUFFER(buffer)); frame = gtk_frame_new("Favorite Bands"); gtk_container_add(GTK_CONTAINER(frame), combo1); gtk_grid_attach(GTK_GRID(grid), frame, 0, 1, 1, 1); /* Creates favorite foods' combo and attaches to grid */ combo2 = new_combo_box_with_text("Mexican", "Japanese", "Italian"); g_signal_connect( G_OBJECT(combo2), "changed", G_CALLBACK( cb_changed ), GTK_ENTRY_BUFFER(buffer)); frame = gtk_frame_new("Favorite Foods"); gtk_container_add(GTK_CONTAINER(frame), combo2); gtk_grid_attach(GTK_GRID(grid), frame, 1, 1, 1, 1); /* Creates favorite movies' combo and attaches to grid */ combo3 = new_combo_box_with_text("Dekalog", "Acossado", "Magnolia"); g_signal_connect( G_OBJECT(combo3), "changed", G_CALLBACK( cb_changed ), GTK_ENTRY_BUFFER(buffer)); frame = gtk_frame_new("Favorite Movies"); gtk_container_add(GTK_CONTAINER(frame), combo3); gtk_grid_attach(GTK_GRID(grid), frame, 2, 1, 1, 1); /* Shows all widgets recursively */ gtk_widget_show_all(window); gtk_main(); return 0; }
void wx_gtk_insert_text_callback(GtkEditable *editable, const gchar * new_text, gint WXUNUSED(new_text_length), gint * WXUNUSED(position), wxTextEntry *text) { GtkEntry *entry = GTK_ENTRY (editable); #if GTK_CHECK_VERSION(3,0,0) || defined(GSEAL_ENABLE) const int text_max_length = gtk_entry_buffer_get_max_length(gtk_entry_get_buffer(entry)); #else const int text_max_length = entry->text_max_length; #endif bool handled = false; // check that we don't overflow the max length limit if we have it if ( text_max_length ) { const int text_length = gtk_entry_get_text_length(entry); // We can't use new_text_length as it is in bytes while we want to count // characters (in first approximation, anyhow...). if ( text_length + g_utf8_strlen(new_text, -1) > text_max_length ) { // Prevent the new text from being inserted. handled = true; // Currently we don't insert anything at all, but it would be better to // insert as many characters as would fit into the text control and // only discard the rest. // Notify the user code about overflow. text->SendMaxLenEvent(); } } if ( !handled && text->GTKEntryOnInsertText(new_text) ) { // If we already handled the new text insertion, don't do it again. handled = true; } if ( handled ) g_signal_stop_emission_by_name (editable, "insert_text"); }
static void text_inserted (GtkEditable *editable, gchar *new_text, gint new_text_length, gint *position, gpointer user_data) { GtkEntryBuffer *buffer; gchar* new_label; gint i; gint current_length, max_length; gboolean valid; valid = TRUE; buffer = gtk_entry_get_buffer (GTK_ENTRY (editable)); current_length = gtk_entry_buffer_get_length (buffer); max_length = gtk_entry_get_max_length (GTK_ENTRY (editable)); /* honor max length property */ if (current_length + new_text_length > max_length) return; /* stop the default implementation */ g_signal_stop_emission (editable, g_signal_lookup ("insert-text", GTK_TYPE_ENTRY), 0); for (i = 0; i < new_text_length; i++) { gchar c; c = *(new_text + i); /* trying to insert a non-numeric char */ if (c < '0' || c > '9') { valid = FALSE; break; } } if (!valid) return; new_label = g_strdup_printf ("%s%s", gtk_entry_buffer_get_text (buffer), new_text); gtk_entry_buffer_set_text (buffer, new_label, current_length + new_text_length); *position = *position + new_text_length; g_free (new_label); }
static void port_icons_callback(GtkEntry *entry,GtkEntryIconPosition icon_pos,GdkEvent *event,gpointer data) { FacqPlugDialog *dialog = FACQ_PLUG_DIALOG(data); GtkEntryBuffer *buf = NULL; switch(icon_pos){ case GTK_ENTRY_ICON_PRIMARY: buf = gtk_entry_get_buffer(entry); gtk_entry_buffer_delete_text(buf,0,-1); break; case GTK_ENTRY_ICON_SECONDARY: gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->priv->spin_button),dialog->priv->port); break; default: return; } }
static void ide_editor_frame__search_populate_popup (IdeEditorFrame *self, GtkWidget *popup, GdTaggedEntry *entry) { g_assert (IDE_IS_EDITOR_FRAME (self)); g_assert (GTK_IS_WIDGET (popup)); g_assert (GD_IS_TAGGED_ENTRY (entry)); if (GTK_IS_MENU_SHELL (popup)) { GMenu *menu; GActionGroup *group; GAction *action; GtkEntryBuffer *buffer; GtkClipboard *clipboard; gboolean clipboard_contains_text; gboolean entry_has_selection; group = gtk_widget_get_action_group (GTK_WIDGET (self->search_frame), "search-entry"); menu = ide_application_get_menu_by_id (IDE_APPLICATION_DEFAULT, "ide-editor-frame-search-menu"); gtk_menu_shell_bind_model (GTK_MENU_SHELL (popup), G_MENU_MODEL (menu), NULL, TRUE); clipboard = gtk_widget_get_clipboard (GTK_WIDGET (entry), GDK_SELECTION_CLIPBOARD); clipboard_contains_text = gtk_clipboard_wait_is_text_available (clipboard); action = g_action_map_lookup_action (G_ACTION_MAP (group), "paste-clipboard"); g_simple_action_set_enabled (G_SIMPLE_ACTION (action), clipboard_contains_text); entry_has_selection = gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), NULL, NULL); action = g_action_map_lookup_action (G_ACTION_MAP (group), "cut-clipboard"); g_simple_action_set_enabled (G_SIMPLE_ACTION (action), entry_has_selection); action = g_action_map_lookup_action (G_ACTION_MAP (group), "copy-clipboard"); g_simple_action_set_enabled (G_SIMPLE_ACTION (action), entry_has_selection); action = g_action_map_lookup_action (G_ACTION_MAP (group), "delete-selection"); g_simple_action_set_enabled (G_SIMPLE_ACTION (action), entry_has_selection); action = g_action_map_lookup_action (G_ACTION_MAP (group), "select-all"); buffer = gtk_entry_get_buffer (GTK_ENTRY (self->search_entry)); g_simple_action_set_enabled (G_SIMPLE_ACTION (action), gtk_entry_buffer_get_length (buffer) > 0); } }
GtkWidget* ptk_path_entry_new( PtkFileBrowser* file_browser ) { GtkWidget* entry = gtk_entry_new(); gtk_entry_set_has_frame( GTK_ENTRY( entry ), TRUE ); // set font if ( file_browser->mypanel > 0 && file_browser->mypanel < 5 && xset_get_s_panel( file_browser->mypanel, "font_path" ) ) { PangoFontDescription* font_desc = pango_font_description_from_string( xset_get_s_panel( file_browser->mypanel, "font_path" ) ); gtk_widget_modify_font( entry, font_desc ); pango_font_description_free( font_desc ); } EntryData* edata = g_slice_new0( EntryData ); edata->history = NULL; edata->current = NULL; edata->editing = NULL; edata->browser = file_browser; g_signal_connect( entry, "focus-in-event", G_CALLBACK(on_focus_in), NULL ); g_signal_connect( entry, "focus-out-event", G_CALLBACK(on_focus_out), NULL ); /* used to eat the tab key */ g_signal_connect( entry, "key-press-event", G_CALLBACK(on_key_press), edata ); /* g_signal_connect( entry, "motion-notify-event", G_CALLBACK(on_mouse_move), NULL ); */ g_signal_connect( entry, "button-press-event", G_CALLBACK(on_button_press), NULL ); g_signal_connect( entry, "button-release-event", G_CALLBACK(on_button_release), NULL ); g_signal_connect( entry, "populate-popup", G_CALLBACK(on_populate_popup), file_browser ); g_signal_connect_after( G_OBJECT( gtk_entry_get_buffer( GTK_ENTRY( entry ) ) ), "inserted-text", G_CALLBACK( on_entry_insert ), NULL ); g_object_weak_ref( G_OBJECT( entry ), (GWeakNotify) entry_data_free, edata ); g_object_set_data( G_OBJECT( entry ), "edata", edata ); return entry; }
/** * facq_plug_dialog_get_input: * @dialog: A #FacqPlugDialog object. * @port: (allow-none) (out caller-allocates): A pointer to a #guint16 variable. * * Retrieves the user input from the @dialog. The port info is written to the * @port variable if not %NULL and the IP address is returned by the function. * * Returns: The IP address chosen by the user, you must free it with g_free(). */ gchar *facq_plug_dialog_get_input(const FacqPlugDialog *dialog,guint16 *port) { gchar *ret = NULL; GtkEntryBuffer *buf = NULL; if(port) *port = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(dialog->priv->spin_button)); buf = gtk_entry_get_buffer(GTK_ENTRY(dialog->priv->address_entry)); if(gtk_entry_buffer_get_length(buf)){ ret = g_strdup(gtk_entry_buffer_get_text(buf)); if(g_strcmp0(ret,"all") == 0){ g_free(ret); ret = NULL; } } else ret = NULL; return ret; }
void on_main_set_filter_button_clicked(GtkWidget * gw, gpointer data) { GtkEntry *filter_entry; gchar *filter_rule; filter_entry = GTK_ENTRY(gtk_builder_get_object(builder, "main_filter_entry")); filter_rule = gtk_entry_buffer_get_text(gtk_entry_get_buffer(filter_entry)); sprintf(bpf_filter_str, "%s", filter_rule); /* * 预编译规则,检测书写是否正确 */ pcap_t *handle; char error_content[PCAP_ERRBUF_SIZE]; int ret; struct bpf_program bpf_filter; bpf_u_int32 net_mask; bpf_u_int32 net_ip; pcap_lookupnet(select_dev, &net_ip, &net_mask, error_content); handle = pcap_open_live("eth0", BUFSIZ, 1, 0, error_content); ret = pcap_compile(handle, &bpf_filter, bpf_filter_str, 0, net_ip); if (-1 == ret) { g_print("%s 不符合规则\n", bpf_filter_str); GtkWidget *dialog; dialog = gtk_message_dialog_new(NULL, GTK_RESPONSE_OK, GTK_MESSAGE_OTHER, GTK_BUTTONS_OK, NULL); gtk_message_dialog_set_markup((GtkMessageDialog *) dialog, "<span foreground=\"red\" size=\"x-large\">:) 过滤规则书写不正确</span>"); gtk_window_set_title(GTK_WINDOW(dialog), "Set Filter rule"); gtk_dialog_run((GtkDialog *) dialog); // show the dialog gtk_widget_destroy(dialog); } }
static void on_search_box_entry_changed (GtkWidget * widget, SearchBox * search_box) { if (!search_box->priv->regex_mode) { GtkEntryBuffer* buffer = gtk_entry_get_buffer (GTK_ENTRY(widget)); if (gtk_entry_buffer_get_length (buffer)) search_box_incremental_search (search_box, TRUE, FALSE, TRUE); else { /* clear selection */ IAnjutaIterable* cursor = ianjuta_editor_get_position (IANJUTA_EDITOR (search_box->priv->current_editor), NULL); ianjuta_editor_selection_set (IANJUTA_EDITOR_SELECTION (search_box->priv->current_editor), cursor, cursor, FALSE, NULL); } } if (search_box->priv->highlight_all) search_box_highlight_all (search_box); }
static int full_save_as(GtkWidget* parent_window, gboolean not_export) { GtkWidget* dialog = 0; GtkWidget* content_area = 0; GtkWidget* alignment = 0; GtkWidget* vbox = 0; GtkWidget* table = 0; GtkTable* t = 0; GtkWidget* name_entry = 0; GtkWidget* folder_button = 0; enum { TABLE_WIDTH = 4, TABLE_HEIGHT = 2 }; int a1 = 0, a2 = 1; int b1 = 1, b2 = TABLE_WIDTH; int y = 0; const char* title = 0; char* folder = 0; if (not_export) title = "Full Save bank as"; else title = "Full Export bank from session as"; dialog = gtk_dialog_new_with_buttons(title, GTK_WINDOW(parent_window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL); content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); alignment = gtk_alignment_new(0, 0, 1, 1); gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), GUI_BORDERSPACE, GUI_BORDERSPACE, GUI_BORDERSPACE, GUI_BORDERSPACE); gtk_container_add(GTK_CONTAINER(content_area), alignment); vbox = gtk_vbox_new(FALSE, GUI_SPACING); gtk_container_add(GTK_CONTAINER(alignment), vbox); table = gtk_table_new(TABLE_HEIGHT, TABLE_WIDTH, TRUE); gui_pack(GTK_BOX(vbox), table); t = GTK_TABLE(table); gtk_table_set_col_spacing(t, 0, GUI_TEXTSPACE); gui_label_attach("Name:", t, a1, a2, y, y + 1); name_entry = gtk_entry_new(); gui_attach(t, name_entry, b1, b2, y, y + 1); if (dish_file_has_state()) gtk_entry_set_text(GTK_ENTRY(name_entry), dish_file_state_bank_name()); else gtk_entry_set_text(GTK_ENTRY(name_entry), untitled_name); g_signal_connect(G_OBJECT(gtk_entry_get_buffer(GTK_ENTRY(name_entry))), "inserted-text", G_CALLBACK(name_buf_txt_ins_cb), NULL); ++y; gui_label_attach("Create Folder in:", t, a1, a2, y, y + 1); folder_button = gtk_file_chooser_button_new("Select folder", GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); gui_attach(t, folder_button, b1, b2, y, y + 1); gtk_widget_show_all(dialog); while(1) { if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { char* uri = 0; const char* name = 0; uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(folder_button)); if (uri && strncmp(uri, "file://", 7) == 0) { folder = strdup(uri + 7); free(uri); } else folder = uri; name = gtk_entry_get_text(GTK_ENTRY(name_entry)); debug("folder:'%s'\tname (name_entry):'%s'\n", folder,name); if (folder && name) { dish_file_write_full(folder, name); if (recent_manager) gtk_recent_manager_add_item(recent_manager, g_filename_to_uri(dish_file_state_path(), NULL, NULL)); break; } } else break; } gtk_widget_destroy(dialog); return 0; }
void wx_gtk_insert_text_callback(GtkEditable *editable, const gchar * new_text, gint new_text_length, gint * position, wxTextEntry *text) { GtkEntry *entry = GTK_ENTRY (editable); #if GTK_CHECK_VERSION(3,0,0) || defined(GSEAL_ENABLE) const int text_max_length = gtk_entry_buffer_get_max_length(gtk_entry_get_buffer(entry)); #else const int text_max_length = entry->text_max_length; #endif bool handled = false; // check that we don't overflow the max length limit if we have it if ( text_max_length ) { const int text_length = gtk_entry_get_text_length(entry); // We can't use new_text_length as it is in bytes while we want to count // characters (in first approximation, anyhow...). if ( text_length + g_utf8_strlen(new_text, -1) > text_max_length ) { // Prevent the new text from being inserted. handled = true; // Currently we don't insert anything at all, but it would be better to // insert as many characters as would fit into the text control and // only discard the rest. // Notify the user code about overflow. text->SendMaxLenEvent(); } } // Check if we have to convert all input to upper-case if ( !handled && text->GTKIsUpperCase() ) { const wxGtkString upper(g_utf8_strup(new_text, new_text_length)); // Use the converted text to generate events if ( !text->GTKEntryOnInsertText(upper) ) { // Event not handled, so do insert the text: we have to do it // ourselves to use the upper-case version of it // Prevent recursive call to this handler again g_signal_handlers_block_by_func ( editable, (gpointer)wx_gtk_insert_text_callback, text ); gtk_editable_insert_text(editable, upper, strlen(upper), position); g_signal_handlers_unblock_by_func ( editable, (gpointer)wx_gtk_insert_text_callback, text ); } // Don't call the default handler in any case, either the event was // handled in the user code or we've already inserted the text. handled = true; } if ( !handled && text->GTKEntryOnInsertText(new_text) ) { // If we already handled the new text insertion, don't do it again. handled = true; } if ( handled ) { // We must update the position to point after the newly inserted text, // as expected by GTK+. *position = text->GetInsertionPoint(); g_signal_stop_emission_by_name (editable, "insert_text"); } }
/* * Get text and use that to fill in the placeholder. */ uint8_t fill_in_flags(char **cmd, uint8_t flags) { uint8_t ret = 0; const char *text = NULL; GtkWidget *dialog, *box, *entry, *label = NULL; GtkEntryBuffer *buf; GValue g_9 = G_VALUE_INIT; g_value_init(&g_9, G_TYPE_INT); g_value_set_int(&g_9, 3); dialog = gtk_dialog_new_with_buttons( "Command options", GTK_WINDOW(window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, "_Close", GTK_RESPONSE_CLOSE, "_Run", GTK_RESPONSE_OK, NULL); box = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); entry = gtk_entry_new(); gtk_widget_set_size_request(dialog, 300, 20); g_object_set_property(G_OBJECT(box), "margin", &g_9); gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); if (flags & SINGLE_FILE_PLACEHOLDER) label = gtk_label_new("File name"); if (flags & SINGLE_URL_PLACEHOLDER) label = gtk_label_new("URI"); if (flags & MULTI_FILE_PLACEHOLDER) label = gtk_label_new("Files"); if (flags & MULTI_URL_PLACEHOLDER) label = gtk_label_new("URIs"); if (label) { gtk_box_pack_start(GTK_BOX(box), label, /* expand */ 0, /* fill */ 1, /* padding */ 3); gtk_box_pack_start(GTK_BOX(box), entry, /* expand */ 1, /* fill */ 1, /* padding */ 3); } gtk_widget_show_all(box); switch (gtk_dialog_run(GTK_DIALOG(dialog))) { case GTK_RESPONSE_OK: buf = gtk_entry_get_buffer(GTK_ENTRY(entry)); text = gtk_entry_buffer_get_text(buf); if ((*cmd = fill_in_command(*cmd, text, flags)) == NULL) { warnx("fill_in_command failed"); break; } ret = 1; break; case GTK_RESPONSE_CLOSE: case GTK_RESPONSE_NONE: case GTK_RESPONSE_DELETE_EVENT: break; default: warnx("unknown result from gtk_dialog_run"); break; } gtk_widget_destroy(dialog); return ret; }