void command_get_selection(doc *d, char **args, int nargs) { if (nargs != 1) return get_selection_usage(); if (!strcmp(args[0], "primary")) return get_selection(d, 1); if (!strcmp(args[0], "clipboard")) return get_selection(d, 0); return get_selection_usage(); }
//------------------------------------------------------------------------------ void ListModelWrapper::handle_popup(const int x, const int y, const int time, GdkEventButton* evb) { Gtk::TreeModel::Path path; Gtk::TreeView::Column *column(0); int cell_x(-1); int cell_y(-1); ListModelWrapper::NodeIdArray list = get_selection(); bool there_is_path_at_pos = false; if (_treeview) there_is_path_at_pos = _treeview->get_path_at_pos(x, y, path, column, cell_x, cell_y); else if (_iconview) { path = _iconview->get_path_at_pos(x, y); there_is_path_at_pos = path.gobj() && !path.empty(); } if ( there_is_path_at_pos ) { // Check that @path is on selection, otherwise add @path to selection bec::NodeId node = get_node_for_path(path); // list stores current selection bool path_at_pos_is_in_selection = false; for (int i = list.size() - 1; i >= 0; --i) { if (node == list[i]) { path_at_pos_is_in_selection = true; break; } } if (!path_at_pos_is_in_selection) { // Add it, if user holds Ctrl while clicking right mouse btn // Otherwise clear selection, and select only @path const bool clear_selection = evb ? (!(evb->state & GDK_CONTROL_MASK)) : false; if (clear_selection) { if (_treeview) _treeview->get_selection()->unselect_all(); if (_iconview) _iconview->unselect_all(); } if (_treeview) _treeview->get_selection()->select(path); if (_iconview) _iconview->select_path(path); list = get_selection(); } } if (!_context_menu) _context_menu = new Gtk::Menu(); run_menu_and_forward_action((*_tm)->get_popup_items_for_nodes(list), x, y, time, *_tm, list, _fe_menu_handler, _context_menu); }
int BC_FileBoxFilterMenu::handle_event() { filebox->filter_text->update( get_selection(filebox->column_of_type(FILEBOX_NAME), 0)->get_text()); filebox->update_filter( get_selection(filebox->column_of_type(FILEBOX_NAME), 0)->get_text()); return 0; }
int BC_FileBoxRecent::handle_event() { if(get_selection(0, 0) >= 0) { filebox->submit_dir(get_selection(0, 0)->get_text()); } return 1; }
void MYMENU_FormatCombineCells() { // get the start/end info int start_row, start_col, end_row, end_col; get_selection( &start_row, &start_col, &end_row, &end_col ); // get the left top cell CellInfo* info = get_cell_info( table, start_row, start_col ); CellInfo* infocopy; if ( info == NULL ) { // empty cell, create a new one infocopy = create_cell_info(); infocopy->combine_right = end_col - start_col; infocopy->combine_bottom = end_row - start_row; } else { // create a new cell copy infocopy = clone_cell_info( info ); // modify the exist one infocopy->combine_right = end_col - start_col; infocopy->combine_bottom = end_row - start_row; } // history history_append( start_row, start_col ); free_redo_history(); // update insert_cell_info( table, start_row, start_col, infocopy ); update_table_view(); }
void MYMENU_ViewSplitView() { static int splitview = 0; if ( splitview == 0 ) { // get the cell where to split int start_row = 0; int start_col = 0; int end_row, end_col; get_selection( &start_row, &start_col, &end_row, &end_col ); // get x/y pos int xx = current_view()->edge[ VIEW_LEFT ] + col_zero_width; int yy = current_view()->edge[ VIEW_TOP ] + row_zero_height; int p; for ( p = current_view()->col_head; p < start_col; ++p ) xx += col_width_of( p ) * ratio; for ( p = current_view()->row_head; p < start_row; ++p ) yy += row_height_of( p ) * ratio; // NOTE: always shift a bit to let the user select the last row/col if ( xx != current_view()->edge[ VIEW_LEFT ] + col_zero_width ) { split_view( xx + 1, -1 ); splitview = 1; } if ( yy != current_view()->edge[ VIEW_TOP ] + row_zero_height ) { split_view( -1, yy + 1 ); splitview = 1; } } else { restore_view(); splitview = 0; } update_selection_rect(); update_table_view(); }
void MYMENU_EditPaste() { if ( editmode == 1 ) { SendMessageW( hEdit, WM_PASTE, 0, 0 ); } else { // get the cell where to paste on int start_row = 0; int start_col = 0; int end_row, end_col; get_selection( &start_row, &start_col, &end_row, &end_col ); // let us extract cells from stream int row = 0; int col = 0; CellInfo* info = iterate_stream_cell( &row, &col ); // base row and col, used to form relative rows and cols int base_row = row; int base_col = col; while ( info != NULL ) { // history history_append( start_row + row - base_row, start_col + col - base_col ); free_redo_history(); insert_cell_info( table, start_row + row - base_row, start_col + col - base_col, info ); info = iterate_stream_cell( &row, &col ); } auto_adapt_layout( table ); update_selection_rect(); update_table_view(); } }
static int get_cmd_selection(char *cmd, int hostgroup) { char *semi_colon; int ret; /* * only global commands have no arguments at all. Those * shouldn't end up here, but if they do we forward them * to peers and pollers */ if (!cmd) { ldebug("Global command [%s] ended up in get_cmd_selection()", cmd); return DEST_PEERS_POLLERS; } semi_colon = strchr(cmd, ';'); if (semi_colon) *semi_colon = '\0'; if (!hostgroup) { ret = get_selection(cmd); } else { ret = get_hostgroup_selection(cmd); } if (semi_colon) *semi_colon = ';'; return ret; }
void Tree::deleteclass() { Gtk::TreeModel::iterator iter = get_selection()->get_selected(); if( *iter ) { Glib::ustring str = (*iter)[m_Columns.m_col_crn]; std::ifstream coursefile( course_file ); std::ofstream tempfile( course_temp ); if( coursefile.is_open() && tempfile.is_open() ) { while( true ) { char buf[10], line[256]; coursefile >> buf; // Get crn coursefile.getline( line, 255 ); // Get rest of line if( coursefile.eof() ) break; if( str.compare( buf ) == 0 ) // Skip if crns are equal continue; tempfile << buf << line << std::endl; // Write to temp } coursefile.close(); tempfile.close(); std::remove( course_file ); // Remove and rename file std::rename( course_temp, course_file ); } m_refTreeModel->erase( iter ); // Erase from tree } }
void ui_menu_file_create::populate() { astring buffer; const image_device_format *format; const char *new_image_name; /* append the "New Image Name" item */ if (get_selection() == ITEMREF_NEW_IMAGE_NAME) { buffer.cat(filename_buffer).cat("_"); new_image_name = buffer; } else { new_image_name = filename_buffer; } item_append("New Image Name:", new_image_name, 0, ITEMREF_NEW_IMAGE_NAME); /* do we support multiple formats? */ format = image->device_get_creatable_formats(); if (ENABLE_FORMATS && (format != NULL)) { item_append("Image Format:", current_format->m_description, 0, ITEMREF_FORMAT); current_format = format; } /* finish up the menu */ item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); item_append("Create", NULL, 0, ITEMREF_CREATE); customtop = ui_get_line_height(machine()) + 3.0f * UI_BOX_TB_BORDER; }
int FrameRatePulldown::handle_event() { char *text = get_selection(0, 0)->get_text(); output->update(text); output->handle_event(); return 1; }
void unindent(editor_t *ed, char *indentation) { int start, end, i, newline, ch, shrinkage, topofs; char *buffer, *p; int width = strlen(indentation); int pos = ed->linepos + ed->col; if (!get_selection(ed, &start, &end)) return; buffer = neutron_malloc(end - start); if (!buffer) return; newline = 1; p = buffer; i = start; shrinkage = 0; topofs = 0; while (i < end) { if (newline) { newline = 0; if (compare(ed, indentation, i, width)) { i += width; shrinkage += width; if (i < ed->toppos) topofs -= width; continue; } } ch = get(ed, i++); *p++ = ch; if (ch == '\n') newline = 1; } if (!shrinkage) { neutron_free(buffer); return; } replace(ed, start, end - start, buffer, p - buffer, 1); neutron_free(buffer); if (ed->anchor < pos) { pos -= shrinkage; } else { ed->anchor -= shrinkage; } ed->toppos += topofs; ed->linepos = line_start(ed, pos); ed->col = ed->lastcol = pos - ed->linepos; ed->refresh = 1; adjust(ed); }
/* This is called automatically when a drag is initiated * It build a URI list of the selected filenames to set as the drag data */ static void clist_drag_data_get(GtkWidget *widget, GdkDragContext *context, GtkSelectionData *data, guint info_arg, guint time, FileView *view) { FileInfo *info; GList *base, *tmp; GString *uri_list = g_string_sized_new(PATH_MAX); disable_refresh(); base = tmp = get_selection(view); for (; tmp != NULL; tmp = tmp->next) { info = tmp->data; g_string_sprintfa(uri_list, "file:%s/%s\r\n", view->dir, info->filename); } gtk_selection_data_set(data, data->target, 8, uri_list->str, uri_list->len); g_string_free(uri_list, TRUE); g_list_free(base); reenable_refresh(); }
int main() { int choice = -1; //choice of oepration to be performed char cont[100]; //continue to main menu? int i_cont; //intialise memory init_mem(); do { //display main menu disp_menu(); //operation selection do { choice = get_selection(); }while(!is_valid_choice(choice)); //perform selected operation perform_opn(choice); //continue confirmation printf("\n\nContinue to main menu? (1 = yes, any other character = no) : "); scanf("%s",cont); i_cont = atoi(cont); }while(i_cont == 1); //destroy memory destroy_mem(); printf("\n\nProgram Exited Successfully!!\n\n"); return 0; }
void ui_menu_barcode_reader::populate() { if (current_device()) { std::string buffer; const char *new_barcode; // selected device item_append(current_display_name().c_str(), "", current_display_flags(), ITEMREF_SELECT_READER); // append the "New Barcode" item if (get_selection() == ITEMREF_NEW_BARCODE) { buffer.append(m_barcode_buffer); new_barcode = buffer.c_str(); } else { new_barcode = m_barcode_buffer; } item_append("New Barcode:", new_barcode, 0, ITEMREF_NEW_BARCODE); // finish up the menu item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); item_append("Enter Code", NULL, 0, ITEMREF_ENTER_BARCODE); customtop = machine().ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } }
void ui_menu_file_create::populate() { std::string buffer; const image_device_format *format; const char *new_image_name; // append the "New Image Name" item if (get_selection() == ITEMREF_NEW_IMAGE_NAME) { buffer.append(m_filename_buffer).append("_"); new_image_name = buffer.c_str(); } else { new_image_name = m_filename_buffer; } item_append("New Image Name:", new_image_name, 0, ITEMREF_NEW_IMAGE_NAME); // do we support multiple formats? if (ENABLE_FORMATS) format = m_image->formatlist(); if (ENABLE_FORMATS && (format != NULL)) { item_append("Image Format:", m_current_format->description(), 0, ITEMREF_FORMAT); m_current_format = format; } // finish up the menu item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); item_append("Create", NULL, 0, ITEMREF_CREATE); customtop = machine().ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; }
static void on_find_tag(GtkMenuItem *menuitem, gpointer user_data) { gchar *selection; GtkWidget *entry; create_dialog_find_file(); entry = gtk_bin_get_child(GTK_BIN(s_ft_dialog.combo)); selection = get_selection(); if (selection) gtk_entry_set_text(GTK_ENTRY(entry), selection); g_free(selection); gtk_widget_grab_focus(entry); if (gtk_dialog_run(GTK_DIALOG(s_ft_dialog.widget)) == GTK_RESPONSE_ACCEPT) { const gchar *name; gboolean case_sensitive, declaration; MatchType match_type; name = gtk_entry_get_text(GTK_ENTRY(entry)); case_sensitive = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(s_ft_dialog.case_sensitive)); declaration = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(s_ft_dialog.declaration)); match_type = gtk_combo_box_get_active(GTK_COMBO_BOX(s_ft_dialog.combo_match)); ui_combo_box_add_to_history(GTK_COMBO_BOX_TEXT(s_ft_dialog.combo), name, 0); find_tags(name, declaration, case_sensitive, match_type); } gtk_widget_hide(s_ft_dialog.widget); }
void w_plugins::item_selected() { Plugin& plugin = m_plugins[get_selection()]; plugin.enabled = !plugin.enabled; dirty = true; get_owning_dialog()->draw_dirty_widgets(); }
void cb_page_widget_image_selected(ZathuraPage* page, GdkPixbuf* pixbuf, void* data) { g_return_if_fail(page != NULL); g_return_if_fail(pixbuf != NULL); g_return_if_fail(data != NULL); zathura_t* zathura = data; GdkAtom* selection = get_selection(zathura); if (selection != NULL) { gtk_clipboard_set_image(gtk_clipboard_get(*selection), pixbuf); bool notification = true; girara_setting_get(zathura->ui.session, "selection-notification", ¬ification); if (notification == true) { char* target = NULL; girara_setting_get(zathura->ui.session, "selection-clipboard", &target); char* escaped_text = g_markup_printf_escaped( _("Copied selected image to selection %s"), target); g_free(target); girara_notify(zathura->ui.session, GIRARA_INFO, "%s", escaped_text); } g_free(selection); } }
double GA::evaluate_individual_fitness(Individual* indv) { double* cuts = indv->get_cuts(); // if it is already calculated, return significance from histogram long bin_z = hist_z->GetBin(cuts, false); if (bin_z >= 0) { double s = hist_s->GetBinContent(bin_z); indv->set_signal(s); double b = hist_b->GetBinContent(bin_z); indv->set_background(b); double significance = 0.; if (s < ZERO || b < ZERO || b < m_opt_background_min || b > m_opt_background_max) significance = 0.; else significance = hist_z->GetBinContent(bin_z); indv->set_fitness(significance); return significance; } // Calculate significance TString selection = get_selection(indv); double s = get_events(m_signal_chain, selection); double b = get_events(m_background_chain, selection); if (s < 0) s = 0.; if (b < 0) b = 0.; indv->set_signal(s); indv->set_background(b); double significance = 0.; if (m_opt_type == 1) significance = get_s_over_b(s, b); else if (m_opt_type == 2) significance = get_s_over_total(s, b); else if (m_opt_type == 3) significance = get_significance(s, b, m_opt_background_syst); if (s < ZERO || b < ZERO || b < m_opt_background_min || b > m_opt_background_max) significance = 0.; hist_s->SetBinContent(hist_s->GetBin(cuts), s); hist_b->SetBinContent(hist_b->GetBin(cuts), b); hist_z->SetBinContent(hist_z->GetBin(cuts), significance); indv->set_fitness(significance); return significance; }
int FormatFormat::handle_event() { if(get_selection(0, 0) >= 0) { int new_format = File::strtoformat(format->plugindb, get_selection(0, 0)->get_text()); if(new_format != format->asset->format) { format->asset->format = new_format; format->format_text->update(get_selection(0, 0)->get_text()); format->update_extension(); format->close_format_windows(); if (format->path_recent) format->path_recent->load_items (FILE_FORMAT_PREFIX(format->asset->format)); } } return 1; }
static void on_find_definition(GtkMenuItem *menuitem, gpointer user_data) { gchar *name; name = get_selection(); if (name) find_tags(name, FALSE, TRUE, MATCH_FULL); g_free(name); }
AIErr twirl_get_parms( AIFilterMessage *pb ) { parms_t **parms; ASBoolean canceled = false; parms_t orig_parms; AIErr error; short dialog_id; AIArtHandle **matches; long count, total_segments=4; // AMPDialogRef dlgPtr; // long item; error = get_selection( &matches, &count, &total_segments, false ); if ( error ) goto errorTag; sAIMDMemory->MdMemoryDisposeHandle((AIMdMemoryHandle)matches); if ( total_segments < 10 ) dialog_id = kTwirlFewDLOG; else dialog_id = kTwirlDLOG; parms = (parms_t **) pb->parameters; if ( !parms ) { error = sAIMDMemory->MdMemoryNewHandle( sizeof(parms_t), (AIMdMemoryHandle *)&pb->parameters); if ( error ) goto errorTag; if ( !pb->parameters ) { error = kOutOfMemoryErr; goto errorTag; } parms = (parms_t **) pb->parameters; (**parms).d_angle = DEFAULT_ANGLE; (**parms).bPositionSet = FALSE; } orig_parms = **parms; canceled = kDlgOKButton != sADMDialog->Modal(pb->d.self, "Twirl Plug-in Dialog", dialog_id, kADMModalDialogStyle, PluginDlgInitProc, (ADMUserData)*parms, 0); if (canceled) // then Cancel button was hit. { **parms = orig_parms; } return (canceled ? kCanceledErr : kNoErr); errorTag: return (error); }
int main() { do{ clear_screen(); show_menu(); run_selection(get_selection()); }while(pause()); return 0; }
AIErr twirl_get_parms( AILiveEffectEditParamMessage *pb ) { parms_t parms; ASBoolean canceled = false; parms_t orig_parms; AIErr error; short dialog_id; AIArtHandle **matches; long count, total_segments=4; AILiveEffectParameters liveEffectDictionary = pb->parameters; AIDictKey dictKey; error = get_selection( &matches, &count, &total_segments, false ); if ( error ) goto errorTag; sAIMDMemory->MdMemoryDisposeHandle((AIMdMemoryHandle)matches); if ( total_segments < 10 ) dialog_id = kTwirlFewDLOG; else dialog_id = kTwirlDLOG; dictKey = sDictionary->Key("angle"); if ( sDictionary->IsKnown( liveEffectDictionary, dictKey ) ) { sDictionary->GetRealEntry( liveEffectDictionary, dictKey, &(parms.d_angle) ); dictKey = sDictionary->Key("position"); sDictionary->GetBooleanEntry( liveEffectDictionary, dictKey, &(parms.bPositionSet) ); } else { parms.d_angle = DEFAULT_ANGLE; parms.bPositionSet = FALSE; } orig_parms = parms; canceled = kDlgOKButton != sADMDialog->Modal(pb->d.self, "Twirl Plug-in Dialog", dialog_id, kADMModalDialogStyle, PluginDlgInitProc, (ADMUserData)&parms, 0); if (canceled) // then Cancel button was hit. { parms = orig_parms; } else { dictKey = sDictionary->Key("angle"); sDictionary->SetRealEntry( liveEffectDictionary, dictKey, parms.d_angle ); dictKey = sDictionary->Key("position"); sDictionary->SetBooleanEntry( liveEffectDictionary, dictKey, parms.bPositionSet ); sLiveEffect->UpdateParameters( pb->context ); } return (canceled ? kCanceledErr : kNoErr); errorTag: return (error); }
static void list_selection_changed_callback (GtkTreeSelection *selection, gpointer user_data) { FMListView *view = FM_LIST_VIEW (user_data); if (view->details->selection != NULL) gof_file_list_free (view->details->selection); view->details->selection = get_selection (view); fm_directory_view_notify_selection_changed (FM_DIRECTORY_VIEW (view)); }
char *TreeViewGoods::get_activated_id() { if( Glib::RefPtr<Gtk::TreeView::Selection> selection = get_selection() ) { if( Gtk::TreeModel::iterator iter = selection->get_selected() ) { Glib::ustring id = ( *iter )[ treeColumns.id ]; return strdup( id.c_str() ); } } return NULL; }
int get_selected_text(editor_t *ed, char *buffer, int size) { int selstart, selend, len; if (!get_selection(ed, &selstart, &selend)) return 0; len = selend - selstart; if (len >= size) return 0; copy(ed, buffer, selstart, len); buffer[len] = 0; return len; }
void copy_selection(editor_t *ed) { int selstart, selend; if (!get_selection(ed, &selstart, &selend)) return; ed->clipsize = selend - selstart; ed->clipboard = (char *) neutron_realloc(ed->clipboard, ed->clipsize); if (!ed->clipboard) return; copy(ed, ed->clipboard, selstart, ed->clipsize); }
int erase_selection(editor_t *ed) { int selstart, selend; if (!get_selection(ed, &selstart, &selend)) return 0; moveto(ed, selstart, 0); erase(ed, selstart, selend - selstart); ed->anchor = -1; ed->refresh = 1; return 1; }