EXPORT wBool_t wTextPrint( wText_p bt ) { wPrinterStream_p f; #ifndef USE_TEXTVIEW int siz, pos, cnt; #endif char * cp; f = wPrinterOpen(); if (f==NULL) { return FALSE; } #ifdef USE_TEXTVIEW cp = gtkGetText( bt ); wPrinterWrite( f, cp, strlen(cp) ); free(cp); #else siz = gtk_text_get_length( GTK_TEXT(bt->text) ); pos = 0; cnt = BUFSIZ; while (pos<siz) { if (pos+cnt>siz) cnt = siz-pos; cp = gtk_editable_get_chars( GTK_EDITABLE(bt->text), pos, pos+cnt ); if (cp == NULL) break; wPrinterWrite( f, cp, cnt ); free(cp); pos += cnt; } #endif wPrinterClose(f); return TRUE; }
void wxTextCtrl::OnInternalIdle() { wxCursor cursor = m_cursor; if (g_globalCursor.IsOk()) cursor = g_globalCursor; if (cursor.IsOk()) { GdkWindow *window = NULL; if (HasFlag(wxTE_MULTILINE)) window = GTK_TEXT(m_text)->text_area; else window = GTK_ENTRY(m_text)->text_area; if (window) gdk_window_set_cursor( window, cursor.GetCursor() ); if (!g_globalCursor.IsOk()) cursor = *wxSTANDARD_CURSOR; window = m_widget->window; if ((window) && !(GTK_WIDGET_NO_WINDOW(m_widget))) gdk_window_set_cursor( window, cursor.GetCursor() ); } if (g_delayedFocus == this) { if (GTK_WIDGET_REALIZED(m_widget)) { gtk_widget_grab_focus( m_widget ); g_delayedFocus = NULL; } } if (wxUpdateUIEvent::CanUpdate(this)) UpdateWindowUI(wxUPDATE_UI_FROMIDLE); }
static void replace_word(GtkWidget *w, gpointer d) { int start, end; char *newword; char buf[BUFSIZE]; /* we don't save their position, * because the cursor is moved by the click. */ gtk_text_freeze(GTK_TEXT(d)); gtk_label_get(GTK_LABEL(GTK_BIN(w)->child), &newword); get_curword(GTK_TEXT(d), buf, &start, &end); gtk_text_set_point(GTK_TEXT(d), end); gtk_text_backward_delete(GTK_TEXT(d), end-start); gtk_text_insert(GTK_TEXT(d), NULL, NULL, NULL, newword, strlen(newword)); gtk_text_thaw(GTK_TEXT(d)); }
static void fdriverchooser_switch_page (GtkNotebook * notebook, GtkNotebookPage * page, gint page_num, TFDRIVERCHOOSER * choose_t) { guint len; char buff[1024]; char *dsn = {""}; char *drv = {""}; char *curr; if (choose_t) { switch (page_num) { case 0: if (choose_t->b_back) gtk_widget_set_sensitive (choose_t->b_back, FALSE); if (choose_t->b_continue) gtk_label_parse_uline(GTK_LABEL(GTK_BIN (choose_t->b_continue)->child), "Continue"); break; case 1: if (choose_t->driverlist && choose_t->tab_panel && GTK_CLIST (choose_t->driverlist)->selection == NULL) { _iodbcdm_messagebox(choose_t->mainwnd, NULL, "Driver wasn't selected!"); gtk_notebook_set_page (GTK_NOTEBOOK (choose_t->tab_panel), 0); break; } if (choose_t->b_back) gtk_widget_set_sensitive (choose_t->b_back, TRUE); if (choose_t->b_continue) gtk_label_parse_uline(GTK_LABEL(GTK_BIN (choose_t->b_continue)->child), "Co_ntinue"); break; case 2: if (choose_t->driverlist && choose_t->tab_panel && choose_t->dsn_entry) { if (GTK_CLIST (choose_t->driverlist)->selection != NULL) { gtk_clist_get_text (GTK_CLIST (choose_t->driverlist), GPOINTER_TO_INT(GTK_CLIST(choose_t->driverlist)->selection->data), 0, &drv); } else { _iodbcdm_messagebox(choose_t->mainwnd, NULL, "Driver wasn't selected!"); gtk_notebook_set_page (GTK_NOTEBOOK (choose_t->tab_panel), 0); break; } dsn = gtk_entry_get_text(GTK_ENTRY(choose_t->dsn_entry)); if (strlen(dsn) < 1) { _iodbcdm_messagebox(choose_t->mainwnd, NULL, "Enter File DSN Name..."); gtk_notebook_set_page (GTK_NOTEBOOK (choose_t->tab_panel), 1); break; } } if (choose_t->b_back) gtk_widget_set_sensitive (choose_t->b_back, TRUE); if (choose_t->b_continue) gtk_label_parse_uline(GTK_LABEL(GTK_BIN (choose_t->b_continue)->child), "_Finish"); if (choose_t->mess_entry) { #if GTK_CHECK_VERSION(2,0,0) GtkTextBuffer *gbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(choose_t->mess_entry)); GtkTextIter *iter; gtk_text_buffer_set_text(gbuf, "", 0); if (strchr(dsn, '/') != NULL) snprintf(buff, sizeof(buff), "Filename: %s\n", dsn); else snprintf(buff, sizeof(buff), "Filename: %s/%s\n", choose_t->curr_dir, dsn); gtk_text_buffer_insert_at_cursor(gbuf, buff, -1); snprintf(buff, sizeof(buff), "Driver: %s\n", drv); gtk_text_buffer_insert_at_cursor(gbuf, buff, -1); gtk_text_buffer_insert_at_cursor(gbuf, "Driver-specific Keywords:\n", -1); if (choose_t->attrs) { for (curr = choose_t->attrs; *curr; curr += (STRLEN (curr) + 1)) { if (!strncasecmp (curr, "PWD=", STRLEN ("PWD="))) continue; if (curr) gtk_text_buffer_insert_at_cursor(gbuf, curr, -1); gtk_text_buffer_insert_at_cursor(gbuf, "\n", -1); } } #else gtk_text_set_point(GTK_TEXT(choose_t->mess_entry), 0); len = gtk_text_get_length(GTK_TEXT(choose_t->mess_entry)); gtk_text_forward_delete(GTK_TEXT(choose_t->mess_entry), len); gtk_text_insert(GTK_TEXT(choose_t->mess_entry), NULL, NULL, NULL, "File Data Source\n", -1); if (strchr(dsn, '/') != NULL) snprintf(buff, sizeof(buff), "Filename: %s\n", dsn); else snprintf(buff, sizeof(buff), "Filename: %s/%s\n", choose_t->curr_dir, dsn); gtk_text_insert(GTK_TEXT(choose_t->mess_entry), NULL, NULL, NULL, buff, -1); snprintf(buff, sizeof(buff), "Driver: %s\n", drv); gtk_text_insert(GTK_TEXT(choose_t->mess_entry), NULL, NULL, NULL, buff, -1); gtk_text_insert(GTK_TEXT(choose_t->mess_entry), NULL, NULL, NULL, "Driver-specific Keywords:\n", -1); if (choose_t->attrs) { for (curr = choose_t->attrs; *curr; curr += (STRLEN (curr) + 1)) { if (!strncasecmp (curr, "PWD=", STRLEN ("PWD="))) { continue; } gtk_text_insert(GTK_TEXT(choose_t->mess_entry), NULL, NULL, NULL, curr, -1); gtk_text_insert(GTK_TEXT(choose_t->mess_entry), NULL, NULL, NULL, "\n", -1); } } #endif } break; } } }
/*-----------------------------------------------------------------------------------------------------------------------*/ int main(int argc,char *argv[]) { GtkWidget *Win,*VBox,*VBox2,*HBox,*MenuBox,*MenuBar,*But; gint i; static GdkColor White = {0,0xFFFF,0xFFFF,0xFFFF}; static GdkColor Red = {0,0xFFFF,0x0000,0x0000}; static GdkColor Blue = {0,0x0000,0x0000,0xFFFF}; GtkStyle *RedStyle,*BlueStyle; g_thread_init(NULL); gdk_threads_init(); gdk_threads_enter(); gtk_init(&argc,&argv); AcqOn=FALSE; strcpy(SetupFName,""); StnNo=1; NScalers=4; for (i=0;i<4;++i) SubA[i]=i; Interval[0]=1; Interval[1]=5; Interval[2]=60; Duration[0]=10; Duration[1]=60; RedStyle=gtk_style_copy(gtk_widget_get_default_style()); for (i=0;i<5;i++) { RedStyle->fg[i]=RedStyle->text[i]=Red; RedStyle->bg[i]=White; } BlueStyle=gtk_style_copy(gtk_widget_get_default_style()); for (i=0;i<5;i++) { BlueStyle->fg[i]=BlueStyle->text[i]=Blue; BlueStyle->bg[i]=White; } Win=gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_signal_connect(GTK_OBJECT(Win),"delete_event",GTK_SIGNAL_FUNC(DeleteMain),NULL); gtk_signal_connect(GTK_OBJECT(Win),"destroy",GTK_SIGNAL_FUNC(DestroyMain),NULL); gtk_window_set_title(GTK_WINDOW(Win),"SCALER (07 Aug 2009)"); gtk_widget_set_uposition(GTK_WIDGET(Win),100,50); gtk_widget_set_usize(GTK_WIDGET(Win),845,600); VBox=gtk_vbox_new(FALSE,0); gtk_container_add(GTK_CONTAINER(Win),VBox); MenuBox=gtk_vbox_new(FALSE,1); gtk_box_pack_start(GTK_BOX(VBox),MenuBox,FALSE,FALSE,0); GetMainMenu(Win,&MenuBar); gtk_box_pack_start(GTK_BOX(MenuBox),MenuBar,FALSE,TRUE,0); VBox2=gtk_vbox_new(FALSE,0); gtk_box_pack_start(GTK_BOX(VBox),VBox2,FALSE,FALSE,0); gtk_container_set_border_width(GTK_CONTAINER(VBox2),10); HBox=gtk_hbox_new(FALSE,0); gtk_box_pack_start(GTK_BOX(VBox2),HBox,FALSE,FALSE,0); S_Start=gtk_label_new("Start:\n"); gtk_box_pack_start(GTK_BOX(HBox),S_Start,FALSE,FALSE,0); HBox=gtk_hbox_new(FALSE,0); gtk_box_pack_start(GTK_BOX(VBox2),HBox,FALSE,FALSE,0); S_Stop=gtk_label_new("Stop:\n"); gtk_box_pack_start(GTK_BOX(HBox),S_Stop,FALSE,FALSE,0); HBox=gtk_hbox_new(FALSE,0); gtk_box_pack_start(GTK_BOX(VBox),HBox,FALSE,FALSE,0); But=gtk_button_new_with_label("Elapsed"); SetStyleRecursively(But,BlueStyle); gtk_box_pack_start(GTK_BOX(HBox),But,FALSE,FALSE,0); gtk_widget_set_usize(But,56,24); But=gtk_button_new_with_label("Scaler1"); SetStyleRecursively(But,BlueStyle); gtk_box_pack_start(GTK_BOX(HBox),But,FALSE,FALSE,40); gtk_widget_set_usize(But,50,24); But=gtk_button_new_with_label("Rate1"); SetStyleRecursively(But,BlueStyle); gtk_box_pack_start(GTK_BOX(HBox),But,FALSE,FALSE,-20); gtk_widget_set_usize(But,50,24); But=gtk_button_new_with_label("Scaler2"); SetStyleRecursively(But,BlueStyle); gtk_box_pack_start(GTK_BOX(HBox),But,FALSE,FALSE,70); gtk_widget_set_usize(But,50,24); But=gtk_button_new_with_label("Rate2"); SetStyleRecursively(But,BlueStyle); gtk_box_pack_start(GTK_BOX(HBox),But,FALSE,FALSE,-50); gtk_widget_set_usize(But,50,24); But=gtk_button_new_with_label("Scaler3"); SetStyleRecursively(But,BlueStyle); gtk_box_pack_start(GTK_BOX(HBox),But,FALSE,FALSE,100); gtk_widget_set_usize(But,50,24); But=gtk_button_new_with_label("Rate3"); SetStyleRecursively(But,BlueStyle); gtk_box_pack_start(GTK_BOX(HBox),But,FALSE,FALSE,-80); gtk_widget_set_usize(But,50,24); But=gtk_button_new_with_label("Scaler4"); SetStyleRecursively(But,BlueStyle); gtk_box_pack_start(GTK_BOX(HBox),But,FALSE,FALSE,135); gtk_widget_set_usize(But,50,24); But=gtk_button_new_with_label("Rate4"); SetStyleRecursively(But,BlueStyle); gtk_box_pack_start(GTK_BOX(HBox),But,FALSE,FALSE,-120); gtk_widget_set_usize(But,50,24); S_Output=gtk_text_new(NULL,NULL); gtk_widget_set_usize(GTK_WIDGET(S_Output),0,430); SetStyleRecursively(S_Output,RedStyle); gtk_box_pack_start(GTK_BOX(VBox),S_Output,FALSE,FALSE,0); gtk_text_set_word_wrap(GTK_TEXT(S_Output),TRUE); gtk_text_set_editable(GTK_TEXT(S_Output),FALSE); gtk_widget_show_all(Win); //gdk_threads_enter(); gtk_main(); gdk_threads_leave(); gtk_style_unref(RedStyle); gtk_style_unref(BlueStyle); return(0); }
static void sfe_ui_TreeSelectionChanged( GtkWidget *tree ) { GList *itemlist; gchar *name; GtkBox *hbox; GtkLabel *label; GtkWidget *item; pStructInf infptr, subinf; gchar* annotation; int i; gchar* rowtext[2]; gchar intbuf[32]; char* strval; int intval; /** Get the hidden label which contains the pointer to the inf **/ if (!tree) return; itemlist = GTK_TREE_SELECTION(tree); if (!itemlist) return; item = GTK_WIDGET (itemlist->data); if (!item) return; hbox = GTK_BOX (GTK_BIN (item)->child); label = GTK_LABEL (((GtkBoxChild*)(hbox->children->next->next->data))->widget); gtk_label_get (label, &name); infptr = (pStructInf)(strtol(name, NULL, 16)); if (!infptr) return; /** Show the info on the right side of the window **/ gtk_entry_set_text(GTK_ENTRY(SFE_Globals.NameEdit), infptr->Name); gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(SFE_Globals.TypeCombo)->entry), infptr->UsrType); gtk_text_set_point(GTK_TEXT(SFE_Globals.AnnotText), 0); gtk_text_forward_delete(GTK_TEXT(SFE_Globals.AnnotText), gtk_text_get_length(GTK_TEXT(SFE_Globals.AnnotText))); annotation=""; stAttrValue(stLookup(infptr,"annotation"), NULL, &annotation, 0); gtk_text_insert(GTK_TEXT(SFE_Globals.AnnotText), NULL, NULL, NULL, annotation, strlen(annotation)); /** Build the attributes listing **/ gtk_clist_clear(GTK_CLIST(SFE_Globals.AttrsCList)); for(i=0;i<infptr->nSubInf;i++) { subinf = infptr->SubInf[i]; if (stStructType(subinf) == ST_T_ATTRIB) { strval = NULL; stAttrValue(subinf, &intval, &strval, 0); rowtext[0] = subinf->Name; if (strval) { rowtext[1] = strval; } else { snprintf(intbuf, 32, "%d", intval); rowtext[1] = intbuf; } gtk_clist_append(GTK_CLIST(SFE_Globals.AttrsCList), rowtext); } } return; }
int main (int argc, char *argv[]) { GtkWidget *dialog; GtkWidget *button; GtkWidget *table; GtkWidget *label; GtkWidget *entry; GtkWidget *hscrollbar; GtkWidget *vscrollbar; GtkWidget *hbox; static GtkTargetEntry targetlist[] = { { "STRING", 0, STRING }, { "TEXT", 0, TEXT }, { "COMPOUND_TEXT", 0, COMPOUND_TEXT } }; static gint ntargets = sizeof(targetlist) / sizeof(targetlist[0]); gtk_init (&argc, &argv); init_atoms(); selection_widget = gtk_invisible_new (); dialog = gtk_dialog_new (); gtk_widget_set_name (dialog, "Test Input"); gtk_container_set_border_width (GTK_CONTAINER(dialog), 0); g_signal_connect (dialog, "destroy", G_CALLBACK (quit), NULL); table = gtk_table_new (4, 2, FALSE); gtk_container_set_border_width (GTK_CONTAINER(table), 10); gtk_table_set_row_spacing (GTK_TABLE (table), 0, 5); gtk_table_set_row_spacing (GTK_TABLE (table), 1, 2); gtk_table_set_row_spacing (GTK_TABLE (table), 2, 2); gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2); gtk_box_pack_start (GTK_BOX (GTK_DIALOG(dialog)->vbox), table, TRUE, TRUE, 0); gtk_widget_show (table); selection_button = gtk_toggle_button_new_with_label ("Claim Selection"); gtk_table_attach (GTK_TABLE (table), selection_button, 0, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 0, 0); gtk_widget_show (selection_button); g_signal_connect (selection_button, "toggled", G_CALLBACK (selection_toggled), NULL); g_signal_connect (selection_widget, "selection_clear_event", G_CALLBACK (selection_clear), NULL); g_signal_connect (selection_widget, "selection_received", G_CALLBACK (selection_received), NULL); gtk_selection_add_targets (selection_widget, GDK_SELECTION_PRIMARY, targetlist, ntargets); g_signal_connect (selection_widget, "selection_get", G_CALLBACK (selection_get), NULL); selection_text = gtk_text_new (NULL, NULL); gtk_table_attach_defaults (GTK_TABLE (table), selection_text, 0, 1, 1, 2); gtk_widget_show (selection_text); hscrollbar = gtk_hscrollbar_new (GTK_TEXT (selection_text)->hadj); gtk_table_attach (GTK_TABLE (table), hscrollbar, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (hscrollbar); vscrollbar = gtk_vscrollbar_new (GTK_TEXT (selection_text)->vadj); gtk_table_attach (GTK_TABLE (table), vscrollbar, 1, 2, 1, 2, GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_widget_show (vscrollbar); hbox = gtk_hbox_new (FALSE, 2); gtk_table_attach (GTK_TABLE (table), hbox, 0, 2, 3, 4, GTK_EXPAND | GTK_FILL, 0, 0, 0); gtk_widget_show (hbox); label = gtk_label_new ("Target:"); gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); entry = gtk_entry_new (); gtk_box_pack_start (GTK_BOX(hbox), entry, TRUE, TRUE, 0); gtk_widget_show (entry); /* .. And create some buttons */ button = gtk_button_new_with_label ("Paste"); gtk_box_pack_start (GTK_BOX (GTK_DIALOG(dialog)->action_area), button, TRUE, TRUE, 0); g_signal_connect (button, "clicked", G_CALLBACK (paste), entry); gtk_widget_show (button); button = gtk_button_new_with_label ("Quit"); gtk_box_pack_start (GTK_BOX (GTK_DIALOG(dialog)->action_area), button, TRUE, TRUE, 0); g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), dialog); gtk_widget_show (button); gtk_widget_show (dialog); gtk_main (); return 0; }
void text_toggle_editable (GtkWidget *checkbutton, GtkWidget *text) { gtk_text_set_editable (GTK_TEXT (text), GTK_TOGGLE_BUTTON (checkbutton)->active); }
static void dosavelog (GtkWidget * widget, GtkFileSelection * fs) { const char *filename; char *txt, *pos; gint textlen; ssize_t len; FILE *fd; int ok; #if GTK_MAJOR_VERSION > 1 GtkTextBuffer * textbuf; GtkTextIter iter, iter2; #endif filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs)); if ((fd = fopen (filename, "w")) == NULL) { ftp_log (gftp_logging_error, NULL, _("Error: Cannot open %s for writing: %s\n"), filename, g_strerror (errno)); return; } #if GTK_MAJOR_VERSION == 1 textlen = gtk_text_get_length (GTK_TEXT (logwdw)); txt = gtk_editable_get_chars (GTK_EDITABLE (logwdw), 0, -1); #else textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (logwdw)); textlen = gtk_text_buffer_get_char_count (textbuf); gtk_text_buffer_get_iter_at_offset (textbuf, &iter, 0); gtk_text_buffer_get_iter_at_offset (textbuf, &iter2, textlen); txt = gtk_text_buffer_get_text (textbuf, &iter, &iter2, 0); /* gtk_text_buffer_get_char_count() returns the number of characters, not bytes. So get the number of bytes that need to be written out */ textlen = strlen (txt); #endif ok = 1; pos = txt; do { if ((len = write (fileno (fd), pos, textlen)) == -1) { ok = 0; ftp_log (gftp_logging_error, NULL, _("Error: Error writing to %s: %s\n"), filename, g_strerror (errno)); break; } textlen -= len; pos += len; } while (textlen > 0); if (ok) ftp_log (gftp_logging_misc, NULL, _("Successfully wrote the log file to %s\n"), filename); fclose (fd); g_free (txt); }
void file_info (gint CurrentPage) { GtkWidget *FileInfoWindow; GtkWidget *Button; GtkWidget *HBox; GtkWidget *FileInfoLabelLeft, *FileInfoLabelRight; gint BufferSize, FileSize, Difference; gboolean NewFile = FALSE; if (!OpenedFilesCnt) return; if (stat (FPROPS(CurrentPage, Name), &FPROPS(CurrentPage, Stats)) == -1) NewFile = TRUE; BufferSize = gtk_text_get_length (GTK_TEXT(FPROPS(CurrentPage, Text))); FileSize = NewFile ? 0 : (gint)FPROPS(CurrentPage, Stats).st_size; Difference = BufferSize - FileSize; FileInfoWindow = gtk_dialog_new (); gtk_window_set_title (GTK_WINDOW(FileInfoWindow), "File Information"); gtk_window_set_policy (GTK_WINDOW(FileInfoWindow), FALSE, FALSE, FALSE); gtk_signal_connect_object (GTK_OBJECT(FileInfoWindow), "delete_event", (GtkSignalFunc) gtk_widget_destroy, GTK_OBJECT(FileInfoWindow)); gtk_signal_connect_object (GTK_OBJECT (FileInfoWindow), "destroy", (GtkSignalFunc) gtk_widget_destroy, GTK_OBJECT(FileInfoWindow)); HBox = gtk_hbox_new (FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER(HBox), 5); FileInfoLabelLeft = gtk_label_new ("Base name :" "\nFull name :" "\nLanguage :" "\n" "\nModified :" "\nReadonly :" "\n" "\nBuffer Size :" "\nFile Size :" "\nDifference :" #ifndef WIN32 "\n" "\nPermissions :" "\nOwner UID :" "\nOwner GID :" #endif ); gtk_label_set_justify (GTK_LABEL(FileInfoLabelLeft), GTK_JUSTIFY_LEFT); FileInfoLabelRight = gtk_label_new (g_strconcat (FPROPS(CurrentPage, BaseName), "\n", FPROPS(CurrentPage, Name), "\n", FPROPS(CurrentPage, WidgetInfo.Lg) == -1 ? UNKNOWN : Prefs.L[FPROPS(CurrentPage, WidgetInfo.Lg)].Description, "\n", "\n", FPROPS(CurrentPage, Changed[0]) ? "Yes" : "No", "\n", FPROPS(CurrentPage, ReadOnly) ? "Yes" : "No", "\n", "\n", g_strdup_printf ("%d", BufferSize), ((BufferSize == -1) || (BufferSize == 0) || (BufferSize == 1)) ? " Byte" : " Bytes", "\n", g_strdup_printf ("%d", FileSize), ((FileSize == -1) || (FileSize == 0) || (FileSize == 1)) ? " Byte" : " Bytes", "\n", g_strdup_printf ("%d", Difference), ((Difference == -1) || (Difference == 0) || (Difference == 1)) ? " Byte" : " Bytes", #ifndef WIN32 "\n", "\n", NewFile ? UNKNOWN : get_file_mode (FPROPS(CurrentPage, Stats)), "\n", NewFile ? UNKNOWN : g_strdup_printf ("%d", FPROPS(CurrentPage, Stats).st_uid), "\n", NewFile ? UNKNOWN : g_strdup_printf ("%d", FPROPS(CurrentPage, Stats).st_gid), #endif NULL)); gtk_label_set_justify (GTK_LABEL(FileInfoLabelRight), GTK_JUSTIFY_LEFT); gtk_box_pack_start (GTK_BOX(HBox), FileInfoLabelLeft, FALSE, FALSE, 5); gtk_box_pack_start (GTK_BOX(HBox), FileInfoLabelRight, FALSE, FALSE, 5); gtk_box_pack_start (GTK_BOX(GTK_DIALOG(FileInfoWindow) -> vbox), HBox, FALSE, FALSE, 5); Button = gtk_button_new_with_label (" Close "); gtk_signal_connect_object (GTK_OBJECT(Button), "clicked", (GtkSignalFunc) gtk_widget_destroy, GTK_OBJECT(FileInfoWindow)); GTK_WIDGET_SET_FLAGS (Button, GTK_CAN_DEFAULT); gtk_box_pack_start (GTK_BOX(GTK_DIALOG(FileInfoWindow) -> action_area), Button, TRUE, TRUE, 0); gtk_widget_grab_default (Button); gtk_widget_show_all (FileInfoWindow); print_msg ("Display File Information window..."); }
void help_text_bold(char *str) { gtk_text_insert (GTK_TEXT (text), NULL, &text->style->fg[GTK_STATE_SELECTED], &text->style->bg[GTK_STATE_SELECTED], str, -1); }
void help_text(char *str) { gtk_text_insert (GTK_TEXT (text), NULL, &text->style->black, NULL, str, -1); }
EXPORT void wTextAppend( wText_p bt, const char * text ) { #ifdef USE_TEXTVIEW GtkTextBuffer * tb; GtkTextIter ti1, ti2; #else static GdkFont * fixedRegularFont = NULL; static GdkFont * fixedBoldFont = NULL; static GdkFont * variableRegularFont = NULL; static GdkFont * variableBoldFont = NULL; GdkFont * regularFont = NULL; GdkFont * boldFont = NULL; #endif wBool_t doBold; char * cp; int len; if (bt->text == 0) abort(); #ifdef USE_TEXTVIEW tb = gtk_text_view_get_buffer( GTK_TEXT_VIEW(bt->text) ); #else if ((bt->option&BT_FIXEDFONT)) { if (fixedRegularFont==NULL) fixedRegularFont = gdk_font_load( "-*-courier-medium-r-*-*-12-*-*-*-*-*-iso8859-*" ); if (fixedBoldFont==NULL) fixedBoldFont = gdk_font_load( "-*-courier-bold-r-*-*-12-*-*-*-*-*-iso8859-*" ); regularFont = fixedRegularFont; boldFont = fixedBoldFont; } else { if (variableRegularFont==NULL) variableRegularFont = gdk_font_load( "-*-helvetica-medium-r-*-*-12-*-*-*-*-*-iso8859-*" ); if (variableBoldFont==NULL) variableBoldFont = gdk_font_load( "-*-helvetica-bold-r-*-*-12-*-*-*-*-*-iso8859-*" ); regularFont = variableRegularFont; boldFont = variableBoldFont; } #endif /*gtk_text_freeze( GTK_TEXT (bt->text) );*/ doBold = FALSE; text = gtkConvertInput( text ); while ( text && *text ) { if ( (bt->option & BT_DOBOLD) != 0 && ( cp = strchr( text, doBold?'>':'<' ) ) != NULL ) { len = cp-text; cp++; } else { len = -1; cp = NULL; } if ( len != 0 ) { #ifdef USE_TEXTVIEW gtk_text_buffer_get_bounds( tb, &ti1, &ti2 ); if ( !doBold ) gtk_text_buffer_insert( tb, &ti2, text, len ); else gtk_text_buffer_insert_with_tags_by_name( tb, &ti2, text, len, "bold", NULL ); #else gtk_text_insert( GTK_TEXT(bt->text), doBold?boldFont:regularFont, &bt->text->style->black, NULL, text, len ); #endif } text = cp; doBold = !doBold; } /*gtk_text_set_point( GTK_TEXT(bt->text), gtk_text_get_length( GTK_TEXT(bt->text) )-1 );*/ /*gtk_text_thaw( GTK_TEXT (bt->text) );*/ bt->changed = FALSE; }
EXPORT wText_p wTextCreate( wWin_p parent, wPos_t x, wPos_t y, const char * helpStr, const char * labelStr, long option, wPos_t width, wPos_t height ) { wText_p bt; #ifdef USE_TEXTVIEW GtkTextBuffer * tb; #else GtkRequisition requisition; #endif bt = gtkAlloc( parent, B_MULTITEXT, x, y, labelStr, sizeof *bt, NULL ); gtkComputePos( (wControl_p)bt ); bt->width = width; bt->height = height; bt->option = option; gtkComputePos( (wControl_p)bt ); #ifdef USE_TEXTVIEW bt->widget = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (bt->widget), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); bt->text = gtk_text_view_new(); if (bt->text == 0) abort(); gtk_container_add (GTK_CONTAINER (bt->widget), bt->text); tb = gtk_text_view_get_buffer( GTK_TEXT_VIEW(bt->text) ); gtk_text_buffer_create_tag( tb, "bold", "weight", PANGO_WEIGHT_BOLD, NULL); /* gtk_text_buffer_create_tag( tb, "italic", "style", PANGO_STYLE_ITALIC, NULL); */ /* gtk_text_buffer_create_tag( tb, "bolditalic", "weight", PANGO_WEIGHT_BOLD, "style", PANGO_STYLE_ITALIC, NULL); */ bt->vscroll = gtk_vscrollbar_new( GTK_TEXT_VIEW(bt->text)->vadjustment ); if (bt->vscroll == 0) abort(); #else bt->widget = gtk_hbox_new( FALSE, 0 ); bt->text = gtk_text_new( NULL, NULL ); if (bt->text == 0) abort(); gtk_box_pack_start( GTK_BOX(bt->widget), bt->text, FALSE, FALSE, 0 ); bt->vscroll = gtk_vscrollbar_new( GTK_TEXT(bt->text)->vadj ); if (bt->vscroll == 0) abort(); gtk_box_pack_start( GTK_BOX(bt->widget), bt->vscroll, FALSE, FALSE, 0 ); #endif if (option&BT_CHARUNITS) { width *= 7; height *= 14; } gtk_widget_show( bt->text ); gtk_widget_show( bt->vscroll ); gtk_widget_show( bt->widget ); #ifdef USE_TEXTVIEW // gtk_widget_set_size_request( GTK_WIDGET(bt->text), width, height ); // gtk_widget_set_size_request( GTK_WIDGET(bt->vscroll), -1, height ); gtk_widget_set_size_request( GTK_WIDGET(bt->widget), width+15/*requisition.width*/, height ); #else gtk_widget_set_usize( GTK_WIDGET(bt->text), width, height ); gtk_widget_set_usize( GTK_WIDGET(bt->vscroll), -1, height ); gtk_widget_size_request( GTK_WIDGET(bt->vscroll), &requisition ); gtk_widget_set_usize( GTK_WIDGET(bt->widget), width+15/*requisition.width*/, height ); #endif if (bt->option&BO_READONLY) { #ifdef USE_TEXTVIEW gtk_text_view_set_editable( GTK_TEXT_VIEW(bt->text), FALSE ); gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(bt->text), FALSE); #else gtk_text_set_editable( GTK_TEXT(bt->text), FALSE ); #endif } #ifdef USE_TEXTVIEW gtk_fixed_put( GTK_FIXED(parent->widget), bt->widget, bt->realX, bt->realY ); #else gtk_container_add( GTK_CONTAINER(parent->widget), bt->widget ); gtk_widget_set_uposition( bt->widget, bt->realX, bt->realY ); #endif gtkControlGetSize( (wControl_p)bt ); if (labelStr) bt->labelW = gtkAddLabel( (wControl_p)bt, labelStr ); #ifdef USE_TEXTVIEW gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW(bt->text), GTK_WRAP_WORD ); #else gtk_text_set_word_wrap( GTK_TEXT(bt->text), TRUE ); #endif gtk_widget_realize( bt->text ); gtkAddButton( (wControl_p)bt ); gtkAddHelpString( bt->widget, helpStr ); #ifdef USE_TEXTVIEW g_signal_connect( G_OBJECT(tb), "changed", GTK_SIGNAL_FUNC(textChanged), bt ); #else gtk_signal_connect( GTK_OBJECT(bt->text), "changed", GTK_SIGNAL_FUNC(textChanged), bt ); #endif return bt; }
void cheat_sheet_dialog (void) { GtkWidget *mainbox, *scrolled_window, *text, *hbox, *thing; GdkFont *font; if(cheat_sheet_window != NULL) { gdk_window_raise(cheat_sheet_window->window); return; } #ifdef USE_GNOME cheat_sheet_window = gnome_app_new("SoundTracker", _("XM Effects Cheat Sheet")); #else cheat_sheet_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(cheat_sheet_window), _("XM Effects Cheat Sheet")); #endif g_signal_connect (GTK_OBJECT (cheat_sheet_window), "delete_event", GTK_SIGNAL_FUNC (cheat_sheet_close_requested), NULL); mainbox = gtk_vbox_new(FALSE, 2); gtk_container_border_width(GTK_CONTAINER(mainbox), 4); #ifdef USE_GNOME gnome_app_set_contents(GNOME_APP(cheat_sheet_window), mainbox); #else gtk_container_add(GTK_CONTAINER(cheat_sheet_window), mainbox); #endif gtk_widget_show(mainbox); scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_box_pack_start (GTK_BOX (mainbox), scrolled_window, TRUE, TRUE, 0); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); gtk_widget_show (scrolled_window); /* Close button */ thing = gtk_hseparator_new(); gtk_widget_show(thing); gtk_box_pack_start(GTK_BOX(mainbox), thing, FALSE, TRUE, 0); hbox = gtk_hbutton_box_new (); gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbox), 4); gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_END); gtk_box_pack_start (GTK_BOX (mainbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); thing = gtk_button_new_from_stock (GTK_STOCK_CLOSE); GTK_WIDGET_SET_FLAGS(thing, GTK_CAN_DEFAULT); gtk_window_set_default(GTK_WINDOW(cheat_sheet_window), thing); g_signal_connect (GTK_OBJECT (thing), "clicked", GTK_SIGNAL_FUNC (cheat_sheet_close_requested), NULL); gtk_box_pack_start (GTK_BOX (hbox), thing, FALSE, FALSE, 0); gtk_widget_show (thing); text = gtk_text_new (NULL, NULL); gtk_text_set_editable (GTK_TEXT (text), FALSE); gtk_text_set_word_wrap (GTK_TEXT (text), FALSE); gtk_container_add (GTK_CONTAINER (scrolled_window), text); gtk_widget_grab_focus (text); gtk_widget_show (text); gtk_widget_set_usize(text, 42 * 12, 46 * 12); font = gdk_font_load ("-adobe-courier-medium-r-normal--*-120-*-*-*-*-*-*"); gtk_text_insert(GTK_TEXT(text), font, NULL, NULL, cheat_sheet_string, -1); /* The Text widget will reference count the font, so we * unreference it here */ gdk_font_unref (font); gtk_widget_show (cheat_sheet_window); }
void text_toggle_word_wrap (GtkWidget *checkbutton, GtkWidget *text) { gtk_text_set_word_wrap(GTK_TEXT(text), GTK_TOGGLE_BUTTON(checkbutton)->active); }
int main( int argc, char *argv[] ) { GtkWidget *window; GtkWidget *box1; GtkWidget *box2; GtkWidget *hbox; GtkWidget *button; GtkWidget *check; GtkWidget *separator; GtkWidget *table; GtkWidget *vscrollbar; GtkWidget *text; GdkColormap *cmap; GdkColor color; GdkFont *fixed_font; FILE *infile; gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_set_usize (window, 600, 500); gtk_window_set_policy (GTK_WINDOW(window), TRUE, TRUE, FALSE); gtk_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC(close_application), NULL); gtk_window_set_title (GTK_WINDOW (window), "Text Widget Example"); gtk_container_set_border_width (GTK_CONTAINER (window), 0); box1 = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (window), box1); gtk_widget_show (box1); box2 = gtk_vbox_new (FALSE, 10); gtk_container_set_border_width (GTK_CONTAINER (box2), 10); gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0); gtk_widget_show (box2); table = gtk_table_new (2, 2, FALSE); gtk_table_set_row_spacing (GTK_TABLE (table), 0, 2); gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2); gtk_box_pack_start (GTK_BOX (box2), table, TRUE, TRUE, 0); gtk_widget_show (table); /* Create the GtkText widget */ text = gtk_text_new (NULL, NULL); gtk_text_set_editable (GTK_TEXT (text), TRUE); gtk_table_attach (GTK_TABLE (table), text, 0, 1, 0, 1, GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); gtk_widget_show (text); /* Add a vertical scrollbar to the GtkText widget */ vscrollbar = gtk_vscrollbar_new (GTK_TEXT (text)->vadj); gtk_table_attach (GTK_TABLE (table), vscrollbar, 1, 2, 0, 1, GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); gtk_widget_show (vscrollbar); /* Get the system color map and allot the color red */ cmap = gdk_colormap_get_system(); color.red = 0xffff; color.green = 0; color.blue = 0; if (!gdk_color_allot(cmap, &color)) { g_error("couldn't allot color"); } /* Load a fixed font */ fixed_font = gdk_font_load ("-misc-fixed-medium-r-*-*-*-140-*-*-*-*-*-*"); /* Realizing a widget creates a window for it, * * ready for us to insert some text */ gtk_widget_realize (text); /* Freeze the text widget, ready for multiple updates */ gtk_text_freeze (GTK_TEXT (text)); /* Insert some colored text */ gtk_text_insert (GTK_TEXT (text), NULL, &text->style->black, NULL, "Supports ", -1); gtk_text_insert (GTK_TEXT (text), NULL, &color, NULL, "colored ", -1); gtk_text_insert (GTK_TEXT (text), NULL, &text->style->black, NULL, "text and different ", -1); gtk_text_insert (GTK_TEXT (text), fixed_font, &text->style->black, NULL, "fonts\n\n", -1); /* Load the file text.c into the text window */ infile = fopen("text.c", "r"); if (infile) { char buffer[1024]; int nchars; while (1) { nchars = fread(buffer, 1, 1024, infile); gtk_text_insert (GTK_TEXT (text), fixed_font, NULL, NULL, buffer, nchars); if (nchars < 1024) break; } fclose (infile); } /* Thaw the text widget, allowing the updates to become visible */ gtk_text_thaw (GTK_TEXT (text)); hbox = gtk_hbutton_box_new (); gtk_box_pack_start (GTK_BOX (box2), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); check = gtk_check_button_new_with_label("Editable"); gtk_box_pack_start (GTK_BOX (hbox), check, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT(check), "toggled", GTK_SIGNAL_FUNC(text_toggle_editable), text); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), TRUE); gtk_widget_show (check); check = gtk_check_button_new_with_label("Wrap Words"); gtk_box_pack_start (GTK_BOX (hbox), check, FALSE, TRUE, 0); gtk_signal_connect (GTK_OBJECT(check), "toggled", GTK_SIGNAL_FUNC(text_toggle_word_wrap), text); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), FALSE); gtk_widget_show (check); separator = gtk_hseparator_new (); gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0); gtk_widget_show (separator); box2 = gtk_vbox_new (FALSE, 10); gtk_container_set_border_width (GTK_CONTAINER (box2), 10); gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0); gtk_widget_show (box2); button = gtk_button_new_with_label ("close"); gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC(close_application), NULL); gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); gtk_widget_set_flags (button, GTK_CAN_DEFAULT); gtk_widget_grab_default (button); gtk_widget_show (button); gtk_widget_show (window); gtk_main (); return(0); }
GtkWidget* create_window1 (void) { GtkWidget *window1; GtkWidget *table1; GtkWidget *table3; GtkWidget *table5; GtkWidget *button4; GtkWidget *popupbutton; GtkWidget *label4; GtkWidget *reference_button; GtkWidget *hseparator1; GtkWidget *table9; GtkWidget *label8; GtkWidget *entry1; GtkWidget *button3; GtkWidget *button1; GtkWidget *hseparator2; GtkWidget *table10; GtkWidget *frame8; GtkWidget *scrolledwindow8; GtkWidget *clist1; GtkWidget *label9; GtkWidget *myNotebook; GtkWidget *scrolledwindow12; GtkWidget *text1; GtkWidget *label57; GtkTooltips *tooltips; tooltips = gtk_tooltips_new (); window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_object_set_data (GTK_OBJECT (window1), "window1", window1); gtk_widget_set_usize (window1, 320, 240); gtk_window_set_title (GTK_WINDOW (window1), _("mydict")); table1 = gtk_table_new (5, 1, FALSE); gtk_widget_ref (table1); gtk_object_set_data_full (GTK_OBJECT (window1), "table1", table1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (table1); gtk_container_add (GTK_CONTAINER (window1), table1); gtk_container_set_border_width (GTK_CONTAINER (table1), 2); table3 = gtk_table_new (1, 1, FALSE); gtk_widget_ref (table3); gtk_object_set_data_full (GTK_OBJECT (window1), "table3", table3, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (table3); gtk_table_attach (GTK_TABLE (table1), table3, 0, 1, 4, 5, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0); table5 = gtk_table_new (1, 4, FALSE); gtk_widget_ref (table5); gtk_object_set_data_full (GTK_OBJECT (window1), "table5", table5, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (table5); gtk_table_attach (GTK_TABLE (table3), table5, 0, 1, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0); button4 = gtk_button_new_with_label (_(" Quit ")); gtk_widget_ref (button4); gtk_object_set_data_full (GTK_OBJECT (window1), "button4", button4, (GtkDestroyNotify) gtk_widget_unref); // gtk_widget_show (button4); gtk_table_attach (GTK_TABLE (table5), button4, 0, 1, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_tooltips_set_tip (tooltips, button4, _("Give me comments"), NULL); popupbutton = gtk_button_new_with_label (_("Popup Recite")); gtk_widget_ref (popupbutton); gtk_object_set_data_full (GTK_OBJECT (window1), "popupbutton", popupbutton, (GtkDestroyNotify) gtk_widget_unref); // gtk_widget_show (popupbutton); gtk_table_attach (GTK_TABLE (table5), popupbutton, 3, 4, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); label4 = gtk_label_new (_(" MyDict , Powered by brains. ")); gtk_widget_ref (label4); gtk_object_set_data_full (GTK_OBJECT (window1), "label4", label4, (GtkDestroyNotify) gtk_widget_unref); // gtk_widget_show (label4); gtk_table_attach (GTK_TABLE (table5), label4, 2, 3, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label4), 0, 0.5); gtk_misc_set_padding (GTK_MISC (label4), 0, 7); reference_button = gtk_button_new_with_label (_("Reference")); gtk_widget_ref (reference_button); gtk_object_set_data_full (GTK_OBJECT (window1), "reference_button", reference_button, (GtkDestroyNotify) gtk_widget_unref); // gtk_widget_show (reference_button); gtk_table_attach (GTK_TABLE (table5), reference_button, 1, 2, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_container_set_border_width (GTK_CONTAINER (reference_button), 1); hseparator1 = gtk_hseparator_new (); gtk_widget_ref (hseparator1); gtk_object_set_data_full (GTK_OBJECT (window1), "hseparator1", hseparator1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (hseparator1); gtk_table_attach (GTK_TABLE (table1), hseparator1, 0, 1, 0, 1, (GtkAttachOptions) (GTK_EXPAND), (GtkAttachOptions) (0), 0, 0); table9 = gtk_table_new (1, 4, FALSE); gtk_widget_ref (table9); gtk_object_set_data_full (GTK_OBJECT (window1), "table9", table9, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (table9); gtk_table_attach (GTK_TABLE (table1), table9, 0, 1, 1, 2, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0); label8 = gtk_label_new (_(" What is: ")); gtk_widget_ref (label8); gtk_object_set_data_full (GTK_OBJECT (window1), "label8", label8, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (label8); gtk_table_attach (GTK_TABLE (table9), label8, 0, 1, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label8), 0, 0.5); gtk_misc_set_padding (GTK_MISC (label8), 0, 5); entry1 = gtk_entry_new (); gtk_widget_ref (entry1); gtk_object_set_data_full (GTK_OBJECT (window1), "entry1", entry1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (entry1); gtk_table_attach (GTK_TABLE (table9), entry1, 1, 2, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_tooltips_set_tip (tooltips, entry1, _("Click Right button to clear the entry"), NULL); button3 = gtk_button_new_with_label (_(" Search ")); gtk_widget_ref (button3); gtk_object_set_data_full (GTK_OBJECT (window1), "button3", button3, (GtkDestroyNotify) gtk_widget_unref); // gtk_widget_show (button3); gtk_table_attach (GTK_TABLE (table9), button3, 2, 3, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_tooltips_set_tip (tooltips, button3, _("Look up "), NULL); button1 = gtk_button_new_with_label (_("Add")); gtk_widget_ref (button1); gtk_object_set_data_full (GTK_OBJECT (window1), "button1", button1, (GtkDestroyNotify) gtk_widget_unref); // gtk_widget_show (button1); gtk_table_attach (GTK_TABLE (table9), button1, 3, 4, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_container_set_border_width (GTK_CONTAINER (button1), 2); gtk_tooltips_set_tip (tooltips, button1, _("Need to remember"), NULL); hseparator2 = gtk_hseparator_new (); gtk_widget_ref (hseparator2); gtk_object_set_data_full (GTK_OBJECT (window1), "hseparator2", hseparator2, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (hseparator2); gtk_table_attach (GTK_TABLE (table1), hseparator2, 0, 1, 2, 3, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0); /* */ table10 = gtk_table_new (1, 2, FALSE); gtk_widget_ref (table10); gtk_object_set_data_full (GTK_OBJECT (window1), "table10", table10, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (table10); gtk_table_attach (GTK_TABLE (table1), table10, 0, 1, 3, 4, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0); frame8 = gtk_frame_new (_("Relative Words")); gtk_widget_ref (frame8); gtk_object_set_data_full (GTK_OBJECT (window1), "frame8", frame8, (GtkDestroyNotify) gtk_widget_unref); // gtk_widget_show (frame8); gtk_table_attach (GTK_TABLE (table10), frame8, 1, 2, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0); gtk_widget_set_usize (frame8, 130, -2); gtk_container_set_border_width (GTK_CONTAINER (frame8), 1); gtk_frame_set_label_align (GTK_FRAME (frame8), 0.61, 0.5); scrolledwindow8 = gtk_scrolled_window_new (NULL, NULL); gtk_widget_ref (scrolledwindow8); gtk_object_set_data_full (GTK_OBJECT (window1), "scrolledwindow8", scrolledwindow8, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (scrolledwindow8); gtk_container_add (GTK_CONTAINER (frame8), scrolledwindow8); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow8), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); clist1 = gtk_clist_new (1); gtk_widget_ref (clist1); gtk_object_set_data_full (GTK_OBJECT (window1), "clist1", clist1, (GtkDestroyNotify) gtk_widget_unref); // gtk_widget_show (clist1); gtk_container_add (GTK_CONTAINER (scrolledwindow8), clist1); gtk_clist_set_column_width (GTK_CLIST (clist1), 0, 80); gtk_clist_column_titles_hide (GTK_CLIST (clist1)); gtk_clist_set_shadow_type (GTK_CLIST (clist1), GTK_SHADOW_ETCHED_IN); label9 = gtk_label_new (_("label9")); gtk_widget_ref (label9); gtk_object_set_data_full (GTK_OBJECT (window1), "label9", label9, (GtkDestroyNotify) gtk_widget_unref); // gtk_widget_show (label9); gtk_clist_set_column_widget (GTK_CLIST (clist1), 0, label9); myNotebook = gtk_notebook_new (); gtk_widget_ref (myNotebook); gtk_object_set_data_full (GTK_OBJECT (window1), "myNotebook", myNotebook, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (myNotebook); gtk_table_attach (GTK_TABLE (table10), myNotebook, 0, 1, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0); gtk_notebook_set_scrollable (GTK_NOTEBOOK (myNotebook), TRUE); scrolledwindow12 = gtk_scrolled_window_new (NULL, NULL); gtk_widget_ref (scrolledwindow12); gtk_object_set_data_full (GTK_OBJECT (window1), "scrolledwindow12", scrolledwindow12, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (scrolledwindow12); gtk_container_add (GTK_CONTAINER (myNotebook), scrolledwindow12); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow12), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); /* */ text1 = gtk_text_new (NULL, NULL); gtk_widget_ref (text1); gtk_object_set_data_full (GTK_OBJECT (window1), "text1", text1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (text1); gtk_container_add (GTK_CONTAINER (scrolledwindow12), text1); gtk_text_insert (GTK_TEXT (text1), NULL, NULL, NULL, _("\nWelcome to gnuDict framework - mydict-client Gtk version\n\n\n\n\n\nNow check the plugins ......."), -1); label57 = gtk_label_new (_("Welcome to mydict")); gtk_widget_ref (label57); gtk_object_set_data_full (GTK_OBJECT (window1), "label57", label57, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (label57); gtk_notebook_set_tab_label (GTK_NOTEBOOK (myNotebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (myNotebook), 0), label57); gtk_signal_connect (GTK_OBJECT (window1), "destroy", GTK_SIGNAL_FUNC (on_window1_destroy), NULL); gtk_signal_connect (GTK_OBJECT (button4), "clicked", GTK_SIGNAL_FUNC (on_button4_clicked), NULL); gtk_signal_connect (GTK_OBJECT (popupbutton), "clicked", GTK_SIGNAL_FUNC (on_popupbutton_clicked), NULL); gtk_signal_connect (GTK_OBJECT (reference_button), "clicked", GTK_SIGNAL_FUNC (on_reference_button_clicked), NULL); gtk_signal_connect (GTK_OBJECT (entry1), "key_press_event", GTK_SIGNAL_FUNC (on_entry1_key_press_event), NULL); gtk_signal_connect (GTK_OBJECT (entry1), "button_press_event", GTK_SIGNAL_FUNC (on_entry1_button_press_event), NULL); gtk_signal_connect (GTK_OBJECT (button3), "clicked", GTK_SIGNAL_FUNC (on_button3_clicked), NULL); gtk_signal_connect (GTK_OBJECT (button1), "clicked", GTK_SIGNAL_FUNC (on_button1_clicked), NULL); gtk_signal_connect (GTK_OBJECT (clist1), "select_row", GTK_SIGNAL_FUNC (on_clist1_select_row), NULL); gtk_signal_connect (GTK_OBJECT (clist1), "key_release_event", GTK_SIGNAL_FUNC (on_clist1_key_release_event), clist1); gtk_signal_connect (GTK_OBJECT (myNotebook), "button_release_event", GTK_SIGNAL_FUNC (on_myNotebook_button_press_event), NULL); gtk_object_set_data (GTK_OBJECT (window1), "tooltips", tooltips); gtk_widget_grab_focus(entry1); return window1; }
void about_dialog (gpointer data) { GtkWidget * tempwid, * notebook, * box, * label, * view, * vscroll, * dialog; char *tempstr, *temp1str, *no_license_agreement, *str, buf[255], *share_dir; size_t len; FILE * fd; #if GTK_MAJOR_VERSION > 1 GtkTextBuffer * textbuf; GtkTextIter iter; gint textlen; #endif share_dir = gftp_get_share_dir (); no_license_agreement = g_strdup_printf (_("Cannot find the license agreement file COPYING. Please make sure it is in either %s or in %s"), BASE_CONF_DIR, share_dir); #if GTK_MAJOR_VERSION == 1 dialog = gtk_dialog_new (); gtk_window_set_title (GTK_WINDOW (dialog), _("About gFTP")); gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 5); gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (dialog)->action_area), TRUE); #else dialog = gtk_dialog_new_with_buttons (_("About gFTP"), NULL, 0, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL); #endif gtk_window_set_wmclass (GTK_WINDOW(dialog), "about", "gFTP"); gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 10); gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 5); gtk_widget_realize (dialog); if (gftp_icon != NULL) { gdk_window_set_icon (dialog->window, NULL, gftp_icon->pixmap, gftp_icon->bitmap); gdk_window_set_icon_name (dialog->window, gftp_version); } notebook = gtk_notebook_new (); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, TRUE, TRUE, 0); gtk_widget_show (notebook); box = gtk_vbox_new (TRUE, 5); gtk_container_border_width (GTK_CONTAINER (box), 10); gtk_widget_show (box); tempwid = toolbar_pixmap (dialog, "gftp-logo.xpm"); gtk_box_pack_start (GTK_BOX (box), tempwid, FALSE, FALSE, 0); gtk_widget_show (tempwid); tempstr = g_strdup_printf (_("%s\nCopyright (C) 1998-2007 Brian Masney <*****@*****.**>\nOfficial Homepage: http://www.gftp.org/\n"), gftp_version); str = _("Translated by"); if (strcmp (str, "Translated by") != 0) { tempstr = g_realloc (tempstr, (gulong) (strlen (tempstr) + strlen (str) + 1)); strcat (tempstr, str); } tempwid = gtk_label_new (tempstr); g_free (tempstr); gtk_box_pack_start (GTK_BOX (box), tempwid, FALSE, FALSE, 0); gtk_widget_show (tempwid); label = gtk_label_new (_("About")); gtk_widget_show (label); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), box, label); box = gtk_vbox_new (FALSE, 5); gtk_container_border_width (GTK_CONTAINER (box), 10); gtk_widget_show (box); tempwid = gtk_table_new (1, 2, FALSE); gtk_box_pack_start (GTK_BOX (box), tempwid, TRUE, TRUE, 0); gtk_widget_show (tempwid); #if GTK_MAJOR_VERSION == 1 view = gtk_text_new (NULL, NULL); gtk_text_set_editable (GTK_TEXT (view), FALSE); gtk_text_set_word_wrap (GTK_TEXT (view), TRUE); gtk_table_attach (GTK_TABLE (tempwid), view, 0, 1, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0); gtk_widget_show (view); vscroll = gtk_vscrollbar_new (GTK_TEXT (view)->vadj); gtk_table_attach (GTK_TABLE (tempwid), vscroll, 1, 2, 0, 1, GTK_FILL, GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 0); gtk_widget_show (vscroll); #else view = gtk_text_view_new (); gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE); gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE); gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD); vscroll = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (vscroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add (GTK_CONTAINER (vscroll), view); gtk_widget_show (view); gtk_table_attach (GTK_TABLE (tempwid), vscroll, 0, 1, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0); gtk_widget_show (vscroll); textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); #endif label = gtk_label_new (_("License Agreement")); gtk_widget_show (label); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), box, label); #if GTK_MAJOR_VERSION == 1 tempwid = gtk_button_new_with_label (_(" Close ")); GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid, FALSE, FALSE, 0); gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), GTK_OBJECT (dialog)); gtk_widget_grab_default (tempwid); gtk_widget_show (tempwid); #else g_signal_connect_swapped (GTK_OBJECT (dialog), "response", G_CALLBACK (gtk_widget_destroy), GTK_OBJECT (dialog)); #endif tempstr = g_strconcat ("/usr/share/common-licenses/GPL", NULL); if (access (tempstr, F_OK) != 0) { g_free (tempstr); temp1str = g_strconcat (share_dir, "/COPYING", NULL); tempstr = gftp_expand_path (NULL, temp1str); g_free (temp1str); if (access (tempstr, F_OK) != 0) { g_free (tempstr); tempstr = gftp_expand_path (NULL, BASE_CONF_DIR "/COPYING"); if (access (tempstr, F_OK) != 0) { #if GTK_MAJOR_VERSION == 1 gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL, no_license_agreement, -1); #else textlen = gtk_text_buffer_get_char_count (textbuf); gtk_text_buffer_get_iter_at_offset (textbuf, &iter, textlen); gtk_text_buffer_insert (textbuf, &iter, no_license_agreement, -1); #endif gtk_widget_show (dialog); return; } } } if ((fd = fopen (tempstr, "r")) == NULL) { #if GTK_MAJOR_VERSION == 1 gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL, no_license_agreement, -1); #else textlen = gtk_text_buffer_get_char_count (textbuf); gtk_text_buffer_get_iter_at_offset (textbuf, &iter, textlen); gtk_text_buffer_insert (textbuf, &iter, no_license_agreement, -1); #endif gtk_widget_show (dialog); g_free (tempstr); return; } g_free (tempstr); memset (buf, 0, sizeof (buf)); while ((len = fread (buf, 1, sizeof (buf) - 1, fd))) { buf[len] = '\0'; #if GTK_MAJOR_VERSION == 1 gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL, buf, -1); #else textlen = gtk_text_buffer_get_char_count (textbuf); gtk_text_buffer_get_iter_at_offset (textbuf, &iter, textlen); gtk_text_buffer_insert (textbuf, &iter, buf, -1); #endif } fclose (fd); gtk_widget_show (dialog); g_free (no_license_agreement); gftp_free_pixmap ("gftp-logo.xpm"); }
void InternetGo (void) { if ((ifilestuff == 0) && (inet == 0)) { shost = gtk_entry_get_text (GTK_ENTRY (connectentry1)); theaddress = atoaddr (shost); iport = atoi (gtk_entry_get_text (GTK_ENTRY (connectentry2))); gtk_widget_destroy (connectwindow); iyesno = 0; bzero ((char *) &host_addr, sizeof (host_addr)); host_addr.sin_family = AF_INET; host_addr.sin_addr.s_addr = inet_addr (inet_ntoa (*theaddress)); host_addr.sin_port = htons (iport); if ((sockfd = socket (AF_INET, SOCK_STREAM, 0)) < 0) { Message ("Unable to open socket.", 3, 0); } itheerror = connect (sockfd, (struct sockaddr *) &host_addr, sizeof (host_addr)); if (itheerror < 0) { sprintf (serrortemp, "Unable to connect to host (%s).", strerror (errno)); Message (serrortemp, 3, 0); } else { fcntl (sockfd, F_SETFL, O_NONBLOCK); biscomputer = 0; sprintf (bplayername, "%s", "unknown"); wiscomputer = 0; sprintf (wplayername, "%s", "unknown"); StatusBar (); if (ichangestuff == 0) { Play ("open.mp3", 0); } internetwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (internetwindow), "Internet window"); gtk_signal_connect (GTK_OBJECT (internetwindow), "delete_event", GTK_SIGNAL_FUNC (CloseSocket), NULL); gtk_window_set_policy (GTK_WINDOW (internetwindow), 0, 0, 1); gtk_container_border_width (GTK_CONTAINER (internetwindow), 0); gtk_widget_realize (internetwindow); internetbox1 = gtk_vbox_new (FALSE, 0); gtk_container_border_width (GTK_CONTAINER (internetbox1), 0); gtk_container_add (GTK_CONTAINER (internetwindow), internetbox1); gtk_widget_show (internetbox1); internetbox2 = gtk_hbox_new (FALSE, 0); gtk_container_border_width (GTK_CONTAINER (internetbox2), 0); gtk_box_pack_start (GTK_BOX (internetbox1), internetbox2, TRUE, TRUE, 5); gtk_widget_show (internetbox2); internetbox3 = gtk_vbox_new (FALSE, 0); gtk_container_border_width (GTK_CONTAINER (internetbox3), 0); gtk_box_pack_start (GTK_BOX (internetbox2), internetbox3, TRUE, TRUE, 0); gtk_widget_show (internetbox3); internettable1 = gtk_table_new (2, 1, FALSE); gtk_widget_show (internettable1); gtk_box_pack_start (GTK_BOX (internetbox3), internettable1, TRUE, TRUE, 0); internettable2 = gtk_table_new (2, 3, FALSE); gtk_widget_show (internettable2); gtk_box_pack_start (GTK_BOX (internetbox3), internettable2, TRUE, TRUE, 0); text = gtk_text_new (NULL, NULL); gtk_widget_set_usize (text, 535, 266); gtk_text_set_editable (GTK_TEXT (text), FALSE); gtk_table_attach (GTK_TABLE (internettable1), text, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 5, 0); gtk_widget_show (text); vscrollbar = gtk_vscrollbar_new (GTK_TEXT (text)->vadj); adj = (GTK_TEXT (text))->vadj; gtk_table_attach (GTK_TABLE (internettable1), vscrollbar, 1, 2, 0, 1, GTK_FILL, GTK_EXPAND | GTK_FILL, 5, 0); gtk_widget_show (vscrollbar); cmap = gdk_colormap_get_system (); color.red = 0xffff; color.green = 0; color.blue = 0; if (!gdk_color_alloc (cmap, &color)) { Message ("Could not allocate color.", 3, 0); } gtk_widget_realize (text); wrapcheck = gtk_check_button_new_with_label ("wrap"); gtk_table_attach (GTK_TABLE (internettable2), wrapcheck, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 5, 10); gtk_signal_connect (GTK_OBJECT (wrapcheck), "toggled", GTK_SIGNAL_FUNC (ToggleWrap), text); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (wrapcheck), FALSE); gtk_widget_show (wrapcheck); internetentry = gtk_entry_new_with_max_length (50); gtk_signal_connect (GTK_OBJECT (internetentry), "activate", GTK_SIGNAL_FUNC (SendData), NULL); gtk_table_attach (GTK_TABLE (internettable2), internetentry, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 5, 10); gtk_widget_grab_focus (internetentry); gtk_widget_show (internetentry); inetsep = gtk_hseparator_new (); gtk_table_attach (GTK_TABLE (internettable2), inetsep, 0, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (inetsep); inetbutton = gtk_button_new_with_label ("Disconnect"); gtk_signal_connect (GTK_OBJECT (inetbutton), "clicked", GTK_SIGNAL_FUNC (CloseSocket), NULL); GTK_WIDGET_SET_FLAGS (inetbutton, GTK_CAN_DEFAULT); gtk_window_set_default (GTK_WINDOW (internetwindow), inetbutton); gtk_table_attach (GTK_TABLE (internettable2), inetbutton, 0, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 2, 2); gtk_widget_show (inetbutton); gtk_widget_show (internetwindow); inet = 1; ReceiveData (); } } }
gint display_about_dbox() { GtkWidget *dbox; gpointer user_data; FILE *fd; gchar buffer[MAXCHARS]; GdkFont *fixed_font; GtkWidget *text; gchar tempstr[MAXCHARS]; dbox = create_about_dbox(); /* Set text */ user_data = gtk_object_get_data(GTK_OBJECT(dbox), "text1"); text = GTK_WIDGET(user_data); gtk_text_freeze(GTK_TEXT (text)); gtk_editable_delete_text(GTK_EDITABLE(text), 0, -1); strcpy(buffer, inst_paths.base_dir); // retrieve base path strcat(buffer, SHARE_DIR); // strcat(buffer, DIR_SEPARATOR); #if defined(__LINUX__) strcat(buffer, "COPYING"); #elif defined(__WIN32__) strcat(buffer, "Copying.txt"); #endif if(access(buffer, F_OK) == 0 ) { #if defined(__LINUX__) fixed_font = gdk_font_load ("-misc-clean-medium-r-*-*-*-140-*-*-*-*-*-*"); #elif defined(__WIN32__) fixed_font = gdk_font_load ("-adobe-courier-medium-r-normal--12-120-75-75-p-70-iso8859-1"); #endif if( (fd=fopen (buffer, "r")) != NULL) { memset (buffer, 0, sizeof(buffer)); while(fread (buffer, 1, sizeof(buffer)-1, fd)) { process_buffer(buffer); gtk_text_insert (GTK_TEXT (text), fixed_font, NULL, NULL, buffer, strlen (buffer)); memset (buffer, 0, sizeof(buffer)); } fclose (fd); } } gtk_text_thaw(GTK_TEXT (text)); /* Set label */ user_data = gtk_object_get_data(GTK_OBJECT(dbox), "label5"); #ifdef HAVE_LIBTIFFEP g_snprintf(tempstr, sizeof(tempstr), "* TILP version %s (cable=%s, tiffep=%s)", GTKTIEMU_VERSION, ticable_get_version(), tiffep_get_version()); #else g_snprintf(tempstr, sizeof(tempstr), "* TILP version %s (%s %s)", GTKTIEMU_VERSION, ticable_get_version(), "NA"); #endif gtk_label_set_text(GTK_LABEL(user_data), tempstr); /* Set pixmap */ user_data = gtk_object_get_data(GTK_OBJECT(dbox), "pixmap2"); #if 0 /* buggy code -- avoid segfault ... */ GtkWidget *tmp_pixmapwid = GTK_WIDGET(user_data); GdkPixmap *pixmap; GdkBitmap *mask; GtkStyle *style; FILE *f; gchar buffer[MAXCHARS]; return; /* Create the base filename */ strcpy(buffer, inst_paths.base_dir); // retrieve base path strcat(buffer, SHARE_DIR); // strcat(buffer, DIR_SEPARATOR); #if defined(__LINUX__) strcat(buffer, "logo.jpg"); #elif defined(__WIN32__) strcat(buffer, "logo.jpg"); #endif DISPLAY("logo: <%s>\n", buffer); /* Try to access the file */ if(access(buffer, F_OK) == 0 ) { /* Open and load file */ f = fopen(buffer, "rb"); if(f == NULL) g_error("Unable to open the logo (logo.jpg).\n"); img.depth = 3; // > 2 colors read_jpg_format(f, &img); fclose(f); convert_bytemap_to_pixmap(&img); style = gtk_widget_get_style(widget); pixmap = gdk_pixmap_create_from_xpm_d(widget->window, &mask, &style->bg[GTK_STATE_NORMAL], (gchar **)(img.pixmap)); gtk_pixmap_set(GTK_PIXMAP(tmp_pixmapwid), pixmap, mask); } else g_warning("Unable to open the logo (logo.jpg).\n"); #endif gtk_widget_show_all(dbox); return 0; }
bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value, const wxPoint &pos, const wxSize &size, long style, const wxValidator& validator, const wxString &name ) { m_needParent = true; m_acceptsFocus = true; if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, validator, name )) { wxFAIL_MSG( wxT("wxTextCtrl creation failed") ); return false; } m_vScrollbarVisible = false; bool multi_line = (style & wxTE_MULTILINE) != 0; if (multi_line) { // create our control ... m_text = gtk_text_new( NULL, NULL ); // ... and put into the upper left hand corner of the table bool bHasHScrollbar = false; m_widget = gtk_table_new(bHasHScrollbar ? 2 : 1, 2, FALSE); GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); gtk_table_attach( GTK_TABLE(m_widget), m_text, 0, 1, 0, 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_FILL | GTK_EXPAND | GTK_SHRINK), 0, 0); // always wrap words gtk_text_set_word_wrap( GTK_TEXT(m_text), TRUE ); // finally, put the vertical scrollbar in the upper right corner m_vScrollbar = gtk_vscrollbar_new( GTK_TEXT(m_text)->vadj ); GTK_WIDGET_UNSET_FLAGS( m_vScrollbar, GTK_CAN_FOCUS ); gtk_table_attach(GTK_TABLE(m_widget), m_vScrollbar, 1, 2, 0, 1, GTK_FILL, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), 0, 0); } else { // a single-line text control: no need for scrollbars m_widget = m_text = gtk_entry_new(); } m_parent->DoAddChild( this ); m_focusWidget = m_text; PostCreation(size); if (multi_line) gtk_widget_show(m_text); if (multi_line) { gtk_signal_connect(GTK_OBJECT(GTK_TEXT(m_text)->vadj), "changed", (GtkSignalFunc) gtk_scrollbar_changed_callback, (gpointer) this ); // only initialize gs_gtk_text_draw once, starting from the next the // klass::draw will already be wxgtk_text_draw if ( !gs_gtk_text_draw ) { GtkDrawCallback& draw = GTK_WIDGET_CLASS(GTK_OBJECT(m_text)->klass)->draw; gs_gtk_text_draw = draw; draw = wxgtk_text_draw; } } if (!value.empty()) { #if !GTK_CHECK_VERSION(1, 2, 0) // if we don't realize it, GTK 1.0.6 dies with a SIGSEGV in // gtk_editable_insert_text() gtk_widget_realize(m_text); #endif // GTK 1.0 gint tmp = 0; #if wxUSE_UNICODE wxWX2MBbuf val = value.mbc_str(); gtk_editable_insert_text( GTK_EDITABLE(m_text), val, strlen(val), &tmp ); #else gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.length(), &tmp ); #endif if (multi_line) { // Bring editable's cursor uptodate. Bug in GTK. SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) )); } } if (style & wxTE_PASSWORD) { if (!multi_line) gtk_entry_set_visibility( GTK_ENTRY(m_text), FALSE ); } if (style & wxTE_READONLY) { if (!multi_line) gtk_entry_set_editable( GTK_ENTRY(m_text), FALSE ); } else { if (multi_line) gtk_text_set_editable( GTK_TEXT(m_text), 1 ); } // We want to be notified about text changes. gtk_signal_connect( GTK_OBJECT(m_text), "changed", GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); m_cursor = wxCursor( wxCURSOR_IBEAM ); wxTextAttr attrDef(GetForegroundColour(), GetBackgroundColour(), GetFont()); SetDefaultStyle( attrDef ); return true; }
void selection_received (GtkWidget *widget, GtkSelectionData *data) { int position; int i; SelType seltype; char *str; if (data->length < 0) { g_print("Error retrieving selection\n"); return; } seltype = SEL_TYPE_NONE; for (i=0; i<LAST_SEL_TYPE; i++) { if (seltypes[i] == data->type) { seltype = i; break; } } if (seltype == SEL_TYPE_NONE) { char *name = gdk_atom_name (data->type); g_print("Don't know how to handle type: %s\n", name?name:"<unknown>"); return; } if (selection_string != NULL) g_string_free (selection_string, TRUE); selection_string = g_string_new (NULL); gtk_text_freeze (GTK_TEXT (selection_text)); gtk_text_set_point (GTK_TEXT (selection_text), 0); gtk_text_forward_delete (GTK_TEXT (selection_text), gtk_text_get_length (GTK_TEXT (selection_text))); position = 0; while (position < data->length) { switch (seltype) { case ATOM: str = stringify_atom (data->data, &position); break; case COMPOUND_TEXT: case STRING: case TEXT: str = stringify_text (data->data, &position); break; case BITMAP: case DRAWABLE: case PIXMAP: case WINDOW: case COLORMAP: str = stringify_xid (data->data, &position); break; case INTEGER: case PIXEL: str = stringify_integer (data->data, &position); break; case SPAN: str = stringify_span (data->data, &position); break; default: { char *name = gdk_atom_name (data->type); g_print("Can't convert type %s to string\n", name?name:"<unknown>"); position = data->length; continue; } } gtk_text_insert (GTK_TEXT (selection_text), NULL, &selection_text->style->black, NULL, str, -1); gtk_text_insert (GTK_TEXT (selection_text), NULL, &selection_text->style->black, NULL, "\n", -1); g_string_append (selection_string, str); g_free (str); } gtk_text_thaw (GTK_TEXT (selection_text)); }
static void cb_encrypt(GtkWidget *w, gpointer p) { GtkWidget *pass_entry; GtkWidget *warn_w; FILE *pgpin; FILE *pgpout; FILE *pgperr; static gchar sys_buf[] = "pgpe -catfq +batchmode"; gchar tmpbuf[1024]; note_data *note; g_return_if_fail(p != NULL); g_return_if_fail(GNOME_IS_DIALOG(p)); if (selected_node == NULL) { warn_w = gnome_warning_dialog_parented( _("Select a note first!"), yank_root_win(NULL)); gtk_window_set_modal(GTK_WINDOW(warn_w), TRUE); return; } ask_commit_changes(); note = (note_data *) gtk_ctree_node_get_row_data( GTK_CTREE(note_tree), GTK_CTREE_NODE(selected_node)); if (!note->text || !strlen(note->text)) { warn_w = gnome_warning_dialog_parented(_("Nothing to encrypt!"), yank_root_win(NULL)); gtk_window_set_modal(GTK_WINDOW(warn_w), TRUE); return; } pass_entry = gtk_object_get_user_data(GTK_OBJECT(p)); setenv("PGPPASSFD", "0", 1); run_pgp(sys_buf, &pgpin, &pgpout, &pgperr); /*Execute PGP*/ if(pgpin && pgpout) { fprintf(pgpin, "%s\n", gtk_entry_get_text(GTK_ENTRY(pass_entry))); /*Output buffer to PGP:*/ fwrite(note->text, sizeof(gchar), strlen(note->text), pgpin); fclose(pgpin); gtk_text_freeze(GTK_TEXT(text_entry)); gtk_editable_delete_text(GTK_EDITABLE(text_entry), 0, gtk_text_get_length(GTK_TEXT(text_entry))); /*Now, read the result back from PGP:*/ do { fgets(tmpbuf, sizeof(tmpbuf), pgpout); if (!feof(pgpout)) { gtk_text_insert(GTK_TEXT(text_entry), NULL, NULL, NULL, tmpbuf, strlen(tmpbuf)); } } while (!feof(pgpout)); gtk_text_thaw(GTK_TEXT(text_entry)); fclose(pgpout); } unsetenv("PGPPASSFD"); }
static gint hi_dialog_run(GtkWidget *parent, int itemid) { history_item_dlg hidlg_actual = { 0 }; history_item_dlg *hidlg = &hidlg_actual; GtkWidget *vbox, *button; NetResult *result; hidlg->itemid = itemid; result = hi_request_run(hidlg, itemid); if (result == NULL) return 0; hidlg->win = jam_dialog_new(parent, "History Item", 300, 300); geometry_tie(hidlg->win, GEOM_HISTORY_ITEM); g_signal_connect(G_OBJECT(hidlg->win), "destroy", G_CALLBACK(gtk_main_quit), NULL); vbox = gtk_vbox_new(FALSE, 5); { GtkWidget *hbox, *scroll; hbox = gtk_hbox_new(FALSE, 5); { gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new("Subject:"), FALSE, FALSE, 0); hidlg->esubject = gtk_entry_new(); gtk_widget_set_usize(hidlg->esubject, 100, -1); /* usize is just the minimum size... */ gtk_box_pack_start(GTK_BOX(hbox), hidlg->esubject, TRUE, TRUE, 0); } gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); hbox = gtk_hbox_new(FALSE, 5); { gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new("Date:"), FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), hi_dialog_date_hbox(hidlg), FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new("Time:"), FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), hi_dialog_time_hbox(hidlg), FALSE, FALSE, 0); hidlg->security.type = conf.defaultsecurity; hidlg->secmgr = secmgr_new(&hidlg->security); gtk_box_pack_end(GTK_BOX(hbox), hidlg->secmgr, FALSE, FALSE, 0); gtk_box_pack_end(GTK_BOX(hbox), gtk_label_new("Security:"), FALSE, FALSE, 0); } gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); scroll = gtk_scrolled_window_new(NULL, NULL); { gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); hidlg->eentry = gtk_text_new(NULL, NULL); /* fixme gtkspell gtkspell_attach(GTK_TEXT(hidlg->eentry)); */ gtk_text_set_editable(GTK_TEXT(hidlg->eentry), TRUE); gtk_text_set_word_wrap(GTK_TEXT(hidlg->eentry), TRUE); gtk_container_add(GTK_CONTAINER(scroll), hidlg->eentry); } gtk_box_pack_start(GTK_BOX(vbox), scroll, TRUE, TRUE, 0); hidlg->metamgr = metamgr_new(GTK_BOX(vbox)); gtk_box_pack_end(GTK_BOX(vbox), hidlg->metamgr, FALSE, FALSE, 0); } jam_dialog_set_contents(hidlg->win, vbox); button = gtk_button_new_with_label(" Save Changes "); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(hi_save_cb), (gpointer) hidlg); jam_dialog_add_button(hidlg->win, button); button = gtk_button_new_with_label(" Delete "); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(hi_delete_cb), (gpointer) hidlg); jam_dialog_add_button(hidlg->win, button); jam_dialog_add_close(hidlg->win); hi_load_result(hidlg, result); gtk_widget_realize(hidlg->win); gtk_widget_realize(hidlg->secmgr); gtk_widget_show(hidlg->win); gtk_main(); return 0; }
static void cb_decrypt(GtkWidget *w, gpointer p) { GtkWidget *pass_entry; GtkWidget *warn_w; FILE *pgpin; FILE *pgpout; FILE *pgperr; static gchar sys_buf[] = "pgpv -qzd +batchmode +force -o - %s"; gchar tmpbuf[1024]; gchar *tmpfname; gchar *tmpcmd; note_data *note; pid_t pgp_pid; gint fd; g_return_if_fail(p != NULL); g_return_if_fail(GNOME_IS_DIALOG(p)); if (selected_node == NULL) { warn_w = gnome_warning_dialog_parented( _("Select a note first!"), yank_root_win(NULL)); gtk_window_set_modal(GTK_WINDOW(warn_w), TRUE); return; } ask_commit_changes(); note = (note_data *) gtk_ctree_node_get_row_data( GTK_CTREE(note_tree), GTK_CTREE_NODE(selected_node)); if (!note->text || !strlen(note->text)) { warn_w = gnome_warning_dialog_parented(_("Nothing to decrypt!"), yank_root_win(NULL)); gtk_window_set_modal(GTK_WINDOW(warn_w), TRUE); return; } tmpfname = tmpnam(NULL); if (tmpfname == NULL) { warn_w = gnome_warning_dialog_parented(_("Can't create tmp filename!"), yank_root_win(NULL)); gtk_window_set_modal(GTK_WINDOW(warn_w), TRUE); return; } fd = safe_open(tmpfname, O_CREAT | O_EXCL | O_WRONLY); if (fd == -1) { warn_w = gnome_warning_dialog_parented(_("Can't open tmp file!"), yank_root_win(NULL)); gtk_window_set_modal(GTK_WINDOW(warn_w), TRUE); return; } write(fd, note->text, strlen(note->text)); close(fd); tmpcmd = g_strdup_printf(sys_buf, tmpfname); pass_entry = gtk_object_get_user_data(GTK_OBJECT(p)); setenv("PGPPASSFD", "0", 1); pgp_pid = run_pgp(tmpcmd, &pgpin, &pgpout, &pgperr); if (pgp_pid == -1) { warn_w = gnome_warning_dialog_parented(_("Error while running pgp!"), yank_root_win(NULL)); gtk_window_set_modal(GTK_WINDOW(warn_w), TRUE); unsetenv("PGPPASSFD"); unlink(tmpfname); g_free(tmpcmd); return; } if (pgpin && pgpout) { fprintf(pgpin, "%s\n", gtk_entry_get_text(GTK_ENTRY(pass_entry))); fwrite(note->text, sizeof (gchar), strlen(note->text), pgpin); fclose(pgpin); gtk_text_freeze(GTK_TEXT(text_entry)); gtk_editable_delete_text(GTK_EDITABLE(text_entry), 0, gtk_text_get_length(GTK_TEXT(text_entry))); do { fgets(tmpbuf, sizeof (tmpbuf), pgpout); if (!feof(pgpout)) { gtk_text_insert(GTK_TEXT(text_entry), NULL, NULL, NULL, tmpbuf, strlen(tmpbuf)); } } while (!feof(pgpout)); gtk_text_thaw(GTK_TEXT(text_entry)); fclose(pgpout); fclose(pgperr); if ((gtk_text_get_length(GTK_TEXT(text_entry)) == 0) && note->text) { warn_w = gnome_warning_dialog_parented(_("Pgp didn't return any\ text. Maybe your're using the wrong password?"), yank_root_win(NULL)); gtk_window_set_modal(GTK_WINDOW(warn_w), TRUE); gtk_text_insert(GTK_TEXT(text_entry), NULL, NULL, NULL, note->text, strlen(note->text)); }
void start(void* v) { GtkWidget *scrolled_win, *tree, *hpanes, *vbox, *menu, *list; /*static gchar *itemnames[] = {"One", "Two", "Three", "Four", "Five"};*/ GtkItemFactory *item_factory; GtkAccelGroup *accel_group; gint nmenu_items; gint i; GtkWidget *table; GtkWidget *name_label, *info_vbox; GtkWidget *type_label; GtkWidget *annot_label, *annot_hbox, *annot_vscroll; GtkWidget *sep1; GtkWidget *props_hbox, *props_scrollwin; GtkWidget *menu_item; gtk_init (&SFE_Globals.ArgC, &SFE_Globals.ArgV); SFE_Globals.Data = stCreateStruct("new","x-unknown/x-unknown"); SFE_Globals.Modified = 0; SFE_Globals.HideColTitles = 0; /* a generic toplevel window */ SFE_Globals.Window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(SFE_Globals.Window), "Centrallix Structure File Editor"); gtk_signal_connect (GTK_OBJECT(SFE_Globals.Window), "delete_event", GTK_SIGNAL_FUNC (gtk_main_quit), NULL); gtk_widget_set_usize(SFE_Globals.Window, 600, 350); /** Build the Open File... dialog box **/ SFE_Globals.OpenDialog = gtk_file_selection_new("Open File..."); gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(SFE_Globals.OpenDialog)->cancel_button), "clicked", (GtkSignalFunc)sfe_ui_FileOpenCancel, GTK_OBJECT(SFE_Globals.OpenDialog)); gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(SFE_Globals.OpenDialog)->ok_button), "clicked", (GtkSignalFunc)sfe_ui_FileOpenOk, GTK_OBJECT(SFE_Globals.OpenDialog)); /* vertical box organizing the menu vs. rest of app */ vbox = gtk_vbox_new(FALSE,1); gtk_container_add(GTK_CONTAINER(SFE_Globals.Window), vbox); gtk_widget_show(vbox); /* menu */ nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]); accel_group = gtk_accel_group_new(); item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group); gtk_item_factory_create_items(item_factory, nmenu_items, menu_items, NULL); gtk_window_add_accel_group(GTK_WINDOW(SFE_Globals.Window), accel_group); menu = gtk_item_factory_get_widget(item_factory, "<main>"); gtk_box_pack_start(GTK_BOX(vbox), menu, FALSE, TRUE, 0); /*menu_item = gtk_item_factory_get_widget(GTK_ITEM_FACTORY(item_factory),"/View/Column Titles"); gtk_menu_item_activate(GTK_MENU_ITEM(menu_item));*/ gtk_widget_show(menu); /* horizontal layout box organizing the treeview and the data view pane */ hpanes = gtk_hpaned_new(); gtk_container_add(GTK_CONTAINER(vbox), hpanes); gtk_container_set_border_width (GTK_CONTAINER(hpanes), 5); gtk_paned_set_gutter_size(GTK_PANED(hpanes), 16); gtk_widget_show(hpanes); /* A generic scrolled window - for the treeview. */ scrolled_win = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_widget_set_usize (scrolled_win, 150, 200); gtk_container_add (GTK_CONTAINER(hpanes), scrolled_win); gtk_widget_show (scrolled_win); /* Create the root tree and add it to the scrolled window */ tree = gtk_tree_new(); gtk_signal_connect (GTK_OBJECT(tree), "select_child", GTK_SIGNAL_FUNC(cb_select_child), tree); gtk_signal_connect (GTK_OBJECT(tree), "unselect_child", GTK_SIGNAL_FUNC(cb_unselect_child), tree); gtk_signal_connect (GTK_OBJECT(tree), "selection_changed", GTK_SIGNAL_FUNC(sfe_ui_TreeSelectionChanged), tree); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_win), tree); gtk_tree_set_selection_mode (GTK_TREE(tree), GTK_SELECTION_SINGLE); gtk_tree_set_view_mode(GTK_TREE(tree), GTK_TREE_VIEW_ITEM); gtk_widget_show (tree); SFE_Globals.TreeView = tree; /** build the item name section **/ info_vbox = gtk_vbox_new(FALSE,1); gtk_container_add(GTK_CONTAINER(hpanes), info_vbox); gtk_widget_show(info_vbox); table = gtk_table_new(3,2,FALSE); gtk_box_pack_start(GTK_BOX(info_vbox), table, FALSE, TRUE, 0); gtk_widget_show(table); name_label = gtk_label_new("Name:"); gtk_label_set_justify(GTK_LABEL(name_label), GTK_JUSTIFY_LEFT); gtk_table_attach(GTK_TABLE(table), name_label, 0, 1, 0, 1, 0, 0, 0, 0); gtk_widget_show(name_label); SFE_Globals.NameEdit = gtk_entry_new_with_max_length(63); gtk_table_attach(GTK_TABLE(table), SFE_Globals.NameEdit, 1, 2, 0, 1, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0, 0); gtk_widget_show(SFE_Globals.NameEdit); /** Item type **/ type_label = gtk_label_new("Type:"); gtk_label_set_justify(GTK_LABEL(type_label), GTK_JUSTIFY_LEFT); gtk_table_attach(GTK_TABLE(table), type_label, 0, 1, 1, 2, 0, 0, 0, 0); gtk_widget_show(type_label); SFE_Globals.TypeCombo = gtk_combo_new(); gtk_table_attach(GTK_TABLE(table), SFE_Globals.TypeCombo, 1, 2, 1, 2, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0, 8); gtk_widget_show(SFE_Globals.TypeCombo); /** Annotation/description/comments section **/ annot_label = gtk_label_new("Desc:"); gtk_label_set_justify(GTK_LABEL(annot_label), GTK_JUSTIFY_LEFT); gtk_table_attach(GTK_TABLE(table), annot_label, 0, 1, 2, 3, 0, 0, 0, 0); gtk_widget_show(annot_label); annot_hbox = gtk_hbox_new(FALSE,1); gtk_table_attach(GTK_TABLE(table), annot_hbox, 1, 2, 2, 3, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0, 0); gtk_widget_show(annot_hbox); SFE_Globals.AnnotText = gtk_text_new(NULL,NULL); gtk_text_set_editable(GTK_TEXT(SFE_Globals.AnnotText), TRUE); gtk_widget_set_usize(SFE_Globals.AnnotText, 100, 48); gtk_container_add(GTK_CONTAINER(annot_hbox), SFE_Globals.AnnotText); gtk_widget_show(SFE_Globals.AnnotText); annot_vscroll = gtk_vscrollbar_new(GTK_TEXT(SFE_Globals.AnnotText)->vadj); gtk_box_pack_end(GTK_BOX(annot_hbox), annot_vscroll, FALSE, TRUE, 0); gtk_widget_show(annot_vscroll); sep1 = gtk_hseparator_new(); gtk_box_pack_start(GTK_BOX(info_vbox), sep1, FALSE, TRUE, 8); gtk_widget_show(sep1); /** Add a columnar list box for the attributes **/ props_scrollwin = gtk_scrolled_window_new(NULL,NULL); gtk_container_add(GTK_CONTAINER(info_vbox), props_scrollwin); gtk_widget_show(props_scrollwin); SFE_Globals.AttrsCList = gtk_clist_new_with_titles(2, props_clist_titles); gtk_clist_set_selection_mode(GTK_CLIST(SFE_Globals.AttrsCList), GTK_SELECTION_SINGLE); gtk_container_add(GTK_CONTAINER(props_scrollwin), SFE_Globals.AttrsCList); gtk_widget_show(SFE_Globals.AttrsCList); gtk_signal_connect (GTK_OBJECT(SFE_Globals.AttrsCList), "select_row", GTK_SIGNAL_FUNC(sfe_ui_CListAttrSelected), SFE_Globals.AttrsCList); #if 0 /** Put some cruft in the treeview **/ for (i = 0; i < 5; i++) { GtkWidget *subtree, *item; gint j; /* Create a tree item */ item = gtk_tree_item_new_with_label (itemnames[i]); /* Add it to the parent tree */ gtk_tree_append (GTK_TREE(tree), item); gtk_widget_show (item); subtree = gtk_tree_new(); /* This is still necessary if you want these signals to be called * for the subtree's children. Note that selection_change will be * signalled for the root tree regardless. */ gtk_signal_connect (GTK_OBJECT(subtree), "select_child", GTK_SIGNAL_FUNC(cb_select_child), subtree); gtk_signal_connect (GTK_OBJECT(subtree), "unselect_child", GTK_SIGNAL_FUNC(cb_unselect_child), subtree); /* Set this item's subtree - note that you cannot do this until * AFTER the item has been added to its parent tree! */ gtk_tree_item_set_subtree (GTK_TREE_ITEM(item), subtree); for (j = 0; j < 5; j++) { GtkWidget *subitem; /* Create a subtree item, in much the same way */ subitem = gtk_tree_item_new_with_label (itemnames[j]); gtk_tree_append (GTK_TREE(subtree), subitem); gtk_widget_show (subitem); } } #endif /** Open the main window **/ gtk_widget_show (SFE_Globals.Window); /** Load any file specified on the command line **/ if (SFE_Globals.ArgC == 2 && SFE_Globals.ArgV[1]) sfeLoadFile(SFE_Globals.ArgV[1]); else sfeRebuildUI(SFE_Globals.Data, GTK_TREE(tree)); /** Create the attribute editing window **/ SFE_Globals.AttrEditWindow = sfe_ui_CreateAttrDialog(); /** Enter the event loop for GTK **/ gtk_main(); thExit(); }
/*! *\brief show crash dialog * *\param text Description *\param debug_output Output text by gdb * *\return GtkWidget * Dialog widget */ static GtkWidget *crash_dialog_show(const gchar *text, const gchar *debug_output) { GtkWidget *window1; GtkWidget *vbox1; GtkWidget *hbox1; GtkWidget *label1; GtkWidget *frame1; GtkWidget *scrolledwindow1; GtkWidget *text1; GtkWidget *hbuttonbox3; GtkWidget *hbuttonbox4; GtkWidget *button3; GtkWidget *button4; GtkWidget *button5; gchar *crash_report; window1 = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_container_set_border_width(GTK_CONTAINER(window1), 5); gtk_window_set_title(GTK_WINDOW(window1), _("Sylpheed has crashed")); gtk_window_set_position(GTK_WINDOW(window1), GTK_WIN_POS_CENTER); gtk_window_set_modal(GTK_WINDOW(window1), TRUE); gtk_window_set_default_size(GTK_WINDOW(window1), 460, 272); vbox1 = gtk_vbox_new(FALSE, 2); gtk_widget_show(vbox1); gtk_container_add(GTK_CONTAINER(window1), vbox1); hbox1 = gtk_hbox_new(FALSE, 4); gtk_widget_show(hbox1); gtk_box_pack_start(GTK_BOX(vbox1), hbox1, FALSE, TRUE, 0); gtk_container_set_border_width(GTK_CONTAINER(hbox1), 4); label1 = gtk_label_new (g_strdup_printf(_("%s.\nPlease file a bug report and include the information below."), text)); gtk_widget_show(label1); gtk_box_pack_start(GTK_BOX(hbox1), label1, TRUE, TRUE, 0); gtk_misc_set_alignment(GTK_MISC(label1), 7.45058e-09, 0.5); frame1 = gtk_frame_new(_("Debug log")); gtk_widget_show(frame1); gtk_box_pack_start(GTK_BOX(vbox1), frame1, TRUE, TRUE, 0); scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL); gtk_widget_show(scrolledwindow1); gtk_container_add(GTK_CONTAINER(frame1), scrolledwindow1); gtk_container_set_border_width(GTK_CONTAINER(scrolledwindow1), 3); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow1), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); text1 = gtk_text_new(NULL, NULL); gtk_text_set_editable(GTK_TEXT(text1), FALSE); gtk_widget_show(text1); gtk_container_add(GTK_CONTAINER(scrolledwindow1), text1); crash_report = g_strdup_printf( "Sylpheed version %s\nGTK+ version %d.%d.%d\nFeatures:%s\nOperating system: %s\nC Library: %s\n--\n%s", VERSION, gtk_major_version, gtk_minor_version, gtk_micro_version, get_compiled_in_features(), get_operating_system(), get_lib_version(), debug_output); gtk_text_insert(GTK_TEXT(text1), NULL, NULL, NULL, crash_report, -1); hbuttonbox3 = gtk_hbutton_box_new(); gtk_widget_show(hbuttonbox3); gtk_box_pack_start(GTK_BOX(vbox1), hbuttonbox3, FALSE, FALSE, 0); hbuttonbox4 = gtk_hbutton_box_new(); gtk_widget_show(hbuttonbox4); gtk_box_pack_start(GTK_BOX(vbox1), hbuttonbox4, FALSE, FALSE, 0); button3 = gtk_button_new_with_label(_("Close")); gtk_widget_show(button3); gtk_container_add(GTK_CONTAINER(hbuttonbox4), button3); GTK_WIDGET_SET_FLAGS(button3, GTK_CAN_DEFAULT); button4 = gtk_button_new_with_label(_("Save...")); gtk_widget_show(button4); gtk_container_add(GTK_CONTAINER(hbuttonbox4), button4); GTK_WIDGET_SET_FLAGS(button4, GTK_CAN_DEFAULT); button5 = gtk_button_new_with_label(_("Create bug report")); gtk_widget_show(button5); gtk_container_add(GTK_CONTAINER(hbuttonbox4), button5); GTK_WIDGET_SET_FLAGS(button5, GTK_CAN_DEFAULT); gtk_signal_connect(GTK_OBJECT(window1), "delete_event", GTK_SIGNAL_FUNC(gtk_main_quit), NULL); gtk_signal_connect(GTK_OBJECT(button3), "clicked", GTK_SIGNAL_FUNC(gtk_main_quit), NULL); gtk_signal_connect(GTK_OBJECT(button4), "clicked", GTK_SIGNAL_FUNC(crash_save_crash_log), crash_report); gtk_signal_connect(GTK_OBJECT(button5), "clicked", GTK_SIGNAL_FUNC(crash_create_bug_report), NULL); gtk_widget_show(window1); gtk_main(); return window1; }
/*-----------------------------------------------------------------------------------------------------------------------*/ void *AcquireData(gpointer Data) //Data acquisition thread triggered by StartCallBack { gulong Curr[4],Prev[4]; gint Overflow[4]; gdouble Rate[4]; gint i,Period; FILE *Fp; struct timeval Tv; gdouble StartTime,ElapsedTime,Delta,TimeNow,TimePrev; time_t DateTime; gchar Str[120]; if (InitCamac()) { SAttention("Could not initialise CAMAC\nCheck if crate is on"); AcqOn=FALSE; pthread_exit(NULL); } if (!(Fp=fopen(RunName,"w"))) { SAttention("Could not open output file\nCheck disk full, file permissions"); AcqOn=FALSE; pthread_exit(NULL); } CamacZ(); Period=0; for (i=0;i<NScalers;++i) { Prev[i]=0; Overflow[i]=0; } gettimeofday(&Tv,NULL); StartTime=(gdouble)Tv.tv_sec+(gdouble)Tv.tv_usec*1.0e-06; TimePrev=StartTime; DateTime=time(NULL); sprintf(Str,"%s Started:%s",RunName,ctime(&DateTime)); gdk_threads_enter(); gtk_label_set_text(GTK_LABEL(S_Start),Str); gdk_threads_leave(); fprintf(Fp,"%s Started:%s",RunName,ctime(&DateTime)); fprintf(Fp," Elapsed Scaler1 Rate1 Scaler2 Rate2 Scaler3 Rate3 Scaler4 Rate4\n"); while (TRUE) { while (TRUE) { gettimeofday(&Tv,NULL); TimeNow=(gdouble)Tv.tv_sec+(gdouble)Tv.tv_usec*1.0e-06; Delta=TimeNow-TimePrev; if (Delta >= (gdouble)Interval[Period]) { TimePrev=TimeNow; break; } if (StopSignal) break; } for (i=0;i<NScalers;++i) { CamacNAF(StnNo,SubA[i],0); Curr[i]=DataRead()+Overflow[i]*SCALER_OVERFLOW; if (Curr[i]<Prev[i]) { ++Overflow[i]; Curr[i]+=SCALER_OVERFLOW; } if (Delta>0.0) Rate[i]=(Curr[i]-Prev[i])/Delta; Prev[i]=Curr[i]; } ElapsedTime=TimeNow-StartTime; if (ElapsedTime>(gdouble)Duration[0]) Period=1; if (ElapsedTime>(gdouble)(Duration[0]+Duration[1])) Period=2; sprintf(Str,"%08.2f",ElapsedTime); gdk_threads_enter(); gtk_text_insert(GTK_TEXT(S_Output),NULL,NULL,NULL,Str,-1); gdk_threads_leave(); fprintf(Fp,"%8.2f",ElapsedTime); for (i=0;i<NScalers;++i) { sprintf(Str," %010ld %010.2f",Curr[i],Rate[i]); gdk_threads_enter(); gtk_text_insert(GTK_TEXT(S_Output),NULL,NULL,NULL,Str,-1); gdk_threads_leave(); } for (i=0;i<NScalers;++i) fprintf(Fp," %10ld %10.2f",Curr[i],Rate[i]); gdk_threads_enter(); gtk_text_insert(GTK_TEXT(S_Output),NULL,NULL,NULL,"\n",-1); gdk_threads_leave(); fprintf(Fp,"\n"); if (StopSignal) break; } DateTime=time(NULL); sprintf(Str,"%s Stopped:%s",RunName,ctime(&DateTime)); gdk_threads_enter(); gtk_text_insert(GTK_TEXT(S_Output),NULL,NULL,NULL,"--------------------------------------------------------------------------------------------------------------------------------------------------------\n",-1); gtk_label_set_text(GTK_LABEL(S_Stop),Str); gdk_threads_leave(); fprintf(Fp,"%s Stopped:%s",RunName,ctime(&DateTime)); AcqOn=FALSE; FinishCamac(); fclose(Fp); pthread_exit(NULL); }
void view_file (char *filename, int fd, unsigned int viewedit, unsigned int del_file, unsigned int start_pos, unsigned int dontupload, char *remote_filename, gftp_window_data * wdata) { GtkWidget * dialog, * view, * table, * tempwid; char buf[8192], *view_program, *edit_program; gftp_config_list_vars * tmplistvar; gftp_file_extensions * tempext; gftp_viewedit_data * newproc; GtkAdjustment * vadj; GList * templist; size_t stlen; int doclose; ssize_t n; char * non_utf8; #if GTK_MAJOR_VERSION > 1 GtkTextBuffer * textbuf; GtkTextIter iter; #endif doclose = 1; stlen = strlen (filename); gftp_lookup_global_option ("ext", &tmplistvar); for (templist = tmplistvar->list; templist != NULL; templist = templist->next) { tempext = templist->data; if (stlen >= tempext->stlen && strcmp (&filename[stlen - tempext->stlen], tempext->ext) == 0) { if (*tempext->view_program == '\0') break; ftp_log (gftp_logging_misc, NULL, _("Opening %s with %s\n"), filename, tempext->view_program); fork_process (tempext->view_program, filename, fd, remote_filename, viewedit, del_file, dontupload, wdata); return; } } if (wdata != NULL) { gftp_lookup_request_option (wdata->request, "view_program", &view_program); gftp_lookup_request_option (wdata->request, "edit_program", &edit_program); if ((non_utf8 = gftp_filename_from_utf8 (wdata->request, filename, NULL)) == NULL) /* freeme later! */ non_utf8 = filename; } else { gftp_lookup_global_option ("view_program", &view_program); gftp_lookup_global_option ("edit_program", &edit_program); non_utf8 = filename; } if (viewedit && *view_program != '\0') { /* Open the file with the default file viewer */ fork_process (view_program, filename, fd, remote_filename, viewedit, del_file, dontupload, wdata); if (non_utf8 != filename && non_utf8) g_free (non_utf8); return; } else if (!viewedit && *edit_program != '\0') { /* Open the file with the default file editor */ newproc = fork_process (edit_program, filename, fd, remote_filename, viewedit, del_file, dontupload, wdata); stat (non_utf8, &newproc->st); if (non_utf8 != filename && non_utf8) g_free (non_utf8); return; } ftp_log (gftp_logging_misc, NULL, _("Viewing file %s\n"), filename); if (fd == 0) { if ((fd = open (non_utf8, O_RDONLY)) < 0) { ftp_log (gftp_logging_error, NULL, _("View: Cannot open file %s: %s\n"), non_utf8, g_strerror (errno)); if (non_utf8 != filename && non_utf8) g_free (non_utf8); return; } doclose = 1; } else { lseek (fd, 0, SEEK_SET); doclose = 0; } if (del_file) { if (unlink (non_utf8) == 0) ftp_log (gftp_logging_misc, NULL, _("Successfully removed %s\n"), filename); else ftp_log (gftp_logging_error, NULL, _("Error: Could not remove file %s: %s\n"), filename, g_strerror (errno)); } if (non_utf8 != filename && non_utf8) g_free (non_utf8); #if GTK_MAJOR_VERSION == 1 dialog = gtk_dialog_new (); gtk_window_set_title (GTK_WINDOW (dialog), filename); gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 5); gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (dialog)->action_area), TRUE); #else dialog = gtk_dialog_new_with_buttons (filename, NULL, 0, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL); #endif gtk_window_set_wmclass (GTK_WINDOW(dialog), "fileview", "gFTP"); gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 5); gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 5); gtk_widget_realize (dialog); if (gftp_icon != NULL) { gdk_window_set_icon (dialog->window, NULL, gftp_icon->pixmap, gftp_icon->bitmap); gdk_window_set_icon_name (dialog->window, gftp_version); } table = gtk_table_new (1, 2, FALSE); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), table, TRUE, TRUE, 0); #if GTK_MAJOR_VERSION == 1 view = gtk_text_new (NULL, NULL); gtk_text_set_editable (GTK_TEXT (view), FALSE); gtk_text_set_word_wrap (GTK_TEXT (view), TRUE); gtk_table_attach (GTK_TABLE (table), view, 0, 1, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0); gtk_widget_show (view); tempwid = gtk_vscrollbar_new (GTK_TEXT (view)->vadj); gtk_table_attach (GTK_TABLE (table), tempwid, 1, 2, 0, 1, GTK_FILL, GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 0); gtk_widget_show (tempwid); vadj = GTK_TEXT (view)->vadj; #else view = gtk_text_view_new (); gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE); gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE); gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD); tempwid = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (tempwid), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add (GTK_CONTAINER (tempwid), view); gtk_widget_show (view); gtk_table_attach (GTK_TABLE (table), tempwid, 0, 1, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0); gtk_widget_show (tempwid); vadj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (tempwid)); #endif gtk_widget_set_size_request (table, 500, 400); gtk_widget_show (table); #if GTK_MAJOR_VERSION == 1 tempwid = gtk_button_new_with_label (_(" Close ")); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid, FALSE, FALSE, 0); gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), GTK_OBJECT (dialog)); gtk_widget_show (tempwid); #else g_signal_connect_swapped (GTK_OBJECT (dialog), "response", G_CALLBACK (gtk_widget_destroy), GTK_OBJECT (dialog)); #endif buf[sizeof (buf) - 1] = '\0'; while ((n = read (fd, buf, sizeof (buf) - 1)) > 0) { buf[n] = '\0'; #if GTK_MAJOR_VERSION == 1 gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL, buf, -1); #else textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); gtk_text_buffer_get_iter_at_offset (textbuf, &iter, -1); gtk_text_buffer_insert (textbuf, &iter, buf, -1); #endif } if (doclose) close (fd); gtk_widget_show (dialog); if (!start_pos) gtk_adjustment_set_value (vadj, vadj->upper); }