void addFile(GtkWidget* widget,struct GUI *gui){ if(gui->c_file>=1024) return; gui->btnOpenfile[gui->c_file++] = gtk_file_chooser_button_new("Open file",GTK_FILE_CHOOSER_ACTION_OPEN); gtk_table_attach_defaults(GTK_TABLE(gui->tableFile),gui->btnOpenfile[gui->c_file-1],0,1,gui->c_file-1,gui->c_file); gtk_widget_show_all(gui->window); }
static GtkWidget* remmina_init_dialog_create_file_button(GtkWidget *table, const gchar *label, gint row, const gchar *filename) { GtkWidget *widget; gchar *pkidir; widget = gtk_label_new(label); gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5); gtk_widget_show(widget); remmina_init_dialog_attach(table, widget, 0, row, 1, 1); widget = gtk_file_chooser_button_new(label, GTK_FILE_CHOOSER_ACTION_OPEN); gtk_file_chooser_button_set_width_chars(GTK_FILE_CHOOSER_BUTTON(widget), 25); gtk_widget_show(widget); remmina_init_dialog_attach(table, widget, 1, row, 2, 1); if (filename && filename[0] != '\0') { gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(widget), filename); } else { pkidir = g_strdup_printf("%s/.pki", g_get_home_dir()); if (g_file_test(pkidir, G_FILE_TEST_IS_DIR)) { gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(widget), pkidir); } g_free(pkidir); } return widget; }
static VALUE rg_initialize(int argc, VALUE *argv, VALUE self) { VALUE title, action, backend; GtkWidget* widget; rb_scan_args(argc, argv, "12", &title, &action, &backend); if (TYPE(title) == T_STRING) { if (NIL_P(backend)){ widget = gtk_file_chooser_button_new(RVAL2CSTR(title), RVAL2GENUM(action, GTK_TYPE_FILE_CHOOSER_ACTION)); } else { widget = gtk_file_chooser_button_new_with_backend(RVAL2CSTR(title), RVAL2GENUM(action, GTK_TYPE_FILE_CHOOSER_ACTION), RVAL2CSTR(backend)); } } else { widget = gtk_file_chooser_button_new_with_dialog(GTK_WIDGET(RVAL2GOBJ(title))); } RBGTK_INITIALIZE(self, widget); return Qnil; }
static GtkWidget* remmina_file_editor_create_chooser(RemminaFileEditor* gfe, GtkWidget* table, gint row, gint col, const gchar* label, const gchar* value, gint type) { GtkWidget* check; GtkWidget* widget; GtkWidget* hbox; widget = gtk_label_new(label); gtk_widget_show(widget); gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5); gtk_table_attach(GTK_TABLE(table), widget, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); hbox = gtk_hbox_new(FALSE, 0); gtk_widget_show(hbox); gtk_table_attach_defaults(GTK_TABLE(table), hbox, col + 1, col + 2, row, row + 1); check = gtk_check_button_new(); gtk_widget_show(check); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), (value && value[0] == '/')); gtk_box_pack_start(GTK_BOX(hbox), check, FALSE, FALSE, 0); widget = gtk_file_chooser_button_new(label, type); gtk_widget_show(widget); if (value) { gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(widget), value); } gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 0); g_signal_connect(G_OBJECT(check), "toggled", G_CALLBACK(remmina_file_editor_button_on_toggled), widget); remmina_file_editor_button_on_toggled(GTK_TOGGLE_BUTTON(check), widget); return widget; }
static void add_new_filechooser_button (const gchar *mnemonic, const gchar *chooser_title, GtkFileChooserAction action, GtkWidget *group_box, GtkSizeGroup *label_group) { GtkWidget *hbox, *label, *chooser, *button; hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); gtk_box_pack_start (GTK_BOX (group_box), hbox); label = gtk_label_new_with_mnemonic (mnemonic); gtk_size_group_add_widget (GTK_SIZE_GROUP (label_group), label); gtk_label_set_xalign (GTK_LABEL (label), 0.0); gtk_box_pack_start (GTK_BOX (hbox), label); chooser = gtk_file_chooser_button_new (g_strconcat(chooser_title, " - testfilechooserbutton", NULL), action); gtk_widget_set_hexpand (chooser, TRUE); gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (chooser), gtk_src_dir, NULL); gtk_file_chooser_remove_shortcut_folder (GTK_FILE_CHOOSER (chooser), gtk_src_dir, NULL); gtk_label_set_mnemonic_widget (GTK_LABEL (label), chooser); g_signal_connect (chooser, "current-folder-changed", G_CALLBACK (chooser_current_folder_changed_cb), NULL); g_signal_connect (chooser, "selection-changed", G_CALLBACK (chooser_selection_changed_cb), NULL); g_signal_connect (chooser, "file-activated", G_CALLBACK (chooser_file_activated_cb), NULL); g_signal_connect (chooser, "update-preview", G_CALLBACK (chooser_update_preview_cb), NULL); gtk_box_pack_start (GTK_BOX (hbox), chooser); button = gtk_button_new_with_label ("Tests"); g_signal_connect (button, "clicked", G_CALLBACK (tests_button_clicked_cb), chooser); gtk_box_pack_start (GTK_BOX (hbox), button); }
/** Callback for a 'Clear' button for GtkFileChooserButton widget. * * @internal * * @param button A pointer to the button widget emitting signal. * * @param user_data A Pointer to the GtkFileChooserButton widget. */ static void file_chooser_clear_cb (GtkButton *button, gpointer user_data) { GtkFileChooserButton *fcb = GTK_FILE_CHOOSER_BUTTON(user_data); const gchar *group = g_object_get_data (G_OBJECT(fcb), "group"); const gchar *pref = g_object_get_data (G_OBJECT(fcb), "pref"); GtkImage *image = g_object_get_data (G_OBJECT(fcb), "path_head_error"); GtkWidget *box; GtkWidget *fcb_new; gchar *boxname; /* We need to distroy the GtkFileChooserButton and recreate as there does not seem to be away of resetting the folder path to NONE */ box = gtk_widget_get_parent (GTK_WIDGET(fcb)); gtk_widget_destroy (GTK_WIDGET(fcb)); if (!gnc_prefs_set_string (group, pref, "")) PINFO("Failed to Clear preference at %s, %s", group, pref); fcb_new = gtk_file_chooser_button_new (_("Select a folder"), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); g_object_set_data (G_OBJECT(fcb_new), "path_head_error", image); gtk_box_pack_start (GTK_BOX (box), fcb_new, TRUE, TRUE, 0); gtk_box_reorder_child (GTK_BOX (box),fcb_new, 0); gtk_widget_show (fcb_new); boxname = g_strconcat ("pref/", group, "/", pref, NULL); gnc_prefs_connect_file_chooser_button (GTK_FILE_CHOOSER_BUTTON(fcb_new), boxname); g_free (boxname); }
GtkWidget *simulate_window_create () { GtkWidget *vbox; GtkWidget *button; GtkWidget *sep; GtkWidget *expander; GtkWidget *file_chooser; GtkWidget *hbox, *entry_run, *label; vbox = gtk_vbox_new (FALSE, 0); hbox = gtk_hbox_new (TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 5); led1 = gtk_matrix_led_new (16, 16, 0); gtk_box_pack_start (GTK_BOX (hbox), led1, TRUE, TRUE, 5); led2 = gtk_matrix_led_new (16, 16, 1); gtk_box_pack_start (GTK_BOX (hbox), led2, TRUE, TRUE, 5); sep = gtk_hseparator_new (); gtk_box_pack_start (GTK_BOX (vbox), sep, TRUE, TRUE, 5); expander = gtk_expander_new_with_mnemonic ("(_Display)显示点阵数据"); GtkWidget *tree = create_list (); gtk_container_add (GTK_CONTAINER (expander), tree); gtk_box_pack_start (GTK_BOX (vbox), expander, TRUE, TRUE, 5); hbox = gtk_hbox_new (TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 5); label = gtk_label_new ("数据文件:"); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 5); file_chooser = gtk_file_chooser_button_new ("选择点阵数据文件", GTK_FILE_CHOOSER_ACTION_OPEN); g_signal_connect (G_OBJECT (file_chooser), "file-set", G_CALLBACK (load_file), NULL); gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (file_chooser), "./"); gtk_box_pack_start (GTK_BOX (hbox), file_chooser, FALSE, TRUE, 5); hbox = gtk_hbox_new (TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 5); button = gtk_button_new_from_stock (GTK_STOCK_MEDIA_PLAY); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (matrix_play), file_chooser); gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 5); button = gtk_button_new_from_stock (GTK_STOCK_MEDIA_PAUSE); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (matrix_pause), file_chooser); gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 5); button = gtk_button_new_from_stock (GTK_STOCK_MEDIA_STOP); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (matrix_stop), NULL); gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 5); return vbox; }
/*# @class GtkFileChooserButton @brief A button to launch a file selection dialog @param title the title of the browse dialog. @param action the open mode for the widget (GtkFileChooserAction). The GtkFileChooserButton is a widget that lets the user select a file. It implements the GtkFileChooser interface. Visually, it is a file name with a button to bring up a GtkFileChooserDialog. The user can then use that dialog to change the file associated with that button. This widget does not support setting the "select-multiple" property to TRUE. [...] */ FALCON_FUNC FileChooserButton::init( VMARG ) { Gtk::ArgCheck1 args( vm, "S,GtkFileChooserAction" ); const char* title = args.getCString( 0 ); int action = args.getInteger( 1 ); GtkWidget* wdt = gtk_file_chooser_button_new( title, (GtkFileChooserAction) action ); MYSELF; self->setObject( (GObject*) wdt ); }
static GtkWidget * filechooserbutton_new(GladeXML *xml, GladeWidgetInfo *info) { GtkWidget *wid; wid = gtk_file_chooser_button_new("",GTK_FILE_CHOOSER_ACTION_OPEN); gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(wid),""); return wid; }
/* * Creates a new GtkWidget of class GtkFileChooser, performing any specialized * initialization needed for the widget to work correctly in this environment. * If a dialog box is used to initialize the widget, return NULL from this * function, and call data->callback with your new widget when it is done. */ static GtkWidget* gb_file_chooser_button_new (GbWidgetNewData *data) { GtkWidget *new_widget; new_widget = gtk_file_chooser_button_new (NULL, GTK_FILE_CHOOSER_ACTION_OPEN); return new_widget; }
GtkWidget* CreateFileChooser(GtkFileChooserAction action, const char* label, const char* opt_name) { GtkWidget* chooser = gtk_file_chooser_button_new(label, action); gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(chooser), theApp.GetConfigS(opt_name).c_str()); g_signal_connect(chooser, "file-set", G_CALLBACK(CB_PickFile), const_cast<char*>(opt_name)); return chooser; }
void file_chooser_button_init(lua_State* L) { lua_file_chooser_button file_chooser_button = malloc(sizeof(dt_lua_file_chooser_button_t)); file_chooser_button->parent.widget = gtk_file_chooser_button_new(lua_tostring(L,2),lua_toboolean(L,1)?GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER:GTK_FILE_CHOOSER_ACTION_OPEN ); file_chooser_button->parent.type = &file_chooser_button_type; luaA_push_type(L, file_chooser_button_type.associated_type, &file_chooser_button); g_object_ref_sink(file_chooser_button->parent.widget); }
GtkWidget* gtr_relocate_dialog_new( GtkWindow * parent, TrCore * core, GSList * torrent_ids ) { int row; GtkWidget * w; GtkWidget * d; GtkWidget * t; struct relocate_dialog_data * data; d = gtk_dialog_new_with_buttons( _( "Set Torrent Location" ), parent, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_APPLY, GTK_RESPONSE_APPLY, NULL ); gtk_dialog_set_default_response( GTK_DIALOG( d ), GTK_RESPONSE_CANCEL ); gtk_dialog_set_alternative_button_order( GTK_DIALOG( d ), GTK_RESPONSE_APPLY, GTK_RESPONSE_CANCEL, -1 ); g_signal_connect( d, "response", G_CALLBACK( onResponse ), NULL ); row = 0; t = hig_workarea_create( ); hig_workarea_add_section_title( t, &row, _( "Location" ) ); if( previousLocation == NULL ) previousLocation = g_strdup( pref_string_get( TR_PREFS_KEY_DOWNLOAD_DIR ) ); w = gtk_file_chooser_button_new( _( "Set Torrent Location" ), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ); gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER( w ), previousLocation ); g_object_set_data( G_OBJECT( d ), "chooser", w ); hig_workarea_add_row( t, &row, _( "Torrent _location:" ), w, NULL ); w = gtk_radio_button_new_with_mnemonic( NULL, _( "_Move from the current folder" ) ); g_object_set_data( G_OBJECT( d ), "move_rb", w ); hig_workarea_add_wide_control( t, &row, w ); w = gtk_radio_button_new_with_mnemonic_from_widget( GTK_RADIO_BUTTON( w ), _( "Local data is _already there" ) ); hig_workarea_add_wide_control( t, &row, w ); hig_workarea_finish( t, &row ); gtk_widget_show_all( t ); gtk_box_pack_start( GTK_BOX( GTK_DIALOG( d )->vbox ), t, TRUE, TRUE, 0 ); data = g_new0( struct relocate_dialog_data, 1 ); data->core = core; data->torrent_ids = torrent_ids; data->chooser_dialog = d; g_object_set_data_full( G_OBJECT( d ), DATA_KEY, data, data_free ); return d; }
static void test_file_chooser_button_basic (void) { GtkWidget *widget; g_test_log_set_fatal_handler (ignore_gvfs_warning, NULL); widget = gtk_file_chooser_button_new ("Choose a file !", GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); g_assert (GTK_IS_FILE_CHOOSER_BUTTON (widget)); g_timeout_add (100, main_loop_quit_cb, NULL); gtk_main(); gtk_widget_destroy (widget); }
GtkWidget* plugin_configure(GtkDialog *configure) { g_signal_connect(configure, "response", G_CALLBACK(dialog_response), NULL); GtkWidget *vbox = gtk_vbox_new(FALSE, 6); check_search_path = gtk_check_button_new_with_label(_("Include path in search?")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_search_path), include_path); ui_widget_set_tooltip_text(check_search_path, _("When filtering for files, should the search include the path when finding matches?")); gtk_box_pack_start(GTK_BOX(vbox), check_search_path, FALSE, FALSE, 10); GtkWidget *label_path = gtk_label_new(_("Exclude paths matching this regular expression:")); gtk_misc_set_alignment(GTK_MISC(label_path), 0, 0); gtk_box_pack_start(GTK_BOX(vbox), label_path, FALSE, FALSE, 2); pathRegexSetting.entry = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(pathRegexSetting.entry), pathRegexSetting.text); GtkWidget *hbox_path = gtk_hbox_new(FALSE, 6); GtkWidget *button_default_path = gtk_button_new_with_label(_("Default")); g_signal_connect(button_default_path, "clicked", G_CALLBACK(set_default), &pathRegexSetting); gtk_box_pack_start(GTK_BOX(hbox_path), pathRegexSetting.entry, TRUE, TRUE, 2); gtk_box_pack_start(GTK_BOX(hbox_path), button_default_path, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(vbox), hbox_path, FALSE, FALSE, 2); GtkWidget *label_name = gtk_label_new(_("Exclude file names matching this regular expression:")); gtk_misc_set_alignment(GTK_MISC(label_name), 0, 0); gtk_box_pack_start(GTK_BOX(vbox), label_name, FALSE, FALSE, 2); nameRegexSetting.entry = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(nameRegexSetting.entry), nameRegexSetting.text); GtkWidget *hbox_name = gtk_hbox_new(FALSE, 6); GtkWidget *button_default_name = gtk_button_new_with_label(_("Default")); g_signal_connect(button_default_name, "clicked", G_CALLBACK(set_default), &nameRegexSetting); gtk_box_pack_start(GTK_BOX(hbox_name), nameRegexSetting.entry, TRUE, TRUE, 2); gtk_box_pack_start(GTK_BOX(hbox_name), button_default_name, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(vbox), hbox_name, FALSE, FALSE, 2); GtkWidget *label_default = gtk_label_new(_("Select a based directory for the non-project opener:")); gtk_misc_set_alignment(GTK_MISC(label_default), 0, 0); gtk_box_pack_start(GTK_BOX(vbox), label_default, FALSE, FALSE, 2); button_folder_picker = gtk_file_chooser_button_new( _("Choose a path"), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(button_folder_picker), opener_path); gtk_box_pack_start(GTK_BOX(vbox), button_folder_picker, FALSE, FALSE, 2); gtk_widget_show_all(vbox); return vbox; }
static void activate (GtkApplication *app, gpointer user_data) { GtkWidget *window; GtkWidget *frame; GtkWidget *drawing_area; GtkWidget *chooser_button; window = gtk_application_window_new (app); gtk_window_set_title (GTK_WINDOW (window), "Drawing Area"); g_signal_connect (window, "destroy", G_CALLBACK (close_window), NULL); gtk_container_set_border_width (GTK_CONTAINER (window), 8); frame = gtk_paned_new(GTK_ORIENTATION_VERTICAL); gtk_container_add (GTK_CONTAINER (window), frame); chooser_button = gtk_file_chooser_button_new("Select problem...", GTK_FILE_CHOOSER_ACTION_OPEN); drawing_area = gtk_drawing_area_new (); /* set a minimum size */ gtk_widget_set_size_request (drawing_area, 800, 800); gtk_paned_add1(GTK_PANED(frame), drawing_area); gtk_paned_add2(GTK_PANED(frame), chooser_button); /* Signals used to handle the backing surface */ g_signal_connect (drawing_area, "draw", G_CALLBACK (draw_cb), NULL); g_signal_connect (drawing_area,"configure-event", G_CALLBACK (configure_event_cb), NULL); g_signal_connect(drawing_area, "button_press_event", G_CALLBACK(button_press_event_cb), NULL); g_signal_connect(chooser_button, "file-set", G_CALLBACK(set_file), chooser_button); /* Ask to receive events the drawing area doesn't normally * subscribe to. In particular, we need to ask for the * button press and motion notify events that want to handle. */ gtk_widget_set_events (drawing_area, gtk_widget_get_events (drawing_area) | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK); gtk_widget_show_all (window); }
int main(int argc, char *argv[]) { GtkWidget *window; GtkWidget *label; GtkWidget *button; GtkFileFilter *filter1, *filter2; GtkWidget *box; const gchar *filename = "/home/caterpillar/workspace/caterpillar.gif"; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "GtkFileChooserButton"); button = gtk_file_chooser_button_new( "選取檔案", GTK_FILE_CHOOSER_ACTION_OPEN); gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(button), filename); filter1 = gtk_file_filter_new(); filter2 = gtk_file_filter_new(); gtk_file_filter_set_name(filter1, "Image Files"); gtk_file_filter_set_name(filter2, "All Files"); gtk_file_filter_add_pattern(filter1, "*.png"); gtk_file_filter_add_pattern(filter1, "*.gif"); gtk_file_filter_add_pattern(filter1, "*.jpg"); gtk_file_filter_add_pattern(filter2, "*"); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(button), filter1); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(button), filter2); label = gtk_label_new(filename); box = gtk_vbox_new(TRUE, 5); gtk_box_pack_start(GTK_BOX(box), button, TRUE, TRUE, 5); gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 5); gtk_container_add(GTK_CONTAINER(window), box); g_signal_connect(GTK_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL); g_signal_connect(GTK_OBJECT(button), "selection_changed", G_CALLBACK(file_changed), label); gtk_widget_show_all(window); gtk_main(); return 0; }
int main (int argc, char *argv[]) { Widgets *w = (Widgets*) g_malloc (sizeof (Widgets)); GtkWidget *window, *vbox, *hbox; gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), "Exercise 4-1"); gtk_container_set_border_width (GTK_CONTAINER (window), 10); g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL); w->rnm = gtk_button_new_from_stock (GTK_STOCK_APPLY); w->name = gtk_entry_new (); gtk_widget_set_sensitive (w->rnm, FALSE); gtk_widget_set_sensitive (w->name, FALSE); w->file = gtk_file_chooser_button_new ("Choose File", GTK_FILE_CHOOSER_ACTION_OPEN); gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (w->file), g_get_home_dir()); g_signal_connect (G_OBJECT (w->file), "selection-changed", G_CALLBACK (file_changed), (gpointer) w); g_signal_connect (G_OBJECT (w->rnm), "clicked", G_CALLBACK (rename_clicked), (gpointer) w); hbox = gtk_hbox_new (FALSE, 5); gtk_box_pack_start (GTK_BOX (hbox), w->name, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (hbox), w->rnm, FALSE, TRUE, 0); vbox = gtk_vbox_new (FALSE, 5); gtk_box_pack_start (GTK_BOX (vbox), w->file, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0); gtk_container_add (GTK_CONTAINER (window), vbox); gtk_widget_show_all (window); gtk_main (); return 0; }
void GUI::setup_right_box(){ this->right_box = gtk_vbox_new (FALSE, 0); // GtkWidget * vm_programs_frame; vm_programs_frame = gtk_frame_new ("Add VM program"); GtkWidget * add_file_vbox; add_file_vbox = gtk_vbox_new(FALSE, 0); // p_files_box GtkWidget * add_file_box; add_file_box = gtk_hbox_new(FALSE, 0); // add file button this->add_chooser_filter = gtk_file_filter_new (); gtk_file_filter_add_pattern (this->add_chooser_filter, "*.prg"); this->add_chooser = gtk_file_chooser_button_new ( "Select a file", GTK_FILE_CHOOSER_ACTION_OPEN); gtk_file_chooser_add_filter (GTK_FILE_CHOOSER(this->add_chooser), this->add_chooser_filter); gtk_widget_set_usize (this->add_chooser, 250, 28); gtk_box_pack_start (GTK_BOX (add_file_box), this->add_chooser, FALSE, FALSE, 5); this->add_file = gtk_button_new_with_label("Add"); g_signal_connect (this->add_file, "clicked", G_CALLBACK (GUI::add_file_clicked), gpointer(this)); gtk_widget_set_usize (this->add_file, 100, 28); gtk_box_pack_start (GTK_BOX (add_file_box), this->add_file, FALSE, FALSE, 5); gtk_box_pack_start (GTK_BOX (add_file_vbox), add_file_box, FALSE, FALSE, 5); // add gtk_container_add (GTK_CONTAINER (vm_programs_frame), add_file_vbox); // add vm_programs_frame to right_box gtk_box_pack_start (GTK_BOX (this->right_box), vm_programs_frame, FALSE, FALSE, 0); // programs notebook this->programs_notebook = gtk_notebook_new(); gtk_widget_set_usize (this->programs_notebook, 600, 400); gtk_box_pack_start (GTK_BOX (this->right_box), this->programs_notebook, FALSE, FALSE, 5); }
int main (int argc, char *argv[]) { GtkWidget *window, *vbox, *button; Widgets *widgets = g_slice_new (Widgets); gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), "Exercise 6-1"); gtk_widget_set_size_request (window, 250, -1); gtk_container_set_border_width (GTK_CONTAINER (window), 10); g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL); widgets->entry = gtk_entry_new (); gtk_entry_set_text (GTK_ENTRY (widgets->entry), "Enter some text and choose a location"); widgets->chooser = gtk_file_chooser_button_new ("Choose a Location ...", GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (widgets->chooser), g_get_home_dir ()); button = gtk_button_new_from_stock (GTK_STOCK_SAVE); vbox = gtk_vbox_new (FALSE, 5); gtk_box_pack_start (GTK_BOX (vbox), widgets->entry, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), widgets->chooser, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (window), vbox); gtk_widget_show_all (window); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (save_the_file), (gpointer) widgets); gtk_main(); return 0; }
/* See VikDataSourceInterface */ static void datasource_file_add_setup_widgets ( GtkWidget *dialog, VikViewport *vvp, gpointer user_data ) { datasource_file_widgets_t *widgets = (datasource_file_widgets_t *)user_data; GtkWidget *filename_label, *type_label; /* The file selector */ filename_label = gtk_label_new (_("File:")); widgets->file = gtk_file_chooser_button_new (_("File to import"), GTK_FILE_CHOOSER_ACTION_OPEN); if (last_folder_uri) gtk_file_chooser_set_current_folder_uri ( GTK_FILE_CHOOSER(widgets->file), last_folder_uri); /* Add filters */ g_list_foreach ( a_babel_file_list, add_file_filter, widgets->file ); GtkFileFilter *all_filter = gtk_file_filter_new (); gtk_file_filter_add_pattern ( all_filter, "*" ); gtk_file_filter_set_name ( all_filter, _("All files") ); gtk_file_chooser_add_filter ( GTK_FILE_CHOOSER(widgets->file), all_filter ); if ( last_file_filter == NULL ) /* No previously selected filter or 'All files' selected */ gtk_file_chooser_set_filter ( GTK_FILE_CHOOSER(widgets->file), all_filter ); /* The file format selector */ type_label = gtk_label_new (_("File type:")); /* Propose any readable file */ BabelMode mode = { 1, 0, 1, 0, 1, 0 }; widgets->type = a_babel_ui_file_type_selector_new ( mode ); g_signal_connect ( G_OBJECT(widgets->type), "changed", G_CALLBACK(a_babel_ui_type_selector_dialog_sensitivity_cb), dialog ); gtk_combo_box_set_active ( GTK_COMBO_BOX(widgets->type), last_type ); /* Manually call the callback to fix the state */ a_babel_ui_type_selector_dialog_sensitivity_cb ( GTK_COMBO_BOX(widgets->type), dialog ); /* Packing all these widgets */ GtkBox *box = GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))); gtk_box_pack_start ( box, filename_label, FALSE, FALSE, 5 ); gtk_box_pack_start ( box, widgets->file, FALSE, FALSE, 5 ); gtk_box_pack_start ( box, type_label, FALSE, FALSE, 5 ); gtk_box_pack_start ( box, widgets->type, FALSE, FALSE, 5 ); gtk_widget_show_all(dialog); }
int main( int argc, char **argv ) { gtk_init( &argc, &argv ); GtkWidget *window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); gtk_window_set_title( GTK_WINDOW( window ), "Ex0601" ); gtk_container_set_border_width( GTK_CONTAINER( window ), 20 ); gtk_widget_set_size_request( window, 480, 320 ); GtkWidget *entry = gtk_entry_new(); gtk_entry_set_visibility( GTK_ENTRY( entry ), TRUE ); GtkWidget *button = gtk_button_new_with_mnemonic( "_Write to File" ); gtk_widget_set_sensitive( button, FALSE ); gtk_widget_set_sensitive( entry, FALSE ); Data data; data.text = '\0'; data.filename = '\0'; data.entry = entry; data.button = button; GtkWidget *chooser = gtk_file_chooser_button_new( "Chooser a folder", GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ); /* gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER( chooser ), g_get_home_dir() ); */ g_signal_connect( G_OBJECT( chooser ), "selection_changed", G_CALLBACK( file_selected ), (gpointer) &data ); g_signal_connect( G_OBJECT( entry ), "changed", G_CALLBACK( text_entered ), (gpointer) &data ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( button_clicked ), (gpointer) &data ); g_signal_connect( G_OBJECT( window ), "destroy", G_CALLBACK( destroy ), (gpointer) &data ); /* arragne all widgets together in a container */ GtkWidget *vbox = gtk_vbox_new( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), chooser, FALSE, FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), entry, FALSE, FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 10 ); gtk_container_add( GTK_CONTAINER( window ), vbox ); gtk_widget_show_all( window ); gtk_main(); return 0; }
/* See VikDataSourceInterface */ static void datasource_file_add_setup_widgets ( GtkWidget *dialog, VikViewport *vvp, gpointer user_data ) { datasource_file_widgets_t *widgets = (datasource_file_widgets_t *)user_data; GtkWidget *filename_label, *type_label; /* The file selector */ filename_label = gtk_label_new (_("File:")); widgets->file = gtk_file_chooser_button_new (_("File to import"), GTK_FILE_CHOOSER_ACTION_OPEN); if (last_folder_uri) gtk_file_chooser_set_current_folder_uri ( GTK_FILE_CHOOSER(widgets->file), last_folder_uri); /* Add filters */ g_list_foreach ( a_babel_file_list, add_file_filter, widgets->file ); GtkFileFilter *all_filter = gtk_file_filter_new (); gtk_file_filter_add_pattern ( all_filter, "*" ); gtk_file_filter_set_name ( all_filter, _("All files") ); gtk_file_chooser_add_filter ( GTK_FILE_CHOOSER(widgets->file), all_filter ); if ( last_file_filter == NULL ) /* No previously selected filter or 'All files' selected */ gtk_file_chooser_set_filter ( GTK_FILE_CHOOSER(widgets->file), all_filter ); /* The file format selector */ type_label = gtk_label_new (_("File type:")); #if GTK_CHECK_VERSION (2,24,0) widgets->type = gtk_combo_box_text_new (); #else widgets->type = gtk_combo_box_new_text (); #endif g_list_foreach (a_babel_file_list, fill_combo_box, widgets->type); gtk_combo_box_set_active (GTK_COMBO_BOX (widgets->type), last_type); /* Packing all these widgets */ gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(dialog)->vbox), filename_label, FALSE, FALSE, 5 ); gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(dialog)->vbox), widgets->file, FALSE, FALSE, 5 ); gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(dialog)->vbox), type_label, FALSE, FALSE, 5 ); gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(dialog)->vbox), widgets->type, FALSE, FALSE, 5 ); gtk_widget_show_all(dialog); }
static void nemo_mime_application_chooser_build_ui (NemoMimeApplicationChooser *chooser) { GtkWidget *box, *button; GAppInfo *info; gtk_container_set_border_width (GTK_CONTAINER (chooser), 8); gtk_box_set_spacing (GTK_BOX (chooser), 0); gtk_box_set_homogeneous (GTK_BOX (chooser), FALSE); chooser->details->label = gtk_label_new (""); gtk_misc_set_alignment (GTK_MISC (chooser->details->label), 0.0, 0.5); gtk_label_set_line_wrap (GTK_LABEL (chooser->details->label), TRUE); gtk_label_set_line_wrap_mode (GTK_LABEL (chooser->details->label), PANGO_WRAP_WORD_CHAR); gtk_box_pack_start (GTK_BOX (chooser), chooser->details->label, FALSE, FALSE, 0); gtk_widget_show (chooser->details->label); chooser->details->open_with_widget = gtk_app_chooser_widget_new (chooser->details->content_type); gtk_app_chooser_widget_set_show_default (GTK_APP_CHOOSER_WIDGET (chooser->details->open_with_widget), TRUE); gtk_app_chooser_widget_set_show_fallback (GTK_APP_CHOOSER_WIDGET (chooser->details->open_with_widget), TRUE); gtk_box_pack_start (GTK_BOX (chooser), chooser->details->open_with_widget, TRUE, TRUE, 6); gtk_widget_show (chooser->details->open_with_widget); g_signal_connect (chooser->details->open_with_widget, "application-selected", G_CALLBACK (application_selected_cb), chooser); g_signal_connect (chooser->details->open_with_widget, "populate-popup", G_CALLBACK (populate_popup_cb), chooser); gtk_app_chooser_widget_set_show_other (GTK_APP_CHOOSER_WIDGET (chooser->details->open_with_widget), TRUE); gtk_app_chooser_widget_set_show_recommended (GTK_APP_CHOOSER_WIDGET (chooser->details->open_with_widget), TRUE); GtkWidget *custom_label = gtk_label_new (_("You can also type or select a custom executable file to use to open this file type. " "You can use this command just once, or set it as default for all files of this type.")); gtk_misc_set_alignment (GTK_MISC (custom_label), 0.0, 0.5); gtk_label_set_line_wrap (GTK_LABEL (custom_label), TRUE); gtk_label_set_line_wrap_mode (GTK_LABEL (custom_label), PANGO_WRAP_WORD_CHAR); gtk_box_pack_start (GTK_BOX (chooser), custom_label, FALSE, FALSE, 0); gtk_widget_show (GTK_WIDGET (custom_label)); GtkWidget *custom_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_pack_start (GTK_BOX (chooser), custom_box, TRUE, TRUE, 0); GtkWidget *entry = gtk_entry_new (); gtk_box_pack_start (GTK_BOX (custom_box), entry, TRUE, TRUE, 0); gtk_entry_set_placeholder_text (GTK_ENTRY (entry), _("Enter a custom command...")); g_signal_connect (entry, "changed", G_CALLBACK (custom_entry_changed_cb), chooser); chooser->details->custom_entry = entry; button = gtk_file_chooser_button_new (_("Custom application"), GTK_FILE_CHOOSER_ACTION_OPEN); g_signal_connect (button, "file-set", G_CALLBACK (custom_app_set_cb), chooser); gtk_widget_show (button); gtk_box_pack_start (GTK_BOX (custom_box), button, FALSE, FALSE, 6); gtk_widget_show_all (custom_box); chooser->details->custom_picker = button; box = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL); gtk_box_set_spacing (GTK_BOX (box), 6); gtk_button_box_set_layout (GTK_BUTTON_BOX (box), GTK_BUTTONBOX_CENTER); gtk_box_pack_start (GTK_BOX (chooser), box, FALSE, FALSE, 6); gtk_widget_show (box); GtkFileFilter *filter = gtk_file_filter_new (); gtk_file_filter_add_mime_type (filter, "application/*"); gtk_file_filter_set_name (filter, _("Executables")); gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (button), filter); button = gtk_button_new_with_label (_("Add to list")); g_signal_connect (button, "clicked", G_CALLBACK (add_clicked_cb), chooser); gtk_widget_show (button); gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0); chooser->details->add_button = button; button = gtk_button_new_with_label (_("Set as default")); g_signal_connect (button, "clicked", G_CALLBACK (set_as_default_clicked_cb), chooser); gtk_widget_show (button); gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0); chooser->details->set_as_default_button = button; button = gtk_button_new_with_label (_("Reset to system defaults")); g_signal_connect (button, "clicked", G_CALLBACK (reset_clicked_cb), chooser); gtk_widget_show (button); gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0); /* initialize sensitivity */ info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (chooser->details->open_with_widget)); if (info != NULL) { application_selected_cb (GTK_APP_CHOOSER_WIDGET (chooser->details->open_with_widget), info, chooser); g_object_unref (info); } }
GtkWidget* gtr_torrent_options_dialog_new( GtkWindow * parent, TrCore * core, tr_ctor * ctor ) { guint row; guint col; const char * str; GtkWidget * w; GtkWidget * d; GtkWidget * t; GtkWidget * l; GtkWidget * source_chooser; struct OpenData * data; bool flag; GSList * list; GSList * walk; /* make the dialog */ d = gtk_dialog_new_with_buttons( _( "Torrent Options" ), parent, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL ); gtk_dialog_set_default_response( GTK_DIALOG( d ), GTK_RESPONSE_ACCEPT ); gtk_dialog_set_alternative_button_order( GTK_DIALOG( d ), GTK_RESPONSE_ACCEPT, GTK_RESPONSE_CANCEL, -1 ); if( tr_ctorGetDownloadDir( ctor, TR_FORCE, &str ) ) g_assert_not_reached( ); g_assert( str ); data = g_new0( struct OpenData, 1 ); data->core = core; data->ctor = ctor; data->filename = g_strdup( tr_ctorGetSourceFile( ctor ) ); data->downloadDir = g_strdup( str ); data->file_list = gtr_file_list_new( core, 0 ); str = _( "Mo_ve .torrent file to the trash" ); data->trash_check = gtk_check_button_new_with_mnemonic( str ); str = _( "_Start when added" ); data->run_check = gtk_check_button_new_with_mnemonic( str ); w = data->priority_combo = gtr_priority_combo_new( ); gtr_priority_combo_set_value( GTK_COMBO_BOX( w ), TR_PRI_NORMAL ); g_signal_connect( G_OBJECT( d ), "response", G_CALLBACK( addResponseCB ), data ); t = gtk_table_new( 6, 2, FALSE ); gtk_container_set_border_width( GTK_CONTAINER( t ), GUI_PAD_BIG ); gtk_table_set_row_spacings( GTK_TABLE( t ), GUI_PAD ); gtk_table_set_col_spacings( GTK_TABLE( t ), GUI_PAD_BIG ); row = col = 0; l = gtk_label_new_with_mnemonic( _( "_Torrent file:" ) ); gtk_misc_set_alignment( GTK_MISC( l ), 0.0f, 0.5f ); gtk_table_attach( GTK_TABLE( t ), l, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0 ); ++col; w = gtk_file_chooser_button_new( _( "Select Source File" ), GTK_FILE_CHOOSER_ACTION_OPEN ); source_chooser = w; gtk_table_attach( GTK_TABLE( t ), w, col, col + 1, row, row + 1, ~0, 0, 0, 0 ); gtk_label_set_mnemonic_widget( GTK_LABEL( l ), w ); addTorrentFilters( GTK_FILE_CHOOSER( w ) ); g_signal_connect( w, "selection-changed", G_CALLBACK( sourceChanged ), data ); ++row; col = 0; l = gtk_label_new_with_mnemonic( _( "_Destination folder:" ) ); gtk_misc_set_alignment( GTK_MISC( l ), 0.0f, 0.5f ); gtk_table_attach( GTK_TABLE( t ), l, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0 ); ++col; w = gtk_file_chooser_button_new( _( "Select Destination Folder" ), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ); if( !gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER( w ), data->downloadDir ) ) g_warning( "couldn't select '%s'", data->downloadDir ); list = get_recent_destinations( ); for( walk = list; walk; walk = walk->next ) gtk_file_chooser_add_shortcut_folder( GTK_FILE_CHOOSER( w ), walk->data, NULL ); g_slist_free( list ); gtk_table_attach( GTK_TABLE( t ), w, col, col + 1, row, row + 1, ~0, 0, 0, 0 ); gtk_label_set_mnemonic_widget( GTK_LABEL( l ), w ); g_signal_connect( w, "selection-changed", G_CALLBACK( downloadDirChanged ), data ); ++row; col = 0; w = data->file_list; gtk_widget_set_size_request ( w, 466u, 300u ); gtk_table_attach_defaults( GTK_TABLE( t ), w, col, col + 2, row, row + 1 ); ++row; col = 0; w = gtk_label_new_with_mnemonic( _( "Torrent _priority:" ) ); gtk_misc_set_alignment( GTK_MISC( w ), 0.0f, 0.5f ); gtk_table_attach( GTK_TABLE( t ), w, col, col + 1, row, row + 1, ~0, 0, 0, 0 ); ++col; gtk_table_attach( GTK_TABLE( t ), data->priority_combo, col, col + 1, row, row + 1, ~0, 0, 0, 0 ); gtk_label_set_mnemonic_widget( GTK_LABEL( w ), data->priority_combo ); ++row; col = 0; w = data->run_check; if( tr_ctorGetPaused( ctor, TR_FORCE, &flag ) ) g_assert_not_reached( ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( w ), !flag ); gtk_table_attach( GTK_TABLE( t ), w, col, col + 2, row, row + 1, GTK_FILL, 0, 0, 0 ); ++row; col = 0; w = data->trash_check; if( tr_ctorGetDeleteSource( ctor, &flag ) ) g_assert_not_reached( ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( w ), flag ); gtk_table_attach( GTK_TABLE( t ), w, col, col + 2, row, row + 1, GTK_FILL, 0, 0, 0 ); /* trigger sourceChanged, either directly or indirectly, * so that it creates the tor/gtor objects */ w = source_chooser; if( data->filename ) gtk_file_chooser_set_filename( GTK_FILE_CHOOSER( w ), data->filename ); else sourceChanged( GTK_FILE_CHOOSER_BUTTON( w ), data ); gtr_dialog_set_content( GTK_DIALOG( d ), t ); w = gtk_dialog_get_widget_for_response( GTK_DIALOG( d ), GTK_RESPONSE_ACCEPT ); gtk_widget_grab_focus( w ); return d; }
void config_missing_letter(GcomprisBoardConf *bconf, GHashTable *config) { GtkWidget *frame, *view, *pixmap, *question, *answer, *choice; GtkWidget *level, *vbox, *hbox, *label; GtkWidget *bbox, *button, *table; GtkFileFilter *file_filter; _config_missing *conf_data; int i; conf_data = g_new0(_config_missing,1); /* frame */ frame = gtk_frame_new(""); gtk_widget_show(frame); gtk_box_pack_start(GTK_BOX(bconf->main_conf_box), frame, TRUE, TRUE, 8); vbox = gtk_vbox_new(FALSE, 8); gtk_widget_show(vbox); gtk_container_add(GTK_CONTAINER(frame), vbox); /* hbox */ hbox = gtk_hbox_new(FALSE, 8); gtk_widget_show(hbox); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 8); /* combo level */ label = gtk_label_new(_("Level:")); gtk_widget_show(label); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 8); level = gtk_combo_box_new_text(); for(i=1; i< gcomprisBoard_missing->maxlevel; i++) { gchar *tmp; tmp = g_strdup_printf(_("Level %d"), i); gtk_combo_box_append_text(GTK_COMBO_BOX(level), tmp); g_free(tmp); } gtk_widget_show(level); gtk_box_pack_start(GTK_BOX(hbox), level, FALSE, FALSE, 8); /* upper case */ gboolean up_init = FALSE; gchar *up_init_str = g_hash_table_lookup( config, "uppercase_only"); if (up_init_str && (strcmp(up_init_str, "True")==0)) up_init = TRUE; gc_board_config_boolean_box(bconf, _("Uppercase only text"), "uppercase_only", up_init); /* list view */ GtkListStore *list = gtk_list_store_new(N_COLUMNS, G_TYPE_STRING, /*Question */ G_TYPE_STRING, /* Answer */ G_TYPE_STRING, /* Choice */ G_TYPE_STRING, /* pixmap */ GDK_TYPE_PIXBUF /* pixbuf */ ); view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(list)); configure_colummns(GTK_TREE_VIEW(view)); gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (view), TRUE); gtk_tree_view_set_search_column (GTK_TREE_VIEW (view), ANSWER_COLUMN); gtk_widget_set_size_request(view, -1, 200); gtk_widget_show(view); GtkScrolledWindow *scroll = GTK_SCROLLED_WINDOW(gtk_scrolled_window_new(NULL,NULL)); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_widget_show(GTK_WIDGET(scroll)); gtk_container_add(GTK_CONTAINER(scroll), view); gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(scroll), TRUE, TRUE, 10); /* button box */ bbox = gtk_hbutton_box_new(); gtk_widget_show(bbox); gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 8); button = gtk_button_new_from_stock(GTK_STOCK_NEW); gtk_widget_show(button); gtk_container_add(GTK_CONTAINER(bbox), button); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(new_clicked), (gpointer) conf_data); button = gtk_button_new_from_stock(GTK_STOCK_DELETE); gtk_widget_show(button); gtk_container_add(GTK_CONTAINER(bbox), button); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(delete_clicked), (gpointer) conf_data); button = gtk_button_new_from_stock(GTK_STOCK_SAVE); gtk_widget_show(button); gtk_container_add(GTK_CONTAINER(bbox), button); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(save_clicked), (gpointer) conf_data); /* table */ table = gtk_table_new(2, 4, FALSE); gtk_widget_show(table); gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 8); /* answer */ label = gtk_label_new(_("Answer")); gtk_widget_show(label); gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); answer = gtk_entry_new(); gtk_widget_show(answer); gtk_table_attach_defaults(GTK_TABLE(table), answer, 1, 2, 0, 1); /* pixmap */ label = gtk_label_new(_("Picture")); gtk_widget_show(label); gtk_table_attach_defaults(GTK_TABLE(table), label, 2, 3, 0, 1); pixmap = gtk_file_chooser_button_new(_("Filename:"), GTK_FILE_CHOOSER_ACTION_OPEN); file_filter = gtk_file_filter_new(); gtk_file_filter_add_pixbuf_formats(file_filter); gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(pixmap), file_filter); gtk_widget_show(pixmap); gtk_table_attach_defaults(GTK_TABLE(table), pixmap, 3, 4, 0, 1); /* question */ label = gtk_label_new(_("Question")); gtk_widget_show(label); gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); question = gtk_entry_new(); gtk_widget_show(question); gtk_table_attach_defaults(GTK_TABLE(table), question, 1, 2, 1, 2); gtk_widget_set_tooltip_text(question, _("Replace the letter to guess " "by the character '_'.") ); /* choice */ label = gtk_label_new(_("Choice")); gtk_widget_show(label); gtk_table_attach_defaults(GTK_TABLE(table), label, 2, 3, 1, 2); choice = gtk_entry_new(); gtk_entry_set_max_length(GTK_ENTRY(choice), MAX_PROPOSAL); gtk_widget_show(choice); gtk_table_attach_defaults(GTK_TABLE(table), choice, 3, 4, 1, 2); gtk_widget_set_tooltip_text(choice, _("Enter here the letter that will be proposed. " "The first letter here must be the solution.")); conf_data -> combo_level = GTK_COMBO_BOX(level); conf_data -> view = GTK_TREE_VIEW(view); conf_data -> pixmap = GTK_FILE_CHOOSER_BUTTON(pixmap); conf_data -> question = GTK_ENTRY(question); conf_data -> answer = GTK_ENTRY(answer); conf_data -> choice = GTK_ENTRY(choice); GtkTreeSelection *selection; selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view)); gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); g_signal_connect(G_OBJECT(selection), "changed", G_CALLBACK(selection_changed), (gpointer) conf_data); g_signal_connect(G_OBJECT(frame), "destroy", G_CALLBACK(destroy_conf_data), (gpointer) conf_data); g_signal_connect(G_OBJECT(level), "changed", G_CALLBACK(level_changed), (gpointer) conf_data); g_signal_connect(G_OBJECT(question), "changed", G_CALLBACK(text_changed), (gpointer) conf_data); g_signal_connect(G_OBJECT(answer), "changed", G_CALLBACK(text_changed), (gpointer) conf_data); g_signal_connect(G_OBJECT(choice), "changed", G_CALLBACK(text_changed), (gpointer) conf_data); g_signal_connect(G_OBJECT(pixmap), "file-set", G_CALLBACK(text_changed), (gpointer) conf_data); gtk_combo_box_set_active(GTK_COMBO_BOX(level), 0); }
static void xfburn_preferences_dialog_init (XfburnPreferencesDialog * obj) { GtkBox *box = GTK_BOX (GTK_DIALOG (obj)->vbox); XfburnPreferencesDialogPrivate *priv = XFBURN_PREFERENCES_DIALOG_GET_PRIVATE (obj); GtkWidget *vbox, *vbox2, *vbox3, *hbox; GtkWidget *label; GtkWidget *frame; GtkWidget *scrolled_window; GtkListStore *icon_store, *store; gint x,y; GdkPixbuf *icon = NULL; GtkTreeIter iter; GtkTreeViewColumn *column_name; GtkCellRenderer *cell_icon, *cell_name; GtkWidget *button_close; gint idx; gtk_window_set_title (GTK_WINDOW (obj), _("Preferences")); xfce_titled_dialog_set_subtitle (XFCE_TITLED_DIALOG (obj), _("Tune how Xfburn behaves")); gtk_window_set_default_size (GTK_WINDOW (obj), 775, 400); gtk_window_set_destroy_with_parent (GTK_WINDOW (obj), TRUE); gtk_window_set_icon_name (GTK_WINDOW (obj), GTK_STOCK_PREFERENCES); gtk_dialog_set_has_separator (GTK_DIALOG (obj), FALSE); hbox = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (box, hbox, TRUE, TRUE, 0); gtk_widget_show (hbox); scrolled_window = gtk_scrolled_window_new (NULL, NULL); g_object_set (G_OBJECT (scrolled_window), "hscrollbar-policy", GTK_POLICY_NEVER, "shadow-type", GTK_SHADOW_IN, "vscrollbar-policy", GTK_POLICY_NEVER, NULL); gtk_box_pack_start (GTK_BOX (hbox), scrolled_window, FALSE, FALSE, 0); gtk_widget_show (scrolled_window); /* icon bar */ icon_store = gtk_list_store_new (SETTINGS_LIST_N_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT); priv->icon_bar = exo_icon_bar_new_with_model (GTK_TREE_MODEL (icon_store)); exo_icon_bar_set_pixbuf_column (EXO_ICON_BAR (priv->icon_bar), SETTINGS_LIST_PIXBUF_COLUMN); exo_icon_bar_set_text_column (EXO_ICON_BAR (priv->icon_bar), SETTINGS_LIST_TEXT_COLUMN); gtk_container_add (GTK_CONTAINER (scrolled_window), priv->icon_bar); gtk_widget_show (priv->icon_bar); /* notebook */ priv->notebook = gtk_notebook_new (); gtk_container_set_border_width (GTK_CONTAINER (priv->notebook), BORDER); g_object_set (G_OBJECT (priv->notebook), "show-border", FALSE, "show-tabs", FALSE, NULL); gtk_box_pack_start (GTK_BOX (hbox), priv->notebook, TRUE, TRUE, BORDER); gtk_widget_show (priv->notebook); /* general tab */ vbox = gtk_vbox_new (FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (vbox), BORDER); idx = gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), vbox, NULL); gtk_widget_show (vbox); vbox2 = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox2); frame = xfce_gtk_frame_box_new_with_content (_("Temporary directory"), vbox2); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, BORDER); gtk_widget_show (frame); priv->chooser_button = gtk_file_chooser_button_new (_("Temporary directory"), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); gtk_box_pack_start (GTK_BOX (vbox2), priv->chooser_button, FALSE, FALSE, BORDER); gtk_widget_show (priv->chooser_button); priv->check_clean_tmpdir = gtk_check_button_new_with_mnemonic (_("_Clean temporary directory on exit")); gtk_box_pack_start (GTK_BOX (vbox2), priv->check_clean_tmpdir, FALSE, FALSE, BORDER); gtk_widget_show (priv->check_clean_tmpdir); vbox2 = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox2); frame = xfce_gtk_frame_box_new_with_content (_("File browser"), vbox2); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, BORDER); gtk_widget_show (frame); priv->check_show_hidden = gtk_check_button_new_with_mnemonic (_("Show _hidden files")); gtk_box_pack_start (GTK_BOX (vbox2), priv->check_show_hidden, FALSE, FALSE, BORDER); gtk_widget_show (priv->check_show_hidden); g_signal_connect (G_OBJECT (priv->check_show_hidden), "clicked", G_CALLBACK (cb_show_hidden_clicked), NULL); priv->check_show_human_readable = gtk_check_button_new_with_mnemonic (_("Show human_readable filesizes")); gtk_box_pack_start (GTK_BOX (vbox2), priv->check_show_human_readable, FALSE, FALSE, BORDER); gtk_widget_show (priv->check_show_human_readable); icon = gtk_widget_render_icon (GTK_WIDGET (priv->icon_bar), GTK_STOCK_PROPERTIES, GTK_ICON_SIZE_DIALOG, NULL); gtk_list_store_append (icon_store, &iter); gtk_list_store_set (icon_store, &iter, SETTINGS_LIST_PIXBUF_COLUMN, icon, SETTINGS_LIST_TEXT_COLUMN, _("General"), SETTINGS_LIST_INDEX_COLUMN, idx, -1); g_object_unref (G_OBJECT (icon)); /* devices tab */ vbox = gtk_vbox_new (FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (vbox), BORDER); idx = gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), vbox, NULL); gtk_widget_show (vbox); label = gtk_label_new (_("Devices")); gtk_widget_show (label); gtk_notebook_set_tab_label (GTK_NOTEBOOK (priv->notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), 1), label); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); vbox2 = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox2); frame = xfce_gtk_frame_box_new_with_content (_("Detected devices"), vbox2); gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, BORDER); gtk_widget_show (frame); scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_IN); gtk_widget_show (scrolled_window); gtk_box_pack_start (GTK_BOX (vbox2), scrolled_window, TRUE, TRUE, BORDER); store = gtk_list_store_new (DEVICE_LIST_N_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN); priv->treeview_devices = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store)); gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), DEVICE_LIST_COLUMN_NAME, GTK_SORT_ASCENDING); gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (priv->treeview_devices), TRUE); gtk_widget_show (priv->treeview_devices); gtk_container_add (GTK_CONTAINER (scrolled_window), priv->treeview_devices); g_object_unref (store); /* add columns */ column_name = gtk_tree_view_column_new (); gtk_tree_view_column_set_title (column_name, _("Name")); gtk_tree_view_column_set_expand (column_name, TRUE); cell_icon = gtk_cell_renderer_pixbuf_new (); gtk_tree_view_column_pack_start (column_name, cell_icon, FALSE); gtk_tree_view_column_set_attributes (column_name, cell_icon, "pixbuf", DEVICE_LIST_COLUMN_ICON, NULL); g_object_set (cell_icon, "xalign", 0.0, "ypad", 0, NULL); cell_name = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (column_name, cell_name, TRUE); gtk_tree_view_column_set_attributes (column_name, cell_name, "text", DEVICE_LIST_COLUMN_NAME, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (priv->treeview_devices), column_name); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->treeview_devices), -1, _("Node"), gtk_cell_renderer_text_new (), "text", DEVICE_LIST_COLUMN_NODE, NULL); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->treeview_devices), -1, _("Write CD-R"), gtk_cell_renderer_toggle_new (), "active", DEVICE_LIST_COLUMN_CDR, NULL); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->treeview_devices), -1, _("Write CD-RW"), gtk_cell_renderer_toggle_new (), "active", DEVICE_LIST_COLUMN_CDRW, NULL); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->treeview_devices), -1, _("Write DVD-R"), gtk_cell_renderer_toggle_new (), "active", DEVICE_LIST_COLUMN_DVDR, NULL); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->treeview_devices), -1, _("Write DVD-RAM"), gtk_cell_renderer_toggle_new (), "active", DEVICE_LIST_COLUMN_DVDRAM, NULL); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->treeview_devices), -1, _("Write Blu-ray"), gtk_cell_renderer_toggle_new (), "active", DEVICE_LIST_COLUMN_BD, NULL); hbox = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, BORDER); gtk_widget_show (hbox); priv->button_scan = xfce_gtk_button_new_mixed (GTK_STOCK_CDROM, _("Sc_an for devices")); gtk_box_pack_end (GTK_BOX (hbox), priv->button_scan, FALSE, FALSE, BORDER); g_signal_connect (G_OBJECT (priv->button_scan), "clicked", G_CALLBACK (scan_button_clicked_cb), obj); gtk_widget_show (priv->button_scan); gtk_icon_size_lookup (GTK_ICON_SIZE_DIALOG, &x, &y); icon = gtk_icon_theme_load_icon ( gtk_icon_theme_get_default(), "media-optical", x, GTK_ICON_LOOKUP_GENERIC_FALLBACK, NULL); if (!icon) icon = gtk_icon_theme_load_icon ( gtk_icon_theme_get_default(), "media-cdrom", x, GTK_ICON_LOOKUP_GENERIC_FALLBACK, NULL); if (!icon) icon = gtk_icon_theme_load_icon ( gtk_icon_theme_get_default(), GTK_STOCK_CDROM, x, GTK_ICON_LOOKUP_GENERIC_FALLBACK, NULL); gtk_list_store_append (icon_store, &iter); gtk_list_store_set (icon_store, &iter, SETTINGS_LIST_PIXBUF_COLUMN, icon, SETTINGS_LIST_TEXT_COLUMN, _("Devices"), SETTINGS_LIST_INDEX_COLUMN, idx, -1); if (icon) g_object_unref (G_OBJECT (icon)); exo_mutual_binding_new (G_OBJECT (priv->notebook), "page", G_OBJECT (priv->icon_bar), "active"); /* below the device list */ #if 0 priv->check_empty_speed_list = gtk_check_button_new_with_mnemonic (_("Show warning on _empty speed list")); gtk_box_pack_start (GTK_BOX (vbox2), priv->check_empty_speed_list, FALSE, FALSE, BORDER); gtk_widget_show (priv->check_empty_speed_list); #endif /* fifo */ vbox3 = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox3); frame = xfce_gtk_frame_box_new_with_content (_("FIFO buffer size (in kb)"), vbox3); gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, BORDER); gtk_widget_show (frame); priv->scale_fifo = gtk_hscale_new_with_range (0.0, FIFO_MAX_SIZE, 32.0); gtk_scale_set_value_pos (GTK_SCALE (priv->scale_fifo), GTK_POS_LEFT); gtk_range_set_value (GTK_RANGE (priv->scale_fifo), 0); gtk_box_pack_start (GTK_BOX (vbox3), priv->scale_fifo, FALSE, FALSE, BORDER/2); gtk_widget_show (priv->scale_fifo); /* action buttons */ button_close = gtk_button_new_from_stock ("gtk-close"); gtk_widget_show (button_close); gtk_dialog_add_action_widget (GTK_DIALOG (obj), button_close, GTK_RESPONSE_CLOSE); GTK_WIDGET_SET_FLAGS (button_close, GTK_CAN_DEFAULT); gtk_widget_grab_focus (button_close); gtk_widget_grab_default (button_close); g_signal_connect (G_OBJECT (obj), "response", G_CALLBACK (xfburn_preferences_dialog_response_cb), priv); refresh_devices_list (obj); g_object_unref (icon_store); }
int main(int argc, char *argv[]) { uid_t uid=getuid(), euid=geteuid(); if (uid==0) { GtkWidget *button1; GtkWidget *button2; GtkWidget *v_a_button; GtkWidget *v_f_button; GtkWidget *s_g_button; GtkWidget *view_log_button; GtkWidget *clear_log_button; GtkWidget *label_combo; GtkWidget *label_app; GtkWidget *label_data; GtkWidget *label_console; GtkWidget *menubar; GtkWidget *fileMenu; GtkWidget *fileMi; GtkWidget *helpMi; GtkWidget *vbox; /*Window Initilization*/ gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "User Utility"); gtk_window_set_default_size(GTK_WINDOW(window), 400, 600); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); gtk_widget_show(window); /* Layout set to fixed*/ fixed = gtk_fixed_new(); gtk_container_add(GTK_CONTAINER(window), fixed); /* Buttons Initilization*/ button1 = gtk_button_new_with_label("Add"); gtk_fixed_put(GTK_FIXED(fixed), button1, 350, 40); gtk_widget_set_size_request(button1, 80, 30); g_signal_connect(G_OBJECT(button1), "clicked",G_CALLBACK(add1_clicked), NULL); button2 = gtk_button_new_with_label("Add"); gtk_fixed_put(GTK_FIXED(fixed), button2, 350, 110); gtk_widget_set_size_request(button2, 80, 30); g_signal_connect(G_OBJECT(button2), "clicked",G_CALLBACK(add2_clicked), NULL); /*Entry boxs initilization*/ entry1 = gtk_entry_new(); gtk_fixed_put(GTK_FIXED(fixed), entry1, 10, 40); gtk_widget_set_size_request(entry1, 260, 30); entry2 = gtk_entry_new(); gtk_fixed_put(GTK_FIXED(fixed), entry2, 10,110); gtk_widget_set_size_request(entry2, 260, 30); /* File choosers Initilization */ c_button1 = gtk_file_chooser_button_new ("Choose fast",GTK_FILE_CHOOSER_ACTION_OPEN); gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (c_button1),g_get_home_dir()); gtk_fixed_put(GTK_FIXED(fixed), c_button1, 280, 40); gtk_widget_set_size_request(c_button1, 50, 30); g_signal_connect(G_OBJECT(c_button1), "file-set",G_CALLBACK(choose1_clicked), NULL); c_button2 = gtk_file_chooser_button_new ("Choose fast",GTK_FILE_CHOOSER_ACTION_OPEN); gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (c_button2),g_get_home_dir()); gtk_fixed_put(GTK_FIXED(fixed), c_button2, 280, 110); gtk_widget_set_size_request(c_button2, 50, 30); g_signal_connect(G_OBJECT(c_button2), "file-set",G_CALLBACK(choose2_clicked), NULL); /* Label Initilization */ label_app = gtk_label_new("Choose an application to add to the whitelist:"); gtk_fixed_put(GTK_FIXED(fixed), label_app, 10, 25); label_data = gtk_label_new("Choose a file to protect: "); gtk_fixed_put(GTK_FIXED(fixed), label_data, 10, 95); label_combo = gtk_label_new("Choose a hashing algo :"); gtk_fixed_put(GTK_FIXED(fixed), label_combo, 10, 167); label_console = gtk_label_new("Console Window : "); gtk_fixed_put(GTK_FIXED(fixed), label_console, 10, 245); /* Combobox Initilization */ combo = gtk_combo_box_text_new(); gtk_combo_box_text_append_text(GTK_COMBO_BOX(combo), "SHA1\0\0"); gtk_combo_box_text_append_text(GTK_COMBO_BOX(combo), "SHA2\0\0"); gtk_combo_box_text_append_text(GTK_COMBO_BOX(combo), "SHA256\0"); gtk_combo_box_text_append_text(GTK_COMBO_BOX(combo), "SHA512\0"); gtk_combo_box_text_append_text(GTK_COMBO_BOX(combo), "MD5\0\0"); gtk_fixed_put(GTK_FIXED(fixed), combo, 160, 160); gtk_widget_set_size_request(combo, 260, 30); g_signal_connect(G_OBJECT(combo), "changed", G_CALLBACK(combo_selected), NULL); /* View Buttons */ v_f_button = gtk_button_new_with_label("View Files"); gtk_fixed_put(GTK_FIXED(fixed), v_f_button, 250, 200); gtk_widget_set_size_request(v_f_button, 150, 30); g_signal_connect(G_OBJECT(v_f_button), "clicked",G_CALLBACK(v_a_clicked), NULL); v_a_button = gtk_button_new_with_label("View Apps"); gtk_fixed_put(GTK_FIXED(fixed), v_a_button, 10, 200); gtk_widget_set_size_request(v_a_button, 150, 30); g_signal_connect(G_OBJECT(v_a_button), "clicked",G_CALLBACK(v_a_clicked), NULL); /* Text view*/ textview = gtk_text_view_new(); gtk_text_view_set_editable(GTK_TEXT_VIEW(textview), FALSE); gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(textview),FALSE); gtk_fixed_put(GTK_FIXED(fixed), textview, 10, 265); gtk_widget_set_size_request(textview, 330, 250); /*Log Buttons */ view_log_button = gtk_button_new_with_label("View Log"); gtk_fixed_put(GTK_FIXED(fixed), view_log_button, 350, 270); gtk_widget_set_size_request(view_log_button, 60, 30); g_signal_connect(G_OBJECT(view_log_button), "clicked",G_CALLBACK(view_log_clicked), NULL); clear_log_button = gtk_button_new_with_label("Clear Log"); gtk_fixed_put(GTK_FIXED(fixed), clear_log_button, 350, 320); gtk_widget_set_size_request(clear_log_button, 60, 30); g_signal_connect(G_OBJECT(clear_log_button), "clicked",G_CALLBACK(clear_log_clicked), NULL); /*Generate Button */ s_g_button = gtk_button_new_with_label("Generate CFG"); gtk_fixed_put(GTK_FIXED(fixed), s_g_button, 150, 530); gtk_widget_set_size_request(s_g_button, 150, 30); g_signal_connect(G_OBJECT(s_g_button), "clicked",G_CALLBACK(g_clicked), NULL); /* Menu bar */ menubar = gtk_menu_bar_new(); fileMenu = gtk_menu_new(); fileMi = gtk_menu_item_new_with_label("File"); helpMi = gtk_menu_item_new_with_label("Help"); gtk_menu_item_set_submenu(GTK_MENU_ITEM(fileMi), fileMenu); gtk_menu_shell_append(GTK_MENU_SHELL(menubar), fileMi); gtk_menu_shell_append(GTK_MENU_SHELL(menubar), helpMi); gtk_fixed_put(GTK_FIXED(fixed), menubar, 0, 0); g_signal_connect(G_OBJECT(helpMi), "activate",G_CALLBACK(g_menu_help), NULL); gtk_widget_show_all(window); /* Close button signal */ g_signal_connect(G_OBJECT(window), "destroy",G_CALLBACK(gtk_main_quit), NULL); gtk_main(); } else{ printf("You are not a sudo user\nRun this application using sudo \n"); } return 0; }
//This function returns a table containing the elements of the page arranged GtkWidget * setPageLayout(GtkWidget* window, GtkWidget* browserForm){ GtkWidget * tableInitialing; GtkWidget *image; GtkWidget * mainSearchBox, *miniSearchBox, *centerSearchBox; GtkWidget *searchMainBut, *searchMiniBut, *searchCenterBut, *exitButton , *goBackBut, *stopBut, *frontBut; GtkWidget *scrolledWindow; GtkWidget *webView; GtkWidget *pageLayoutExpander; webView = webkit_web_view_new(); pageLayoutExpander = gtk_expander_new_with_mnemonic("V_iew page"); //creates a table with 20 rows and 17 columns tableInitialing = gtk_table_new( 30, 17, TRUE); exitButton = gtk_button_new_with_mnemonic("E_xit One click browser"); g_signal_connect_swapped( G_OBJECT(exitButton), "clicked", G_CALLBACK(gtk_widget_destroy), (gpointer) window); gtk_table_attach_defaults( GTK_TABLE(tableInitialing), exitButton, 0, 17, 29,30); //Start of expander setting //declaration of variables involved in setting position of tabs GtkWidget *settingExpander, *expanderVBox; GtkWidget *setTapUpRadio, *setTapDownRadio, *clearHistoryBut, *viewHistoryBut; GtkWidget *facebookLogo, *twitterLogo, *gmailLogo, *skypeLogo, *googleLogo; GtkWidget *facebookEventBox, *twitterEventBox, *gmailEventBox, *skypeEventBox, *googleEventBox; //Initialising variables setTapUpRadio = gtk_radio_button_new_with_label(NULL,"Set tab position up"); setTapDownRadio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(setTapUpRadio), "Set tab position down"); //Initialises the clearHistoryBut and associate a callback to it clearHistoryBut = gtk_button_new_with_mnemonic("_Clear history"); g_signal_connect(G_OBJECT(clearHistoryBut), "clicked", G_CALLBACK(clearHistory), NULL); viewHistoryBut = gtk_button_new_with_mnemonic("_View history"); g_signal_connect_swapped(G_OBJECT(viewHistoryBut),"clicked", G_CALLBACK(viewHistory), NULL); //Initialises the expander and the vbox settingExpander = gtk_expander_new_with_mnemonic("_Settings"); expanderVBox = gtk_vbox_new(TRUE, 0); //Adds radio buttons to the vbox gtk_box_pack_start_defaults( GTK_BOX(expanderVBox), setTapUpRadio); gtk_box_pack_start_defaults( GTK_BOX(expanderVBox), setTapDownRadio); gtk_box_pack_start_defaults( GTK_BOX(expanderVBox), clearHistoryBut); gtk_box_pack_start_defaults( GTK_BOX(expanderVBox), viewHistoryBut); //Linking signals of radio buttons to the respective callbacks g_signal_connect_swapped( G_OBJECT(setTapUpRadio), "toggled", G_CALLBACK(setTapUp), browserForm); g_signal_connect_swapped( G_OBJECT(setTapDownRadio), "toggled", G_CALLBACK(setTapDown), browserForm); gtk_container_add( GTK_CONTAINER(settingExpander), expanderVBox); gtk_table_attach_defaults( GTK_TABLE(tableInitialing),settingExpander, 0,3,20,24); //End of expander setting goBackBut = gtk_button_new_with_label(" <-- "); gtk_widget_set_size_request(goBackBut, 10, 25); gtk_table_attach_defaults( GTK_TABLE(tableInitialing), goBackBut, 1, 2, 1, 2); g_signal_connect_swapped(goBackBut, "clicked", G_CALLBACK(back), webView); stopBut = gtk_button_new_with_label(" X "); gtk_widget_set_size_request(stopBut, 10, 25); gtk_table_attach_defaults( GTK_TABLE(tableInitialing), stopBut, 2, 3, 1, 2); g_signal_connect_swapped(stopBut, "clicked", G_CALLBACK(stop), webView); frontBut = gtk_button_new_with_label(" --> "); gtk_widget_set_size_request(frontBut, 10, 25); gtk_table_attach_defaults( GTK_TABLE(tableInitialing), frontBut, 16, 17, 1, 2); g_signal_connect_swapped(frontBut, "clicked", G_CALLBACK(forward), webView); //This patch of code initiates autocompletion of the search box GtkEntryCompletion *completion; GtkTreeIter *iter; GtkListStore *store_list; FILE * historyPtr; store_list = gtk_list_store_new(1,G_TYPE_STRING); completion = gtk_entry_completion_new(); if( (historyPtr = fopen("History/History.htm","r+")) == NULL) g_print("Error"); gchar historyString[100]; while( !feof(historyPtr)){ fscanf(historyPtr,"%s",historyString); gtk_list_store_append(store_list, iter); gtk_list_store_set(store_list, iter, 0, historyString, -1); } fclose(historyPtr); gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(store_list)); gtk_entry_completion_set_text_column(completion, 0); mainSearchBox = gtk_entry_new(); gtk_entry_set_completion(GTK_ENTRY(mainSearchBox), completion); gtk_widget_set_size_request(mainSearchBox, 500, 25); gtk_table_attach_defaults( GTK_TABLE(tableInitialing), mainSearchBox, 3, 15, 1, 2 ); g_signal_connect_swapped(mainSearchBox, "activate", G_CALLBACK(activate), webView); searchMainBut = gtk_button_new_with_mnemonic("Sear_ch"); gtk_widget_set_size_request(searchMainBut, 10,15); gtk_table_attach_defaults( GTK_TABLE(tableInitialing), searchMainBut, 15, 16, 1, 2 ); g_signal_connect_swapped(searchMainBut, "clicked", G_CALLBACK(setUri), mainSearchBox); g_signal_connect_swapped(searchMainBut, "clicked", G_CALLBACK(go), webView); //g_signal_connect_swapped(searchMainBut, "clicked", G_CALLBACK(initialiseEntryCompletion), completion); //Linking callbacks to signals emitted by webview widget g_signal_connect(WEBKIT_WEB_VIEW(webView),"load-progress-changed",G_CALLBACK(progress),mainSearchBox); g_signal_connect(WEBKIT_WEB_VIEW(webView),"load-finished",G_CALLBACK(finished),mainSearchBox); scrolledWindow = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(scrolledWindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(scrolledWindow), webView); gtk_widget_show_all(scrolledWindow); //PageLayout expander //gtk_widget_set_sensitive(pageLayoutExpander, FALSE); gtk_container_add( GTK_CONTAINER(pageLayoutExpander), scrolledWindow); gtk_table_attach_defaults(GTK_TABLE(tableInitialing), pageLayoutExpander, 0, 17, 2, 29); g_signal_connect_swapped(WEBKIT_WEB_VIEW(webView),"load-finished",G_CALLBACK(viewSearchedPage),pageLayoutExpander); image = gtk_image_new_from_file("images/OneClickLogo.png"); GtkWidget* imageEventBox = initialiseEventBox(image); g_signal_connect( G_OBJECT(imageEventBox), "button_press_event", G_CALLBACK(searchOneClick), webView); g_signal_connect( G_OBJECT(imageEventBox), "button_press_event", G_CALLBACK(logoClicked), mainSearchBox); gtk_table_attach_defaults(GTK_TABLE(tableInitialing), imageEventBox, 3, 14, 14, 24); //Adding pictures of some social media to the browser's home page facebookLogo = gtk_image_new_from_file("images/facebook.jpg"); skypeLogo = gtk_image_new_from_file("images/skype.jpg"); twitterLogo = gtk_image_new_from_file("images/twitter.jpg"); gmailLogo = gtk_image_new_from_file("images/gmail.jpg"); googleLogo = gtk_image_new_from_file("images/google.jpg"); //Adding event handlers to images facebookEventBox = initialiseEventBox(facebookLogo); g_signal_connect( G_OBJECT(facebookEventBox), "button_press_event", G_CALLBACK(searchFacebook), webView); g_signal_connect( G_OBJECT(facebookEventBox), "button_press_event", G_CALLBACK(facebookLogoClicked), mainSearchBox); gtk_table_attach_defaults(GTK_TABLE(tableInitialing), facebookEventBox, 4, 6, 24, 28 ); gmailEventBox = initialiseEventBox(gmailLogo); g_signal_connect( G_OBJECT(gmailEventBox), "button_press_event", G_CALLBACK(searchGmail), webView); g_signal_connect( G_OBJECT(gmailEventBox), "button_press_event", G_CALLBACK(gmailLogoClicked), mainSearchBox); gtk_table_attach_defaults(GTK_TABLE(tableInitialing), gmailEventBox, 6, 8, 24, 28 ); twitterEventBox = initialiseEventBox(twitterLogo); g_signal_connect( G_OBJECT(twitterEventBox), "button_press_event", G_CALLBACK(searchTwitter), webView); g_signal_connect( G_OBJECT(twitterEventBox), "button_press_event", G_CALLBACK(twitterLogoClicked), mainSearchBox); gtk_table_attach_defaults(GTK_TABLE(tableInitialing), twitterEventBox, 8, 10, 24, 28 ); skypeEventBox = initialiseEventBox(skypeLogo); g_signal_connect( G_OBJECT(skypeEventBox), "button_press_event", G_CALLBACK(searchSKype), webView); g_signal_connect( G_OBJECT(skypeEventBox), "button_press_event", G_CALLBACK(skypeLogoClicked), mainSearchBox); gtk_table_attach_defaults(GTK_TABLE(tableInitialing), skypeEventBox, 10, 12, 24, 28 ); googleEventBox = initialiseEventBox(googleLogo); g_signal_connect( G_OBJECT(googleEventBox), "button_press_event", G_CALLBACK(searchGoogle), webView); g_signal_connect( G_OBJECT(googleEventBox), "button_press_event", G_CALLBACK(googleLogoClicked), mainSearchBox); gtk_table_attach_defaults(GTK_TABLE(tableInitialing), googleEventBox, 12, 14, 24, 28 ); //This patch of code implements the file chooser button that opens files on the user's computer GtkWidget *openFileChooser; openFileChooser = gtk_file_chooser_button_new("Select an html document to open",GTK_FILE_CHOOSER_ACTION_OPEN); g_signal_connect_swapped(G_OBJECT(openFileChooser), "selection_changed", G_CALLBACK(openFile), webView); //gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(openFileChooser), g_get_home_dir()); gtk_table_attach_defaults(GTK_TABLE(tableInitialing), openFileChooser, 4, 12, 0, 1 ); GtkFileFilter *filter; filter = gtk_file_filter_new(); gtk_file_filter_set_name (filter, "HTML Files"); gtk_file_filter_add_pattern (filter, "*.html"); gtk_file_filter_add_pattern (filter, "*.htm"); gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (openFileChooser), filter); return tableInitialing; }
GtkWidget * palette_import_dialog_new (GimpContext *context) { ImportDialog *dialog; GimpGradient *gradient; GtkWidget *button; GtkWidget *main_hbox; GtkWidget *frame; GtkWidget *vbox; GtkWidget *table; GtkWidget *abox; GtkSizeGroup *size_group; GSList *group = NULL; g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL); gradient = gimp_context_get_gradient (context); dialog = g_slice_new0 (ImportDialog); dialog->import_type = GRADIENT_IMPORT; dialog->context = gimp_context_new (context->gimp, "Palette Import", context); dialog->dialog = gimp_dialog_new (_("Import a New Palette"), "gimp-palette-import", NULL, 0, gimp_standard_help_func, GIMP_HELP_PALETTE_IMPORT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL); button = gtk_dialog_add_button (GTK_DIALOG (dialog->dialog), _("_Import"), GTK_RESPONSE_OK); gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_icon_name ("gtk-convert", GTK_ICON_SIZE_BUTTON)); gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog->dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); g_object_set_data_full (G_OBJECT (dialog->dialog), "palette-import-dialog", dialog, (GDestroyNotify) palette_import_free); g_signal_connect (dialog->dialog, "response", G_CALLBACK (palette_import_response), dialog); gimp_dnd_viewable_dest_add (dialog->dialog, GIMP_TYPE_GRADIENT, import_dialog_drop_callback, dialog); gimp_dnd_viewable_dest_add (dialog->dialog, GIMP_TYPE_IMAGE, import_dialog_drop_callback, dialog); main_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); gtk_container_set_border_width (GTK_CONTAINER (main_hbox), 12); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog->dialog))), main_hbox, TRUE, TRUE, 0); gtk_widget_show (main_hbox); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); gtk_box_pack_start (GTK_BOX (main_hbox), vbox, TRUE, TRUE, 0); gtk_widget_show (vbox); /* The "Source" frame */ frame = gimp_frame_new (_("Select Source")); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); table = gtk_table_new (5, 2, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 6); gtk_table_set_row_spacings (GTK_TABLE (table), 6); gtk_container_add (GTK_CONTAINER (frame), table); gtk_widget_show (table); dialog->gradient_radio = gtk_radio_button_new_with_mnemonic (group, _("_Gradient")); group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (dialog->gradient_radio)); gtk_table_attach (GTK_TABLE (table), dialog->gradient_radio, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (dialog->gradient_radio); g_signal_connect (dialog->gradient_radio, "toggled", G_CALLBACK (palette_import_grad_callback), dialog); dialog->image_radio = gtk_radio_button_new_with_mnemonic (group, _("I_mage")); group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (dialog->image_radio)); gtk_table_attach (GTK_TABLE (table), dialog->image_radio, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (dialog->image_radio); g_signal_connect (dialog->image_radio, "toggled", G_CALLBACK (palette_import_image_callback), dialog); gtk_widget_set_sensitive (dialog->image_radio, ! gimp_container_is_empty (context->gimp->images)); dialog->sample_merged_toggle = gtk_check_button_new_with_mnemonic (_("Sample _Merged")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->sample_merged_toggle), TRUE); gtk_table_attach (GTK_TABLE (table), dialog->sample_merged_toggle, 1, 2, 2, 3, GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (dialog->sample_merged_toggle); g_signal_connect_swapped (dialog->sample_merged_toggle, "toggled", G_CALLBACK (palette_import_make_palette), dialog); dialog->selection_only_toggle = gtk_check_button_new_with_mnemonic (_("_Selected Pixels only")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->selection_only_toggle), FALSE); gtk_table_attach (GTK_TABLE (table), dialog->selection_only_toggle, 1, 2, 3, 4, GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (dialog->selection_only_toggle); g_signal_connect_swapped (dialog->selection_only_toggle, "toggled", G_CALLBACK (palette_import_make_palette), dialog); dialog->file_radio = gtk_radio_button_new_with_mnemonic (group, _("Palette _file")); group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (dialog->image_radio)); gtk_table_attach (GTK_TABLE (table), dialog->file_radio, 0, 1, 4, 5, GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (dialog->file_radio); g_signal_connect (dialog->file_radio, "toggled", G_CALLBACK (palette_import_file_callback), dialog); size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL); /* The gradient menu */ dialog->gradient_combo = gimp_container_combo_box_new (gimp_data_factory_get_container (context->gimp->gradient_factory), dialog->context, 24, 1); gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, NULL, 0.0, 0.5, dialog->gradient_combo, 1, FALSE); gtk_size_group_add_widget (size_group, dialog->gradient_combo); /* The image menu */ dialog->image_combo = gimp_container_combo_box_new (context->gimp->images, dialog->context, 24, 1); gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, NULL, 0.0, 0.5, dialog->image_combo, 1, FALSE); gtk_size_group_add_widget (size_group, dialog->image_combo); /* Palette file name entry */ dialog->file_chooser = gtk_file_chooser_button_new (_("Select Palette File"), GTK_FILE_CHOOSER_ACTION_OPEN); gimp_table_attach_aligned (GTK_TABLE (table), 0, 4, NULL, 0.0, 0.5, dialog->file_chooser, 1, FALSE); gtk_size_group_add_widget (size_group, dialog->file_chooser); g_object_unref (size_group); /* The "Import" frame */ frame = gimp_frame_new (_("Import Options")); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); table = gtk_table_new (4, 3, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 6); gtk_table_set_row_spacings (GTK_TABLE (table), 6); gtk_container_add (GTK_CONTAINER (frame), table); gtk_widget_show (table); /* The source's name */ dialog->entry = gtk_entry_new (); gtk_entry_set_text (GTK_ENTRY (dialog->entry), gradient ? gimp_object_get_name (gradient) : _("New import")); gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, _("Palette _name:"), 0.0, 0.5, dialog->entry, 2, FALSE); /* The # of colors */ dialog->num_colors = GTK_ADJUSTMENT (gimp_scale_entry_new (GTK_TABLE (table), 0, 1, _("N_umber of colors:"), -1, 5, 256, 2, 10000, 1, 10, 0, TRUE, 0.0, 0.0, NULL, NULL)); g_signal_connect_swapped (dialog->num_colors, "value-changed", G_CALLBACK (palette_import_make_palette), dialog); /* The columns */ dialog->columns = GTK_ADJUSTMENT (gimp_scale_entry_new (GTK_TABLE (table), 0, 2, _("C_olumns:"), -1, 5, 16, 0, 64, 1, 8, 0, TRUE, 0.0, 0.0, NULL, NULL)); g_signal_connect (dialog->columns, "value-changed", G_CALLBACK (palette_import_columns_changed), dialog); /* The interval */ dialog->threshold = GTK_ADJUSTMENT (gimp_scale_entry_new (GTK_TABLE (table), 0, 3, _("I_nterval:"), -1, 5, 1, 1, 128, 1, 8, 0, TRUE, 0.0, 0.0, NULL, NULL)); g_signal_connect_swapped (dialog->threshold, "value-changed", G_CALLBACK (palette_import_make_palette), dialog); /* The "Preview" frame */ frame = gimp_frame_new (_("Preview")); gtk_box_pack_start (GTK_BOX (main_hbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_container_add (GTK_CONTAINER (frame), vbox); gtk_widget_show (vbox); abox = gtk_alignment_new (0.0, 0.0, 0.0, 0.0); gtk_box_pack_start (GTK_BOX (vbox), abox, FALSE, FALSE, 0); gtk_widget_show (abox); dialog->preview = gimp_view_new_full_by_types (dialog->context, GIMP_TYPE_VIEW, GIMP_TYPE_PALETTE, 192, 192, 1, TRUE, FALSE, FALSE); gtk_container_add (GTK_CONTAINER (abox), dialog->preview); gtk_widget_show (dialog->preview); dialog->no_colors_label = gtk_label_new (_("The selected source contains no colors.")); gtk_widget_set_size_request (dialog->no_colors_label, 194, -1); gtk_label_set_line_wrap (GTK_LABEL (dialog->no_colors_label), TRUE); gimp_label_set_attributes (GTK_LABEL (dialog->no_colors_label), PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC, -1); gtk_box_pack_start (GTK_BOX (vbox), dialog->no_colors_label, FALSE, FALSE, 0); gtk_widget_show (dialog->no_colors_label); /* keep the dialog up-to-date */ g_signal_connect (context->gimp->images, "add", G_CALLBACK (palette_import_image_add), dialog); g_signal_connect (context->gimp->images, "remove", G_CALLBACK (palette_import_image_remove), dialog); g_signal_connect (dialog->context, "gradient-changed", G_CALLBACK (palette_import_gradient_changed), dialog); g_signal_connect (dialog->context, "image-changed", G_CALLBACK (palette_import_image_changed), dialog); g_signal_connect (dialog->file_chooser, "selection-changed", G_CALLBACK (palette_import_filename_changed), dialog); palette_import_grad_callback (dialog->gradient_radio, dialog); return dialog->dialog; }