int x_create_input (Dlg_head *h, widget_data parent, WInput *in) { GtkWidget *gnome_entry; GtkEntry *entry; /* The widget might have been initialized manually. * Look in gscreen.c for an example */ if (in->widget.wdata) return 1; #ifdef USE_GNOME_ENTRY gnome_entry = gnome_entry_new (in->widget.tkname); #else entry = GTK_ENTRY (gnome_entry = gtk_entry_new ()); gtk_entry_set_visibility (entry, !in->is_password); #endif gtk_widget_show (gnome_entry); in->widget.wdata = (widget_data) gnome_entry; #ifdef USE_GNOME_ENTRY entry = GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (gnome_entry))); #endif gtk_entry_set_text (entry, in->buffer); gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1); gtk_entry_set_position (entry, in->point); gtk_signal_connect (GTK_OBJECT (entry), "button_press_event", GTK_SIGNAL_FUNC (entry_click), in); gtk_signal_connect (GTK_OBJECT (entry), "button_release_event", GTK_SIGNAL_FUNC (entry_release), in); return 1; }
GtkWidget * get_gtk_widget (Widget_Item *p) { GtkWidget *w = GTK_WIDGET (p->widget->wdata); if (GNOME_IS_ENTRY (w)) return (gnome_entry_gtk_entry ((GnomeEntry *)(w))); else return (GTK_WIDGET (p->widget->wdata)); }
static void lookup_button_cb (GtkButton *button, GtkWidget * defbox) { gchar *text; GtkWidget * entry = gnome_entry_gtk_entry(GNOME_ENTRY(gdict_entry)); text = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1); if (text) { gdict_defbox_lookup (GDICT_DEFBOX (defbox), text); g_free (text); } }
void x_update_input (WInput *in) { GnomeEntry *gnome_entry; GtkEntry *entry; char *text; int draw = 0; /* If the widget has not been initialized yet (done by WIDGET_INIT) */ if (!in->widget.wdata) return; #ifdef USE_GNOME_ENTRY gnome_entry = GNOME_ENTRY (in->widget.wdata); entry = GTK_ENTRY (gnome_entry_gtk_entry (gnome_entry)); #else entry = GTK_ENTRY (in->widget.wdata); #endif if (in->first == -1){ gtk_editable_select_region (GTK_EDITABLE (entry), 0, 0); in->first = 0; } text = gtk_entry_get_text (GTK_ENTRY (entry)); if (text && strcmp (text, in->buffer)){ gtk_entry_set_text (entry, in->buffer); draw = 1; } if (GTK_EDITABLE (entry)->current_pos != in->point){ gtk_entry_set_position (entry, in->point); draw = 1; } if (draw){ #ifdef USE_GNOME_ENTRY gtk_widget_draw (GTK_WIDGET (gnome_entry), NULL); #else gtk_widget_draw (GTK_WIDGET (entry), NULL); #endif gtk_editable_changed (GTK_EDITABLE (entry)); gtk_widget_queue_draw (GTK_WIDGET (entry)); } }
static void GDict_exec (const char * search) { if (!gdict_dlg) { // create the dialog GDict_dlg_create (search); } else { // raise to the front gdk_window_raise (gdict_dlg->window); } GtkWidget * entry = gnome_entry_gtk_entry (GNOME_ENTRY(gdict_entry)); gtk_entry_set_text (GTK_ENTRY(entry), search); gnome_entry_prepend_history(GNOME_ENTRY(gdict_entry), false, search); gdict_defbox_lookup (GDICT_DEFBOX (gdict_defbox), (char*)search); }
static void GDict_dlg_create (const char * search) { GtkWidget * vbox; GtkWidget * hbox; GtkWidget * button; GtkWidget * scrolled; GtkWidget * close; GtkWidget * gtk_entry; // create the toplevel dialog gdict_dlg = gnome_dialog_new ("AbiWord Dictionary", GNOME_STOCK_BUTTON_CLOSE, NULL); gtk_window_set_modal (GTK_WINDOW(gdict_dlg), false); gtk_widget_set_usize (gdict_dlg, 450, 300); // center the dialog and connect focus XAP_App * pApp = XAP_App::getApp (); XAP_UnixFrame * pFrame = static_cast<XAP_UnixFrame*>(pApp->getLastFocussedFrame ()); GtkWidget * parent = pFrame->getTopLevelWindow(); centerDialog(parent, gdict_dlg); close = GTK_WIDGET (g_list_last (GNOME_DIALOG (gdict_dlg)->buttons)->data); vbox = GNOME_DIALOG(gdict_dlg)->vbox; hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL); gtk_container_set_border_width (GTK_CONTAINER (hbox), GNOME_PAD_SMALL); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); button = gtk_button_new_with_label ("Look Up"); gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); gdict_entry = gnome_entry_new(NULL); gtk_entry = gnome_entry_gtk_entry(GNOME_ENTRY(gdict_entry)); gtk_box_pack_start (GTK_BOX (hbox), gdict_entry, TRUE, TRUE, 0); scrolled = gtk_scrolled_window_new (NULL, NULL); gtk_container_set_border_width (GTK_CONTAINER (scrolled), GNOME_PAD_SMALL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_start (GTK_BOX (vbox), scrolled, TRUE, TRUE, 0); gdict_defbox = gdict_defbox_new (); gtk_widget_show (gdict_defbox); gtk_container_add (GTK_CONTAINER (scrolled), gdict_defbox); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (lookup_button_cb), gdict_defbox); g_signal_connect (G_OBJECT (gtk_entry), "activate", G_CALLBACK (entry_activate_cb), gdict_defbox); #if 0 g_signal_connect (G_OBJECT (gtk_entry), "changed", G_CALLBACK (entry_activate_cb), gdict_defbox); #endif g_signal_connect (G_OBJECT (gdict_dlg), "close", G_CALLBACK(close_cb), (gpointer)0); g_signal_connect (G_OBJECT (close), "clicked", G_CALLBACK(close_cb), (gpointer)0); g_signal_connect_after(G_OBJECT(gdict_dlg), "destroy", NULL, NULL); gtk_widget_show_all (gdict_dlg); }
void on_connectdbok_clicked(GtkWidget *widget, gpointer user_data) { gchar *host; gchar *user; gchar *password; gchar *dbname; gchar dbquery[200]; gchar dbstatus[1000]; int broken,found; xmlNodePtr node; host=gtk_entry_get_text((GtkEntry *)gnome_entry_gtk_entry(connectdb_host)); user=gtk_entry_get_text((GtkEntry *)gnome_entry_gtk_entry(connectdb_user)); password=gtk_entry_get_text(connectdb_password); dbname=gtk_entry_get_text((GtkEntry *)gnome_entry_gtk_entry(connectdb_database)); broken=FALSE; mysql=mysql_init(NULL); if (!mysql_real_connect(mysql,host,user,password,NULL,0,NULL,0)) { error_dialog("Could not connect to Database"); fprintf(stderr, "Failed to connect to database: Error: %s\n", mysql_error(mysql)); mysql_close(mysql); mysql=NULL; } else { sprintf(dbquery,"use %s",dbname); mysql_query(mysql,dbquery); if (mysql_errno(mysql)!=0) { switch (ok_cancel_dialog("The database does not exist.\nCreate a new one?")) { case 0: g_message("Creating new Database %s.\n",dbname); sprintf(dbquery,"create database %s",dbname); if (mysql_query(mysql,dbquery)!=0) { fprintf(stderr, "Failed to create database: Error: %s\n", mysql_error(mysql)); } sprintf(dbquery,"use %s",dbname); if (mysql_query(mysql,dbquery)!=0) { fprintf(stderr, "Failed to use database: Error: %s\n", mysql_error(mysql)); } break; case 1: broken=TRUE; break; default: broken=TRUE; break; } } if (broken==FALSE) { sprintf(dbquery,"create table _TableNames (Name Text,TName Text,Comment Text)"); mysql_query(mysql,dbquery); name_cache=g_hash_table_new(g_str_hash,g_str_equal); tname_cache=g_hash_table_new(g_str_hash,g_str_equal); sprintf(dbstatus,"Database: %s\nuser: %s\nhost: %s",dbname,user,host); gtk_label_set_text(database_status_label,dbstatus); // ------------------------------- found=FALSE; node=global_configs_doc->children; while (node) { if (strcmp(node->name,"configurations")==0) { node=node->children; break; } node=node->next; } if (node) { while (node) { if (strcmp(node->name,"dbconfig")==0) { if (strcmp(xmlGetProp(node,"dbname"),dbname)==0) { found=TRUE; db_global_configs_node=node; break; } } node=node->next; } } if (!found) { db_global_configs_node=xmlNewNode(NULL,"dbconfig"); xmlSetProp(db_global_configs_node,"dbname",dbname); xmlAddChild(global_configs_doc->children,db_global_configs_node); } // --------------------------------- found=FALSE; node=local_configs_doc->children; while (node) { if (strcmp(node->name,"configurations")==0) { node=node->children; break; } node=node->next; } if (node) { while (node) { if (strcmp(node->name,"dbconfig")==0) { if (strcmp(xmlGetProp(node,"dbname"),dbname)==0) { found=TRUE; db_local_configs_node=node; break; } } node=node->next; } } if (!found) { db_local_configs_node=xmlNewNode(NULL,"dbconfig"); xmlSetProp(db_local_configs_node,"dbname",xmlEncodeEntitiesReentrant(local_configs_doc,dbname)); xmlAddChild(local_configs_doc->children,db_local_configs_node); } else { gtk_widget_set_sensitive(GTK_WIDGET(connect_button),FALSE); gtk_widget_set_sensitive(GTK_WIDGET(disconnect_button),TRUE); gtk_widget_set_sensitive(GTK_WIDGET(add_category_button),TRUE); } // --------------------------------- gnome_dialog_close(connectdb_dialog); update_tablelist(mysql); } } }