source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | grimen/is_reviewable | https://github.com/grimen/is_reviewable | lib/is_reviewable/review.rb | Ruby | mit | 46 | master | 2,766 | # coding: utf-8
module IsReviewable
class Review < ::ActiveRecord::Base
ASSOCIATIVE_FIELDS = [
:reviewable_id,
:reviewable_type,
:reviewer_id,
:reviewer_type,
:ip
].freeze
CONTENT_FIELDS = [
:rating,
:body
].freeze
# Associat... |
github | rmcfadzean/rack-pratchett | https://github.com/rmcfadzean/rack-pratchett | rack-pratchett.gemspec | Ruby | mit | 46 | master | 1,308 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'rack/pratchett/version'
Gem::Specification.new do |spec|
spec.name = "rack-pratchett"
spec.version = Rack::Pratchett::VERSION
spec.authors = ["Rob"]
spec.email ... |
github | rmcfadzean/rack-pratchett | https://github.com/rmcfadzean/rack-pratchett | lib/rack/pratchett.rb | Ruby | mit | 46 | master | 234 | module Rack
class Pratchett
def initialize(app)
@app = app
end
def call(env)
result = @app.call(env)
result[1]['X-Clacks-Overhead'.freeze] = 'GNU Terry Pratchett'.freeze
result
end
end
end |
github | rmcfadzean/rack-pratchett | https://github.com/rmcfadzean/rack-pratchett | spec/pratchett_spec.rb | Ruby | mit | 46 | master | 395 | require 'spec_helper'
describe 'Rack::Pratchett' do
let(:app) {
Rack::Builder.new do
use Rack::Pratchett
run lambda { |env| [200, {'Content-Type' => 'text/plain'}, ["GNU Terry Pratchett"]] }
end
}
specify 'includes X-Clacks-Overhead header' do
response = Rack::MockRequest.new(app).get('... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | vr.gemspec | Ruby | mit | 46 | master | 1,506 | load "./src/version.rb"
Gem::Specification.new do |s|
s.name = "visualruby"
s.licenses = ["MIT"]
s.version = VERSION
s.add_dependency(GTK_VERSION)
s.add_dependency(GTK_SOURCEVIEW_VERSION)
s.authors = ["Eric Cunningham"]
s.email = "beagle4321_2000@yahoo.com" # optional
s.summary = "Create IDE d... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | all_requires.rb | Ruby | mit | 46 | master | 1,167 | require "rubygems"
require "yaml" #needed
require "net/http" #needed
require "net/https" #needed
require "fileutils" #needed
require "open3" # needed to run glade in own process
require "rubygems/installer"
require "rubygems/uninstaller"
require "rubygems/package"
require "rubygems/specification"
... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | lib/DragDrop.rb | Ruby | mit | 46 | master | 1,255 | # The main namespace for visualruby.
module VR
module Draggable
def add_target_widget(widget)
@target_widgets ||= []
@target_widgets << widget
ar = [[ self.object_id.to_s, :same_app, 12_345]]
drag_source_set(Gdk::ModifierType::BUTTON1_MASK |
Gdk::ModifierType::BUTT... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | lib/GladeGUI.rb | Ruby | mit | 46 | master | 17,715 | # GladeGUI connects your class to a glade form.
# It will load a .glade
# file into memory, enabling your ruby programs to have a GUI interface.
#
# GladeGUI works by adding an instance variable named "@builder" to your class. The "@builder"
# variable is an instance of Gtk::Builder.
# It holds references to all yo... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | lib/vrlib.rb | Ruby | mit | 46 | master | 1,379 | require_relative "../src/version"
require GTK_VERSION
require "date"
require "yaml"
require "find"
require "fileutils"
#tools go first
require_relative "GladeGUI"
# require_relative "Alert"
require_relative "AlertDialog"
require_relative "DragDrop"
require_relative "SavableClass"
require_relative "Tools"
require_rel... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | lib/Tools.rb | Ruby | mit | 46 | master | 493 | module VR
# Copies a directory recursively
def VR.copy_recursively(from, out_dir)
Find.find(from) do |path|
next if path == from
rel_path = path.gsub(from, "")
if File.directory?(path)
FileUtils.makedirs(out_dir + rel_path)
else
if not File.directory?(out_dir + File.... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | lib/SavableClass.rb | Ruby | mit | 46 | master | 1,651 | module VR
# Loads or creates a yaml file with a given object type (class).
# If the file exists already, the object will be returned. If not,
# a new instance will be returned, and the file will instantly be saved.
# @param [Class] klass The class of the object to be loaded or created
# @param [String] file_... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | lib/Alert.rb | Ruby | mit | 46 | master | 5,970 | module VR
# Class that the #alert method uses. This class is note useful by itself. See #alert method instead.
# @see #alert
# @private
class Alert
attr_accessor :answer
include GladeGUI
# Just passes on values from #alert method.
# @see #alert
def initialize(mes... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | lib/AlertDialog.rb | Ruby | mit | 46 | master | 6,141 | module VR
# Class that the #alert method uses. This class is note useful by itself. See #alert method instead.
# @see #alert
# @private
class AlertDialog
include GladeGUI
# Just passes on values from #alert method.
# @see #alert
def initialize(message, flags = {})
@... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | lib/treeview/ListView.rb | Ruby | mit | 46 | master | 3,544 | module VR
class ListView < Gtk::TreeView
# include GladeGUI
include ViewCommon
# def before_show
# @builder[:scrolledwindow1].add self
# self.visible = true
# end
# The new() constructor takes a Hash that defines the columns as its only argument. The Hash defines
# symbols as the ... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | lib/treeview/IterMethods.rb | Ruby | mit | 46 | master | 2,527 | module VR::ViewCommon
# The IterMethods module extends the GtkTreeIter class so it can work with
# visualruby's colum ID symbols as well as Gtk's column numbers.
#
module IterMethods
attr_accessor :column_keys
@column_keys = nil
# The [] method returns the value from the specified column in th... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | lib/treeview/TreeView.rb | Ruby | mit | 46 | master | 1,793 | module VR
#
# TreeView is almost identical to VR::ListView. The only difference
# is how rows are added, and that they use a different model class.
# See VR::ListView for in-depth docs. Also, see Gtk::TreeView for more.
#
# Also, most of the useful methods for VR::TreeView are found in VR::ViewCommon.
# All ... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | lib/treeview/ViewCommon.rb | Ruby | mit | 46 | master | 15,647 | module VR
# This module holds all the methods that both VR::ListView
# and VR::TreeView use. All the methods listed here can be called from a
# VR::ListView or a VR::TreeView.
#
# ==The col_<propery>, ren_<property>, col_attr, and ren_attr methods
#
# All of these methods do the same thing: set the properti... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | lib/treeview/FileTreeView.rb | Ruby | mit | 46 | master | 6,680 | module VR
class FileTreeView < VR::TreeView
attr_accessor :root, :glob
# A Code block that further excludes files and folders included in the tree. If this block returns false
# for the entry, it will be excluded. If it returns true, it will be included...
attr_accessor :validate_block
... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | lib/treeview/columns/CalendarCol.rb | Ruby | mit | 46 | master | 2,827 | module VR::Col
# The CalendarCol class is a simple calendar window where you can edit
# the date:
#
# http://visualruby.net/img/calendar.jpg
#
# This class is very useful when you want to display and edit dates
# in a VR::ListView. You can define a column with the type VR::Col::CalendarCol
# and the column will displ... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | lib/treeview/columns/SpinCol.rb | Ruby | mit | 46 | master | 267 | # This column signals VR::TreeView to make a column that appears as a number
# and uses a spinbutton to edit it.
module VR::Col
class SpinCol < Gtk::Adjustment
def initialize(val, min, max, step)
super(val, min, max, step, 0, 0)
end
end
end |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | lib/treeview/columns/ComboCol.rb | Ruby | mit | 46 | master | 1,314 | module VR::Col
# The Combo class is for use with VR::ListView and VR::TreeView. It
# simply holds the values for a combobox to be displayed in the view.
# It is not a visual component, it just holds data.
#
# It is one of the data types that you can pass to the constructors for VR::ListView and
# VR::TreeView.... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | lib/treeview/columns/ProgressCol.rb | Ruby | mit | 46 | master | 614 | module VR::Col
# This class is simply a wrapper for an Integer. It signals VR::Listview's
# and VR::Treeviews constructor to make this column a progressbar using
# VR::Col::Ren::CellRendererProgress. For example, whwn you create a VR::ListView,
# you can pass VR::Progress as a column type:
#
# @view = VR::Li... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | lib/treeview/columns/TreeViewColumn_old.rb | Ruby | mit | 46 | master | 3,542 | module VR::Col
class TreeViewColumn < Gtk::TreeViewColumn # :nodoc:
def initialize(view, model_col, sym, type)
super()
self.title = sym.to_s.gsub("_", " ").split(' ').map {|w| w.capitalize }.join(' ') # My Title
@view = view
self.resizable = true
cols = (type.is_a? Has... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | lib/treeview/columns/CellRendererProgress.rb | Ruby | mit | 46 | master | 342 | #module VR
#
# class CellRendererProgress < Gtk::CellRendererProgress # :nodoc:
#
# attr_reader :model_col, :column, :model_sym
#
# def initialize(model_col, column, view, model_sym)
# super()
# @model_col = model_col
# @model_sym = model_sym
# @column = column
# @view = view
# ... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | lib/treeview/columns/CellRendererCombo.rb | Ruby | mit | 46 | master | 2,281 | module VR::Col::Ren
# This class is a helper to VR::ListView and VR::TreeView. When
# colums are created, this class is used as the renderer because
# it adds functionality to the Gtk Renderer.
#
# When you call ListView#render(model_col) an instance of this class
# will be returned. It is a subclass of
#
#... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | lib/treeview/columns/CellRendererText.rb | Ruby | mit | 46 | master | 1,258 | module VR::Col::Ren
# This class is a helper to VR::ListView and VR::TreeView. When
# colums are created, this class is used as the renderer because
# it adds functionality to the Gtk Renderer.
#
# When you call ListView#render(model_col) an instance of this class
# will be returned. It is a subclass of Gtk::... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | lib/treeview/columns/BlobCol.rb | Ruby | mit | 46 | master | 2,061 | module VR::Col
# The BlobCol class is a simple text editor for editing strings of data:
#
# It is a very useful class when you want to display and edit long strings
# of data in a VR::ListView. To create a coulmn of long strings in a VR::ListView,
# simply define the column type as VR::Col::BlobCol:
#
# @vi... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | lib/treeview/columns/TreeViewColumn.rb | Ruby | mit | 46 | master | 3,056 | module VR
class TreeViewColumn < Gtk::TreeViewColumn # :nodoc:
def initialize(view, sym)
super()
self.title = sym.to_s.gsub("_", " ").split(' ').map {|w| w.capitalize }.join(' ') # My Title
@view = view
self.resizable = true
# self.visible = true
end
def add_ren... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | lib/treeview/columns/CurrencyCol.rb | Ruby | mit | 46 | master | 404 | module VR::Col
class CurrencyCol
attr_accessor :value, :format
def initialize(value, format = "%.2f")
set_value(value, format)
end
def set_value(value, format = "%.2f")
@value = value
@format = format
end
def each_cell(col, ren, model, iter)
ren.text =... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | lib/treeview/columns/CellRendererObject.rb | Ruby | mit | 46 | master | 1,441 | module VR::Col::Ren
# This class is a helper to VR::ListView and VR::TreeView. When
# colums are created, this class is used as the renderer because
# it adds functionality to the Gtk Renderer.
#
# When you call ListView#render(model_col) an instance of this class
# will be returned. It is a subclass of Gtk::... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | lib/treeview/columns/ImageCol.rb | Ruby | mit | 46 | master | 325 | module VR::Col
class ImageCol #< Gdk::Pixbuf
include GladeGUI
def initialize(image)
# super(File.dirname(__FILE__) + "/../../../img/image-x-generic.png")
@image1 = image
end
def before_show()
@builder["window1"].resize 500, 360
end
def to_s
"<Img>"
end
end
... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | lib/treeview/columns/CellRendererSpin.rb | Ruby | mit | 46 | master | 1,178 | module VR::Col::Ren
# This class is a helper to VR::ListView and VR::TreeView. When
# colums are created, this class is used as the renderer because
# it adds functionality to the Gtk Renderer.
#
# When you call ListView#render(column_id) an instance of this class
# will be returned. It is a subclass of
#
#... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | lib/treeview/columns/CellRendererToggle.rb | Ruby | mit | 46 | master | 1,378 | module VR::Col::Ren
#
# This renderer has a slightly different validate_block than the others. Its validate_block will be called with three
# parameters:
#
# @view.renderer(:name).validate_block = Proc.new { | model_sym, row, view |
# (row[:name].length < 3)
# }
#
# Also, you can use the VR::Col::Ren::... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | lib/oinspect/ObjectInspectorGUI.rb | Ruby | mit | 46 | master | 1,251 | # ObjectInspector isn't meant to be called directly, #oinspect for API.
module VR::ObjectInspector
# ObjectInspector isn't meant to be called directly, see #oinspect for API.
class ObjectInspectorGUI
include GladeGUI
def initialize(obj=self)
@obj = obj
@obj_to_s = obj.to_s
@meth_view... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | lib/oinspect/MethodsListView.rb | Ruby | mit | 46 | master | 399 | module VR::ObjectInspector
class MethodsListView < VR::ListView
def initialize(obj)
super(:method => String, :arity => String, :parameters => String)
obj.public_methods.each do |meth|
row = add_row
row[:method] = meth.to_s
row[:arity] = obj.method(meth).arity.to_s
row... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | lib/oinspect/VariablesListView.rb | Ruby | mit | 46 | master | 1,084 | module VR::ObjectInspector
# Listview that holds variables in the ObjectInspectorGUI
class VariablesListView < VR::ListView
def initialize(obj)
super(variable: String, type: String, class: String, value: String, obj: Object)
obj.instance_variables.each do |var|
row = add_row
row[:va... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/78_listview_objects/listviewobjects.rb | Ruby | mit | 46 | master | 210 | require "vrlib"
# require_relative "../../lib/vrlib"
require_relative 'src/DataObject'
require_relative 'src/ListViewObjects'
require_relative 'src/ListViewObjectsGUI'
ListViewObjectsGUI.new.show_glade() |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/78_listview_objects/src/ListViewObjectsGUI.rb | Ruby | mit | 46 | master | 966 | # This class just adds a GUI to the ListViewObjects class.
class ListViewObjectsGUI < ListViewObjects
include GladeGUI
def before_show
@builder["scrolledwindow1"].add(self)
self.visible = true
# edited_callback is a method that is called after a cell has been edited. It is
# used to do housekee... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/78_listview_objects/src/ListViewObjects.rb | Ruby | mit | 46 | master | 2,102 | # This is a listview that contains objects! The columns contain a date object, a user defined, and
# a long (blob) text string. The columns are named :join, :name, and :quote.
class ListViewObjects < VR::ListView
def initialize()
# hash of column types.
@cols = { join: VR::Col::CalendarCol, name: DataOb... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/78_listview_objects/src/DataObject.rb | Ruby | mit | 46 | master | 1,044 | # This is a basic object that contains data. Using visualruby, you can easily
# load your objects into a listview and manipulate them. You just define one
# of the colums's type as the object's name (here DataObject) and it will appear in the
# ListView.
class DataObject
include GladeGUI
def initialize(na... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/35_child_window/child_window.rb | Ruby | mit | 46 | master | 241 | require "vrlib"
#require_relative "./../../lib/vrlib"
require_relative "src/ChildWindowDemo"
require_relative "src/ModalWindow"
require_relative "src/ModelessWindow"
require_relative "src/MyChildClass"
ChildWindowDemo.new.show_glade() |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/35_child_window/src/ChildWindowDemo.rb | Ruby | mit | 46 | master | 1,617 | ##
# This is a "main" GUI class for a program. It allows you
# to open modal and non-modal windows.
#
# Modal windows are
# windows that appear on top of the main program window and
# halt the main window until they are closed. They're good for
# dialogs etc.
#
# Normal non-modal windows operate concurrent... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/35_child_window/src/MyChildClass.rb | Ruby | mit | 46 | master | 235 | ##
# This is just a generic window that gets opened as either modal
# or non-modal.
#
class MyChildClass
include GladeGUI
def initialize(title, message)
@labelMessage = message
@window1 = title
end
end |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/97_active_record2/main.rb | Ruby | mit | 46 | master | 3,245 | # ignore -- this is for development, same as require 'vrlib'
require "vrlib"
begin
require 'active_record'
require 'sqlite3'
rescue LoadError
alert "You must install activerecord gem to use this example. " +
"Just enter at command prompt:\n\n<b>gem install activerecord\ngem install sqlite3</b>"
exit
end... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/97_active_record2/bin/CompanyGUI.rb | Ruby | mit | 46 | master | 1,844 | class CompanyGUI
include GladeGUI
def before_show()
@employer_view = VR::ListView.new(:employer => Employer, :address => String, :company_type => String)
@builder["scroll_employer"].add(@employer_view)
# @employer_view.selection.signal_connect("changed") { employer_view__changed }
@employer_view.c... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/97_active_record2/bin/Employee.rb | Ruby | mit | 46 | master | 395 | class Employee < ActiveRecord::Base
has_many :paychecks
belongs_to :employer
include GladeGUI
def each_cell(col, ren, model, iter)
bal = balance().to_f
ren.text = name
ren.foreground = bal < 0 ? "white" : "black"
ren.background = bal < 0 ? "red" : "white"
end
def balance()
Paycheck.su... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/49_settings_file/src/SavableSettings.rb | Ruby | mit | 46 | master | 1,386 | class SavableSettings
include GladeGUI
def initialize()
defaults()
end
# defaults are set on new and loaded objects. You can add to this list
# and it will not cause errors. New variables will be added
# and loaded objects will function flawlessly. When you load a yaml
# file using VR::load_ya... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/08_interrupt_exit/src/InterruptExit.rb | Ruby | mit | 46 | master | 537 | class InterruptExit
include GladeGUI
def ui_destroy_btn__clicked(*a)
@builder["window1"].destroy
end
def ui_ask_btn__clicked(*a)
@builder["window1"].close
end
# The main window is always window1
# the delete_event is fired when you click the "X" button.
def window1__delete_event(*a)
a... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/75_treeview/src/FamilyTree.rb | Ruby | mit | 46 | master | 625 | class FamilyTree
include GladeGUI
def before_show()
@tree = VR::TreeView.new(name: String, age: Integer)
top = @tree.add_row(nil)
top[:name] = "Family"
eric = @tree.add_row(top, name: "Eric", age: 47)
joe = @tree.add_row(eric, name: "Joe", age: 15)
ann = @tree.add_row(eric, name: "Ann", ag... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/03_builder_variable/src/BuilderDemo.rb | Ruby | mit | 46 | master | 445 | class BuilderDemo
include GladeGUI
# You can retreive the @builder objects:
def ui_change_but__clicked(*args)
if @builder["ui_animal_ent"].buffer.text == "Dog"
@builder["ui_animal_ent"].buffer.text = "Cat"
@builder["ui_name_ent"].buffer.text = "Fluffy"
else # use variables instead
... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/95_active_record/active_record.rb | Ruby | mit | 46 | master | 1,232 | require "vrlib"
begin
require 'active_record'
require 'sqlite3'
rescue LoadError
alert "You must install activerecord gem to use this example. " +
"Just enter at command prompt:\n\n<b>gem install activerecord\ngem install sqlite3</b>"
exit
end
# from require_all gem:
require_rel 'bin/'
ActiveRecord::... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/95_active_record/bin/ChoosePerson.rb | Ruby | mit | 46 | master | 395 | class ChoosePerson < VR::ListView
include GladeGUI
def initialize()
super(:person => Person) # Person class
end
def before_show()
@builder["scrolledwindow1"].add(self)
Person.all.each do |p|
row = add_row(:person => p)
end
self.show
end
def buttonShow__clicked(*a)
return u... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/95_active_record/bin/Person.rb | Ruby | mit | 46 | master | 460 | class Person < ActiveRecord::Base
include GladeGUI
def before_show
@builder[:labelName].label = "<big>#{name}</big>"
set_glade_all() # updates entry boxes
end
# this is what shows in the listview
def to_s
"#{self.name} (#{self.email}) #{self.phone}"
end
def but... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/02_hello/hello.rb | Ruby | mit | 46 | master | 226 | require "./../../lib/vrlib.rb"
require_relative "src/Phantom.rb"
main = Gtk::Application.new("org.visualruby.phantom_demo", :handles_open)
main.signal_connect "activate" do |app|
HelloGUI.new.show_ui(app)
end
main.run |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/10_all_widgets/src/AllWidgets.rb | Ruby | mit | 46 | master | 985 | ##
# This file shows all the widget types that auto-fill when you
# call the show_glade() method. This provides a great shortcut
# for assigning initial values to widgets in your forms.
#
# So when you might normally write:
#
# @builder["window1"].title = "All Widgets"
#
# instead you can write:
#
# @window1... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/04_before_show/src/MyClass.rb | Ruby | mit | 46 | master | 201 | class MyClass #(change name)
include GladeGUI
def before_show()
@button1 = "Hello World"
end
def button1__clicked(*args)
@builder["button1"].label = "Goodbye World"
end
end |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/04_before_show/src/BeforeShow.rb | Ruby | mit | 46 | master | 366 | class BeforeShow
include GladeGUI
def initialize()
if @bilder.nil?
alert("Inside initialize():\n@builder = nil")
end
end
# in before_show() you can use @builder
def before_show()
my_button = @builder["ui_button"]
my_button.label = "Hello World"
@builder["ui_entry"].text = "This w... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/07_event_handlers/src/MyTextView.rb | Ruby | mit | 46 | master | 302 | class MyTextView < Gtk::TextView
def self__focus_in_event(*args)
self.buffer.text = "CALLED: self__focus_in_event(): Editing Now!"
return false
end
def self__focus_out_event(*args)
self.buffer.text = "CALLED: self__focus_out_event: Waiting..."
return false
end
end |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/07_event_handlers/src/Event_Handlers.rb | Ruby | mit | 46 | master | 913 | class Event_Handlers
include GladeGUI
def before_show()
@my_var = @builder["ui_use_variable_but"]
# This is how you add your own widget to a scrolledwindow:
@txt = MyTextView.new()
@txt.visible = true
@txt.buffer.text = "Try clicking on the buttons and text area." +
... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/36_dialog_box/dialog_box.rb | Ruby | mit | 46 | master | 227 | require "vrlib"
require_relative "src/ChooserDialog"
dialog = ChooserDialog.new()
language, set_default = dialog.run()
alert("Language: #{language}\nSet Default?: #{set_default ? 'true' : 'false'}") unless language.nil? |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/36_dialog_box/src/ChooserDialog.rb | Ruby | mit | 46 | master | 443 | class ChooserDialog
include GladeGUI # to load ChooserDialog.glade
def run()
load_glade # in GladeGUI
response = @builder[:window1].run()
case response
when Gtk::ResponseType::OK
lang, default = @builder[:comboLang].active_text, @builder[:checkDefault].active?
when Gtk::Response... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/72_object_views/src/BalanceListView.rb | Ruby | mit | 46 | master | 1,334 | class BalanceListView < VR::ListView
include GladeGUI
def initialize
cols = { name: CustomerClass, balance: BalanceClass }
super(cols)
col_width(:name => 160, :balance => 120)
col_attr(:balance, alignment: 1, xalign: 1)
col_editable(true)
refresh()
self.visible = true
end
... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/72_object_views/src/BalanceClass.rb | Ruby | mit | 46 | master | 492 | class BalanceClass
def initialize(value)
@value = value # Float value of their balance
end
def each_cell(col, ren, model, iter)
ren.text = @value.to_s
ren.foreground = @value < 0 ? "darkred" : "black"
ren.weight = @value < 0 ? 700 : 400 # bold or normal
#set background based on... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/72_object_views/src/CustomerClass.rb | Ruby | mit | 46 | master | 323 | class CustomerClass
attr_accessor :state
def initialize(name, address, state)
@name = name
@address = address
@state = state
end
def each_cell(col, ren, model, iter)
ren.text = @name # necessary, this appears in the table
ren.background = @state != "CA" ? "papayawhip" : "white"
end
end |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/80_golf_handicap/golf_handicap.rb | Ruby | mit | 46 | master | 270 | require "vrlib"
require_relative "src/Handicap"
require_relative "src/LoadGolfer"
require_relative "src/Score"
last_file = Dir.glob("*.yaml").max_by {|f| File.mtime(f)}
if last_file.nil?
load_new_golfer
else
VR::load_yaml(Handicap, last_file).show_glade
end |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/80_golf_handicap/golf_handicap.gemspec | Ruby | mit | 46 | master | 1,039 | Gem::Specification.new do |s|
s.name = "golf_handicap" # i.e. visualruby. This name will show up in the gem list.
s.version = "0.0.11" # i.e. (major,non-backwards compatable).(backwards compatable).(bugfix)
s.add_dependency "visualruby"
s.has_rdoc = false
s.authors = ["Eric Cunningham"]
s.email = "you@y... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/80_golf_handicap/src/LoadGolfer.rb | Ruby | mit | 46 | master | 806 | def load_new_golfer
files = []
names = []
Dir[File.expand_path("*.yaml")].each do |file_name|
files << file_name
names << File.basename(file_name, ".*")
end
answer = files.empty? ? false : alert("Choose Golfer:", data: names, button_no: "New Golfer")
if answer.is_a?(String)... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/80_golf_handicap/src/Score.rb | Ruby | mit | 46 | master | 841 | class Score
attr_accessor :ui_date_calendar, :ui_score_ent, :ui_course_name_ent
attr_accessor :ui_course_rating_ent, :ui_course_slope_ent, :used, :handicap
include GladeGUI
def initialize(course, rating, slope)
@ui_course_name_ent = course
@ui_course_rating_ent = rating
@ui_course_slope_ent = sl... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/80_golf_handicap/src/Handicap.rb | Ruby | mit | 46 | master | 3,772 | class Handicap
include GladeGUI
def initialize()
@scores = []
end
def before_show()
@ui_rounds_listview = VR::ListView.new(rnd: String, date: VR::Col::CalendarCol,
course: String, rating_slope: String, score: String, diff: Score,
hcp: String)
@ui_rounds_listview.col_xalign(diff: 1, h... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/70_better_views/src/BetterView.rb | Ruby | mit | 46 | master | 748 | class BetterView < VR::ListView
include GladeGUI
def initialize()
super({ name: String, balance: Float })
refresh()
self.visible = true
end
def before_show
@builder["scrolledwindow1"].add_child(self)
end
# this just loads the data into the model
def refresh()
data = get_data... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/06_alert_box/alertdemo.rb | Ruby | mit | 46 | master | 222 | require_relative "./../../lib/vrlib"
require_relative "src/AlertBoxDemo.rb"
main = Gtk::Application.new("org.visualruby.main")
main.signal_connect "activate" do |app|
app = AlertBoxDemo.new.show_glade()
end
main.run |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/06_alert_box/src/AlertBoxDemo.rb | Ruby | mit | 46 | master | 2,437 | class AlertBoxDemo
include GladeGUI
def buttonSimple__clicked(*a)
alert "I'll be back"
end
# Its best to include a parent so alert box always on top.
# Will return true, false or nil ("x" pressed)
def buttonYesNo__clicked(*a)
if alert("Do you want to continue?", :button_yes => "Yes", :button_n... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/09_get_glade_variables/get_glade_variables.rb | Ruby | mit | 46 | master | 281 | require "vrlib"
require_relative "src/DataObjectGUI"
form = DataObjectGUI.new("Harry Milktoast",
"123 Main, San Clemente, CA 90090",
"harvey@harveyserver.com",
"132-243-4323")
form.show_glade() |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/09_get_glade_variables/src/DataObjectGUI.rb | Ruby | mit | 46 | master | 1,130 | class DataObjectGUI
include GladeGUI
# the @init_ variables are just saving the initial values for reset
def initialize(name, address, phone, email)
@ui_name_ent = @init_name = name
@ui_address_ent = @init_address = address
@ui_phone_ent = @init_phone = phone
@ui_email_ent = @i... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/78_listview/listview.gemspec | Ruby | mit | 46 | master | 892 | Gem::Specification.new do |s|
s.name = "listview" # i.e. visualruby. This name will show up in the gem list.
s.version = "0.0.1" # i.e. (major,non-backwards compatable).(backwards compatable).(bugfix)
s.add_dependency "visualruby"
s.has_rdoc = false
s.authors = ["Your Name"]
s.email = "you@yoursite.com"... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/78_listview/src/SongListView.rb | Ruby | mit | 46 | master | 3,822 | ##
# This class contains all the code for the ListView itself.
# It sets-up the columns and data.
# The GUI class will make changes to the view/data.
# All the GUI code is in SongListViewGUI.rb.
#
class SongListView < VR::ListView
AUDIO_ICON = GdkPixbuf::Pixbuf.new(:file => File.dirname(__FILE__) + "/audio-x-gen... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/78_listview/src/SongListViewGUI.rb | Ruby | mit | 46 | master | 1,677 | class SongListViewGUI < SongListView
include GladeGUI
def before_show
@builder["scrolledwindow1"].add_child(self)
end
def self__row_activated(*args)
return unless row = selected_rows.first
alert "You selected\n#{row[:song]}\nby #{row[:artist]}"
end
def invisible__toggled(*args)
refresh... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/77_filetreeview/src/ProjectTreeGUI.rb | Ruby | mit | 46 | master | 912 | class ProjectTreeGUI #(change name)
attr_accessor :ftv
include GladeGUI
def before_show()
@ftv = ProjectTree.new()
@builder["scrolledwindow1"].add(@ftv) #needs show_all
@ftv.set_show_expanders(false)
@open_folders = []
end
def ftv__row_activated(_self, path, col)
return unless ro... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/77_filetreeview/src/ProjectTree.rb | Ruby | mit | 46 | master | 1,088 | # This demonstrates the VR::FileTreeView class. You can configure it using a glob and a
# validation block. It will only include the files and folders designated in the glob
# and that have the vaildation block return true.
#
# It does this:
#
# files = Dir.glob(folder_path, glob)
# files = files.select &@... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/05_menus/src/Menus.rb | Ruby | mit | 46 | master | 494 | class Menus
include GladeGUI
def ui_open_menu__activate(*args)
alert("Opening File...")
end
def ui_save_menu__activate(*args)
alert("Saving File...")
end
def ui_quit_menu__activate(*args)
@builder["window1"].close
end
def ui_about_menu__activate(*args)
alert("Version 16.7.31", hea... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/80_drag_drop/src/DragDropDemo.rb | Ruby | mit | 46 | master | 1,366 | class DragDropDemo
include GladeGUI
def before_show()
@window1 = "Drag and Drop Demo"
@textview1 = "I'm a widget named textview1.\n\nTry dragging a file or the button onto me."
@view = VR::FileTreeView.new(Dir.pwd,"./img")
@view.refresh()
@view.expand_row(@view.model.iter_first.path, false)
... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/71_prettify_view/src/PrettyView.rb | Ruby | mit | 46 | master | 1,425 | class PrettyView < VR::ListView
include GladeGUI
def initialize()
super({ name: String, balance: Float })
col_width(name: 160, balance: 120)
col_attr(:balance, alignment: 1, xalign: 1) # align header and numbers to right
refresh()
self.visible = true
each_cell_method(:balance, :balanc... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | examples/20_calculator/src/CalculatorGUI.rb | Ruby | mit | 46 | master | 985 | class CalculatorGUI
include GladeGUI
def before_show()
@window1 = "Calculator" #sets window1's title to "Calculator"
@button = [ 1, 2, 3, "C" ] +
[ 4, 5, 6, "+" ] +
[ 7, 8, 9, "-" ] +
[ 0, ".","/","=" ]
@clear_display = false
@display = @builder["ui... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | skeleton/document/NewWindow.rb | Ruby | mit | 46 | master | 289 | class MyClass #(change name)
include GladeGUI
#code that runs immediately before the #show_glade method of this class
def before_show()
@var1 = "Hello World"
end
def widget__clicked(*args)
#code that runs when widget named "widget" in glade is clicked.
end
end |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | src/editor/VR_TextViewCommon.rb | Ruby | mit | 46 | master | 1,073 | module VR_TextViewCommon
def get_line_iters(line, search_str = nil)
s = buffer.get_iter_at(:line => line)
e = get_end_iter(s)
if !search_str.nil?
s, e = s.forward_search(search_str, :case_insensitive, e)
end
return s, e
end
def select_text(line, search_str = nil)
s, e = get_line_... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | src/editor/VR_Document.rb | Ruby | mit | 46 | master | 5,086 | class VR_Document < GtkSource::View
include VR_TextViewCommon
attr_accessor :full_path_file, :title, :settings, :context, :hilight
def initialize(full_path_file, title_label, main)
@main = main
super()
@title = title_label #reference to label on tab
@full_path_file = full_path_file
rel... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | src/editor/VR_TabSearch.rb | Ruby | mit | 46 | master | 1,289 | module VR_TabSearch
def find_in_all(str, case_sensitive)
out = "Search Results for: " + str + "\n"
out += scan_for_text(str, @docs[self.page].buffer.text, @docs[self.page].full_path_file, case_sensitive)
(0..self.n_pages-1).each do |i|
if i != self.page
out += scan_for_text(str, @docs[i]... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | src/editor/VR_TextShell.rb | Ruby | mit | 46 | master | 1,843 | class VR_TextShell < GtkSource::View
include VR_TextViewCommon
def initialize(tabs)
super()
@tabs = tabs
@current_line = 0
@lines = [] #needed
self.editable = false
@blue = buffer.create_tag("blue", { "foreground" => "#0000A0", "underline" => :single }) # Pango::UNDERLINE_SINGLE })
se... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | src/editor/VR_Tabs.rb | Ruby | mit | 46 | master | 5,424 | class VR_Tabs < Gtk::Notebook
attr_reader :docs
include VR_TabSearch
def initialize(main)
super()
@docs = []
@main = main
@x_img = File.dirname(__FILE__) + '/../../img/close.png'
self.scrollable = true #after super
self.expand = true
end
#todo update file tree, parent window?
def... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | src/main/Find_Replace.rb | Ruby | mit | 46 | master | 4,354 | class Find_Replace
include GladeGUI
def initialize(tabs, shell)
@tabs = tabs
@shell = shell
@entryFind = @tabs.docs[@tabs.page].selected_text()
@entryReplace = nil
@checkCase = true
@comboFiles = "All Files in Project"
end
def buttonNext__clicked(*a)
get_glade_variables
return... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | src/main/VR_ENV.rb | Ruby | mit | 46 | master | 685 | class VR_ENV
include GladeGUI
SETTINGS_FILE = ".vr_settings.yaml"
attr_accessor :width, :height, :panel_pos
attr_accessor :run_command_line, :open_files, :open_folders, :current_file
attr_accessor :notebook_panel_position, :current_line
#to add setting, just add to list
def defaults
@width ||= 70... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | src/main/ProjectTree.rb | Ruby | mit | 46 | master | 574 | class ProjectTree < VR::FileTreeView #(change name)
attr_accessor :ftv
include GladeGUI
def initialize()
path = $VR_ENV_GLOBAL.projects_home
icon_path = File.expand_path(File.join(File.path(__FILE__), "..", "..", "..", "img"))
super(path, icon_path, "*", proc { |folder| has_settings_file?(folder)... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | src/main/VR_ENV_GLOBAL.rb | Ruby | mit | 46 | master | 1,883 | class VR_ENV_GLOBAL
GLOBAL_SETTINGS_FILE = File.join(ENV["HOME"], "visualruby", ".global_settings.yaml")
include GladeGUI
attr_accessor :browser, :tab_spaces, :glade_path, :default_project, :projects_home_open_folders
attr_accessor :font_name, :settings_file_version, :projects_home, :home_project
#r... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | src/main/VR_File_Tree.rb | Ruby | mit | 46 | master | 5,254 | class VR_File_Tree < VR::FileTreeView
def initialize(main, icon_path)
super(Dir.pwd, icon_path)
@main = main
@api = RubygemsAPI.new
@builder = Gtk::Builder.new(file: File.join(File.dirname(__FILE__), "glade", "VR_File_Tree.glade"))
@builder.connect_signals{ |handle| method(handle) }
col_visi... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | src/main/OpenProject.rb | Ruby | mit | 46 | master | 2,155 | class OpenProject
include GladeGUI
def initialize(parent)
@parent = parent
@projects_home = $VR_ENV_GLOBAL.projects_home
end
def before_show
@ftv = ProjectTree.new()
@ftv.show
@ftv.set_show_expanders(false)
@builder["view"].add_child(@ftv)
end
def ftv__cursor_changed(*a)
@ftv... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | src/main/VR_Tools.rb | Ruby | mit | 46 | master | 3,567 | module VR_Tools
# this freezes screen while command executes, returns output.
# use Open3.popen3() to run in different process.
def VR_Tools.popen(cmd)
begin
lines = IO.popen(cmd).readlines
lines ||= [""]
return lines.join()
rescue
alert("The following command couldn't run:\n... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | src/main/GemTree.rb | Ruby | mit | 46 | master | 590 | class GemTree < VR::ListView
RUBY_ICON = GdkPixbuf::Pixbuf.new(:file => File.dirname(__FILE__) + '/../../img/rb.png')
def initialize()
hash = {:gems => {:pix => GdkPixbuf::Pixbuf, :gem => String}}
super(hash)
self.headers_visible = false
@api = RubygemsAPI.new
end
def self__button_release_eve... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | src/main/VR_Remote_Gem_Tree.rb | Ruby | mit | 46 | master | 1,633 | class VR_Remote_Gem_Tree < GemTree
def initialize(main)
super()
@main = main
@gems = Hash.new
@builder = Gtk::Builder.new(file: File.join(File.dirname(__FILE__), "glade", "VR_Remote_Gem_Tree.glade"))
@builder.connect_signals{ |handle| method(handle) }
end
def refresh(force = true)
return... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | src/main/NewProjectGUI.rb | Ruby | mit | 46 | master | 643 | class NewProjectGUI
include GladeGUI
def initialize(parent)
@parent = parent
@projects_home = $VR_ENV_GLOBAL.projects_home + "/" # sets in glade
end
def buttonCreate__clicked(*args)
fn = @builder["entryFolderName"].text
fn = fn.gsub(/[^\w\.\/\-]/, '_')
path = File.join($VR_ENV_GLOBAL.proj... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | src/main/VR_Main.rb | Ruby | mit | 46 | master | 8,778 | class VR_Main
include GladeGUI
attr_accessor :proj_path, :tabs, :shell, :builder, :file_tree
def initialize(argv)
# can pass project on command line
@proj_path = VR_Tools.vr_project?(argv[0]) ? argv[0] : nil
end
def before_show
# there must be a visualruby directory:
required_project... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.