gboolean on_match_selected( GtkEntryCompletion *completion, GtkTreeModel *model, GtkTreeIter *iter, GtkWidget *entry ) { char* path = NULL; gtk_tree_model_get( model, iter, COL_PATH, &path, -1 ); if ( path && path[0] && !g_str_has_suffix( path, "/" ) ) { g_signal_handlers_block_matched( G_OBJECT( entry ), G_SIGNAL_MATCH_FUNC, 0, 0, NULL, on_changed, NULL ); char* new_path = g_strdup_printf( "%s/", path ); gtk_entry_set_text( GTK_ENTRY( entry ), new_path ); g_free( new_path ); g_free( path ); gtk_editable_set_position( (GtkEditable*)entry, -1 ); g_signal_handlers_unblock_matched( G_OBJECT( entry ), G_SIGNAL_MATCH_FUNC, 0, 0, NULL, on_changed, NULL ); on_changed( GTK_ENTRY( entry ), NULL ); return TRUE; } return FALSE; }
void VoxelEditor::paste() { deselect(); // test for image in clipboard QClipboard * clipboard = QApplication::clipboard(); QImage img = clipboard->image(); if (img.isNull()) { // paste whatever we have in the internal copied list selected_list = copied_list; } else { // paste image from clipboard selected_list.clear(); SelectedVoxel voxel; for (int x = 0; x < img.width(); x++) for (int y = 0; y < img.height(); y++) { QColor pixel = QColor(img.pixel(x, y)); if (pixel.alpha() <= 0) continue; RGBColor c(pixel.red(), pixel.green(), pixel.blue()); unsigned char cc = VoxelFile::get_closest_index(c); voxel.x = x; voxel.y = 0; voxel.z = img.height() - y; voxel.v = cc; selected_list.push_back(voxel); } } window->set_status("Pasted voxels"); on_changed(); }
void Gobby::GotoDialog::on_document_changed(SessionView* view) { if(m_current_view != NULL) { GtkTextBuffer* buffer = GTK_TEXT_BUFFER( m_current_view->get_text_buffer()); g_signal_handler_disconnect(buffer, m_changed_handler); } m_current_view = dynamic_cast<TextSessionView*>(view); set_response_sensitive(Gtk::RESPONSE_ACCEPT, m_current_view != NULL); m_entry_line.set_sensitive(m_current_view != NULL); if(m_current_view != NULL) { GtkTextBuffer* buffer = GTK_TEXT_BUFFER( m_current_view->get_text_buffer()); m_changed_handler = g_signal_connect_after( G_OBJECT(buffer), "changed", G_CALLBACK(on_changed_static), this); on_changed(); } }
void TypeData::set_class_type (ClassPtr new_class_type) { if (class_type_.is_null()) { class_type_ = new_class_type; on_changed(); } else if (!(class_type_ == new_class_type)) { set_ptype (tp_Error); } }
template <TypeData::flag_id_t FLAG> void TypeData::set_flag (bool f) { bool old_f = get_flag <FLAG> (); if (old_f) { dl_assert (f, dl_pstr ("It is forbidden to remove flag %d", FLAG)); } else if (f) { flags_ |= FLAG; on_changed(); } }
void TypeData::set_ptype (PrimitiveType new_ptype) { if (new_ptype != ptype_) { ptype_ = new_ptype; if (new_ptype == tp_Error) { set_error_flag (true); } on_changed(); } }
void TypeData::set_flags (type_flags_t new_flags) { dl_assert ((flags_ & new_flags) == flags_, "It is forbiddent to remove flag"); if (flags_ != new_flags) { if (new_flags & error_flag_e) { set_error_flag (true); } flags_ = new_flags; on_changed(); } }
void file_watch_dog::check() { namespace fs = boost::filesystem; if ( fs::exists( file_path_ ) ) { std::time_t this_write_time = fs::last_write_time( file_path_ ); if ( this_write_time > last_write_time_ ) { last_write_time_ = this_write_time; on_changed(); } } }
void VoxelEditor::offset_selected(int dx, int dy, int dz) { if (dx == 0 && dy == 0 && dz == 0) return; SelectedVoxels::iterator it; for (it = selected_list.begin(); it != selected_list.end(); it++) { SelectedVoxel & v = *it; v.x += dx; v.y += dy; v.z += dz; } on_changed(); }
void HawkPreferences::apply() { cfg_ratio_cutoff = GetDlgItemInt(IDC_RATIO_CUTOFF, NULL, FALSE); cfg_max_playlists = GetDlgItemInt(IDC_MAX_PLAYLISTS, NULL, FALSE); // Limit cutoff to 0 - 100 cfg_ratio_cutoff = min(100, max(0, cfg_ratio_cutoff)); SetDlgItemInt(IDC_RATIO_CUTOFF, cfg_ratio_cutoff, FALSE); // Limit max playlists to > 2 cfg_max_playlists = max(2, cfg_max_playlists); SetDlgItemInt(IDC_MAX_PLAYLISTS, cfg_max_playlists, FALSE); on_changed(); }
void periodic_update() { v_ = calc(); if (slot_) { std::cerr << "periodic\n"; std::thread([this]() { std::cerr << "next\n"; ::usleep(update_interval_usec_); auto slot = slot_; if (slot_) slot->on_changed(slot_, parent_); periodic_update(); }).detach(); } }
static gboolean on_key_press( GtkWidget *entry, GdkEventKey* evt, EntryData* edata ) { int keymod = ( evt->state & ( GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_SUPER_MASK | GDK_HYPER_MASK | GDK_META_MASK ) ); if( evt->keyval == GDK_KEY_Tab && !keymod ) { //gtk_entry_completion_insert_prefix( gtk_entry_get_completion(GTK_ENTRY(entry)) ); //gtk_editable_set_position( (GtkEditable*)entry, -1 ); /* g_signal_handlers_block_matched( G_OBJECT( entry ), G_SIGNAL_MATCH_FUNC, 0, 0, NULL, on_changed, NULL ); gtk_entry_completion_insert_prefix( gtk_entry_get_completion(GTK_ENTRY(entry)) ); const char* path = gtk_entry_get_text( GTK_ENTRY( entry ) ); if ( path && path[0] && !g_str_has_suffix( path, "/" ) && g_file_test( path, G_FILE_TEST_IS_DIR ) ) { char* new_path = g_strdup_printf( "%s/", path ); gtk_entry_set_text( GTK_ENTRY( entry ), new_path ); g_free( new_path ); } gtk_editable_set_position( (GtkEditable*)entry, -1 ); g_signal_handlers_unblock_matched( G_OBJECT( entry ), G_SIGNAL_MATCH_FUNC, 0, 0, NULL, on_changed, NULL ); on_changed( GTK_ENTRY( entry ), NULL ); */ insert_complete( GTK_ENTRY( entry ) ); on_changed( GTK_ENTRY( entry ), NULL ); seek_path_delayed( GTK_ENTRY( entry ), 10 ); return TRUE; } else if ( evt->keyval == GDK_KEY_BackSpace && keymod == 1 ) // shift { gtk_entry_set_text( GTK_ENTRY( entry ), "" ); return TRUE; } return FALSE; }
void VoxelEditor::use_tool_secondary(bool click) { if (!has_hit) return; if (!click) return; int tool = window->get_tool(); if (tool == BLOCK_EDIT_TOOL) { voxel->set(hit_block.x, hit_block.y, hit_block.z, VOXEL_AIR); voxel->reset_shape(); update_hit(); on_changed(); } else if (tool == PENCIL_EDIT_TOOL) { pick_color(); } }
FrequencyKeypadView::FrequencyKeypadView( NavigationView& nav, const rf::Frequency value ) { add_child(&text_value); const auto button_fn = [this](Button& button) { this->on_button(button); }; const char* const key_caps = "123456789<0."; size_t n = 0; for(auto& button : buttons) { add_child(&button); const std::string label { key_caps[n] }; button.on_select = button_fn; button.set_parent_rect({ static_cast<Coord>((n % 3) * button_w), static_cast<Coord>((n / 3) * button_h + button_h), button_w, button_h }); button.set_text(label); n++; } add_child(&button_close); button_close.on_select = [this, &nav](Button&) { if( on_changed ) { on_changed(this->value()); } nav.pop(); }; set_value(value); }
Engine_State::Engine_State( ) { m_on = false; // motor is off m_idle = true; // motor is idle connect(this, SIGNAL( switched_on() ), this, SIGNAL( changed() ) ); connect(this, SIGNAL( switched_off() ), this, SIGNAL( changed() ) ); connect(this, SIGNAL( was_set_to_idle() ), this, SIGNAL( changed() ) ); connect(this, SIGNAL( was_unset_to_idle() ), this, SIGNAL( changed() ) ); connect(this, SIGNAL( changed() ), this, SLOT( on_changed() ) ); }
gboolean on_match_selected( GtkEntryCompletion *completion, GtkTreeModel *model, GtkTreeIter *iter, GtkWidget *entry ) { char* path = NULL; gtk_tree_model_get( model, iter, COL_PATH, &path, -1 ); if ( path && path[0] ) { g_signal_handlers_block_matched( G_OBJECT( entry ), G_SIGNAL_MATCH_FUNC, 0, 0, NULL, on_changed, NULL ); gtk_entry_set_text( GTK_ENTRY( entry ), path ); g_free( path ); gtk_editable_set_position( (GtkEditable*)entry, -1 ); g_signal_handlers_unblock_matched( G_OBJECT( entry ), G_SIGNAL_MATCH_FUNC, 0, 0, NULL, on_changed, NULL ); on_changed( GTK_ENTRY( entry ), NULL ); seek_path_delayed( GTK_ENTRY( entry ), 10 ); } return TRUE; }
void VoxelEditor::delete_selected() { selected_list.clear(); window->set_status("Deleted voxels"); on_changed(); }
void VoxelEditor::use_tool_primary(bool click) { int tool = window->get_tool(); if ((tool == BLOCK_EDIT_TOOL || tool == BUCKET_EDIT_TOOL) && !click) return; if (tool == POINTER_EDIT_TOOL) { vec2 mouse(last_pos.x(), height() - last_pos.y()); vec3 pos, dir; get_window_ray(mouse, inverse_mvp, viewport, pos, dir); if (selected_list.size() > 0) { if (click) pos_arrows.on_mouse_press(pos, dir); else { pos_arrows.on_mouse_move(pos, dir); vec3 add = pos_arrows.get(1.0f); int dx = int(add.x); int dy = int(add.y); int dz = int(add.z); offset_selected(dx, dy, dz); } if (pos_arrows.pan != NONE_CONE) { update(); return; } } if (click) { start_drag = last_pos; rubberband->move(mapToGlobal(start_drag)); rubberband->resize(0, 0); rubberband->show(); } else { rubberband->setGeometry( QRect(mapToGlobal(start_drag), mapToGlobal(last_pos)).normalized()); } update_drag(); return; } if (!has_hit) return; int hit_x, hit_y, hit_z; if (tool == BLOCK_EDIT_TOOL) { hit_x = hit_next.x; hit_y = hit_next.y; hit_z = hit_next.z; } else if (tool == PENCIL_EDIT_TOOL || tool == BUCKET_EDIT_TOOL) { if (hit_floor) return; hit_x = hit_block.x; hit_y = hit_block.y; hit_z = hit_block.z; } else return; if (tool == BUCKET_EDIT_TOOL) flood_fill(hit_x, hit_y, hit_z); else voxel->set(hit_x, hit_y, hit_z, window->get_palette_index()); voxel->reset_shape(); update_hit(); on_changed(); }
void HawkPreferences::on_edit_change(UINT, int, CWindow) { on_changed(); }