# File gtk2/sample/testgtk/testgtk.rb, line 155 def main srand Gtk::RC.parse("testgtkrc") create_main_window Gtk.main end
Create bookmarkfile data.
# File clutter-gstreamer/sample/video-player.rb, line 77 def actor_animate(actor, mode, duration, first_property, *args) actor.save_easing_state actor.easing_mode = mode actor.easing_duration = duration actor.set_property(first_property, args.first) end
#add_depend_package(“glib2”, “ext/glib2”, “/.…./ruby-gnome2”)
# File glib2/lib/mkmf-gnome2.rb, line 148 def add_depend_package(target_name, target_srcdir, top_srcdir, options={}) gem_spec = find_gem_spec(target_name) if gem_spec target_source_dir = File.join(gem_spec.full_gem_path, "ext/#{target_name}") target_build_dir = target_source_dir add_depend_package_path(target_name, target_source_dir, target_build_dir) end [top_srcdir, File.join(top_srcdir, target_name), $configure_args['--topdir'], File.join($configure_args['--topdir'], target_name)].each do |topdir| topdir = File.expand_path(topdir) target_source_dir_full_path = File.join(topdir, target_srcdir) top_build_dir = options[:top_build_dir] || topdir target_build_dir = options[:target_build_dir] || target_srcdir target_build_dir_full_path = File.join(top_build_dir, target_build_dir) unless File.exist?(target_build_dir_full_path) target_build_dir_full_path = File.join(top_build_dir, target_srcdir) end unless File.exist?(target_build_dir_full_path) target_build_dir_full_path = File.join(topdir, target_build_dir) end unless File.exist?(target_build_dir_full_path) target_build_dir_full_path = File.join(topdir, target_srcdir) end add_depend_package_path(target_name, target_source_dir_full_path, target_build_dir_full_path) end end
# File glib2/lib/mkmf-gnome2.rb, line 183 def add_depend_package_path(target_name, target_source_dir, target_build_dir) if File.exist?(target_source_dir) $INCFLAGS = "-I#{target_source_dir} #{$INCFLAGS}" end case RUBY_PLATFORM when /cygwin|mingw|mswin/ target_base_dir = Pathname.new(target_source_dir).parent.parent target_binary_base_dir = target_base_dir + "vendor" + "local" if target_binary_base_dir.exist? $INCFLAGS = "-I#{target_binary_base_dir}/include #{$INCFLAGS}" target_pkg_config_dir = target_binary_base_dir + "lib" + "pkgconfig" PKGConfig.add_path(target_pkg_config_dir.to_s) end end return unless File.exist?(target_build_dir) if target_source_dir != target_build_dir $INCFLAGS = "-I#{target_build_dir} #{$INCFLAGS}" end case RUBY_PLATFORM when /cygwin|mingw|mswin/ library_base_name = "ruby-#{target_name.gsub(/-/, '_')}" case RUBY_PLATFORM when /cygwin|mingw/ $LDFLAGS << " -L#{target_build_dir}" $libs << " -l#{library_base_name}" when /mswin/ $DLDFLAGS << " /libpath:#{target_build_dir}" $libs << " lib#{library_base_name}.lib" end end end
# File glib2/lib/mkmf-gnome2.rb, line 218 def add_distcleanfile(file) $distcleanfiles ||= [] $distcleanfiles << file end
# File glib2/lib/mkmf-gnome2.rb, line 436 def add_obj(name) ensure_objs $objs << name unless $objs.index(name) end
# File glib2/lib/mkmf-gnome2.rb, line 448 def check_cairo(options={}) rcairo_source_dir = options[:rcairo_source_dir] if rcairo_source_dir and !File.exist?(rcairo_source_dir) rcairo_source_dir = nil end if rcairo_source_dir.nil? cairo_gem_spec = find_gem_spec("cairo") rcairo_source_dir = cairo_gem_spec.full_gem_path if cairo_gem_spec end unless rcairo_source_dir.nil? if /mingw|cygwin|mswin/ =~ RUBY_PLATFORM options = {} build_dir = "tmp/#{RUBY_PLATFORM}/cairo/#{RUBY_VERSION}" if File.exist?(File.join(rcairo_source_dir, build_dir)) options[:target_build_dir] = build_dir end add_depend_package("cairo", "ext/cairo", rcairo_source_dir, options) $defs << "-DRUBY_CAIRO_PLATFORM_WIN32" end $CFLAGS += " -I#{rcairo_source_dir}/ext/cairo" end PKGConfig.have_package('cairo') and have_header('rb_cairo.h') end
# File glib2/lib/mkmf-gnome2.rb, line 408 def check_ruby_func #Other options ruby_header = "ruby.h" have_func("rb_define_alloc_func", ruby_header) # for ruby-1.8 have_func("rb_block_proc", ruby_header) # for ruby-1.8 STDOUT.print("checking for new allocation framework... ") # for ruby-1.7 if Object.respond_to? :allocate STDOUT.print "yes\n" $defs << "-DHAVE_OBJECT_ALLOCATE" else STDOUT.print "no\n" end STDOUT.print("checking for attribute assignment... ") # for ruby-1.7 STDOUT.flush if defined? try_compile and try_compile <<SRC #include "ruby.h" #include "node.h" int node_attrasgn = (int)NODE_ATTRASGN; SRC STDOUT.print "yes\n" $defs << "-DHAVE_NODE_ATTRASGN" else STDOUT.print "no\n" end end
# File clutter-gstreamer/sample/video-player.rb, line 311 def clamp(x, low, high) if x > high high elsif x < low low else x end end
# File poppler/sample/pdf2.rb, line 60 def compute_size(width, height, rotate) width = width.to_f height = height.to_f radius = 0 unless rotate.zero? radius = rotate / 180.0 * Math::PI if (90 < rotate and rotate < 180) or (270 < rotate and rotate < 360) radius -= Math::PI / 2 end end inner_angle1 = Math.atan(width / height) inner_angle2 = Math.atan(height / width) diagonal = Math.sqrt(width ** 2 + height ** 2) angle1 = radius + inner_angle1 angle2 = radius + inner_angle2 bottom1 = diagonal * Math.cos(angle1) length1 = (bottom1 * Math.tan(angle1)).abs.to_i bottom2 = diagonal * Math.cos(angle2) length2 = (bottom2 * Math.tan(angle2)).abs.to_i if (0 <= rotate and rotate <= 90) or (180 <= rotate and rotate <= 270) [length1, length2] else [length2, length1] end end
# File clutter-gstreamer/sample/video-player.rb, line 71 def controls_timeout_cb(app) app.controls_timeout = 0 show_controls(app, false) false end
# File gtk2/sample/misc/buttonbox.rb, line 13 def create_bbox_window(horizontal, title, pos, spacing, layout) window = Gtk::Window.new(title) window.signal_connect("delete_event") do window.destroy end box1 = Gtk::VBox.new(false, 0) window.add(box1) if horizontal window.set_default_size(550, 60) window.move(150, pos) bbox = Gtk::HButtonBox.new else window.set_default_size(150, 400) window.move(pos, 200) bbox = Gtk::VButtonBox.new end bbox.layout_style = layout bbox.spacing = spacing box1.border_width = 25 box1.pack_start(bbox, true, true, 0) button = Gtk::Button.new("OK") bbox.add(button) button.signal_connect("clicked") do window.destroy end button = Gtk::Button.new("Cancel") bbox.add(button) button.signal_connect("clicked") do window.destroy end button = Gtk::Button.new("Help") bbox.add(button) window.show_all end
Main Window
# File gtk2/sample/testgtk/testgtk.rb, line 71 def create_main_window buttons = [ ["button box", ButtonBoxSample], ["buttons", ButtonSample], ["check buttons", CheckButtonSample], ["color selection", ColorSelectionSample], ["dialog", DialogSample], ["entry", EntrySample], ["file selection", FileSelectionSample], ["font selection", FontSelectionSample], ["gamma curve", GammaCurveSample], ["labels", LabelSample], ["layout", LayoutSample], ["menus", MenuSample], ["notebook", NotebookSample], ["pixmap", PixmapSample], ["progress bar", ProgressBarSample], ["radio buttons", RadioButtonSample], ["range controls", RangeSample], ["reparent", ReparentSample], ["rulers", RulerSample], ["saved position", SavedPositionSample], ["scrolled windows", ScrolledWindowSample], ["shapes", ShapesSample], ["spinbutton", SpinButtonSample], ["statusbar", StatusbarSample], ["toggle buttons", ToggleButtonSample], ["toolbar", ToolbarSample], ["tooltips", TooltipsSample], ["WM hints", WMHintsSample], ] nbuttons = buttons.size window = Gtk::Window.new window.name = "main window" window.set_default_size(200, 400) window.move(20, 20) window.signal_connect("destroy"){Gtk.main_quit} box1 = Gtk::VBox.new(false, 0) window.add(box1) label = Gtk::Label.new("Gtk+ v#{Gtk::MAJOR_VERSION}.#{Gtk::MINOR_VERSION}.#{Gtk::MICRO_VERSION}") box1.pack_start(label, false, false, 0) label = Gtk::Label.new("Ruby/GTK2 v#{Gtk::BINDING_VERSION.join(".")}") box1.pack_start(label, false, false, 0) scrolled_window = Gtk::ScrolledWindow.new(nil, nil) scrolled_window.border_width = 10 scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC) box1.pack_start(scrolled_window, true, true, 0) box2 = Gtk::VBox.new(false, 0) box2.border_width = 10 scrolled_window.add_with_viewport(box2); box2.focus_vadjustment = scrolled_window.vadjustment buttons.each do |title, sample_class| button = Gtk::Button.new(title) unless sample_class.nil? button.signal_connect("clicked"){|obj| sample_class.invoke } else button.sensitive = false end box2.pack_start(button, true, true, 0) end box1.pack_start(Gtk::HSeparator.new, false, true, 0) button = Gtk::Button.new("close") button.signal_connect("clicked") do window.destroy Gtk.main_quit end box1.pack_start(button, false, true, 5) window.show_all end
# File glib2/lib/mkmf-gnome2.rb, line 283 def create_makefile_at_srcdir(pkg_name, srcdir, defs = nil) base_dir = File.basename(Dir.pwd) last_common_index = srcdir.rindex(base_dir) if last_common_index builddir = srcdir[(last_common_index + base_dir.size + 1)..-1] end builddir ||= "." FileUtils.mkdir_p(builddir) Dir.chdir(builddir) do yield if block_given? $defs << defs if defs ensure_objs create_makefile(pkg_name, srcdir) end end
# File glib2/lib/mkmf-gnome2.rb, line 223 def create_pkg_config_file(package_name, c_package, version=nil, pc_file_name=nil) pc_file_name ||= "#{package_name.downcase.sub(/\//, '-')}.pc" version ||= ruby_gnome2_version || PKGConfig.modversion(c_package) puts "creating #{pc_file_name}" File.open(pc_file_name, 'w') do |pc_file| if package_name.nil? c_module_name = PKGConfig.name(c_package) package_name = "Ruby/#{c_module_name}" if c_module_name end pc_file.puts("Name: #{package_name}") if package_name description = PKGConfig.description(c_package) pc_file.puts("Description: Ruby bindings for #{description}") if description pc_file.printf("Version: #{version}") end add_distcleanfile(pc_file_name) end
# File glib2/lib/mkmf-gnome2.rb, line 317 def create_top_makefile(sub_dirs=["src"]) File.open("Makefile", "w") do |makefile| makefile.print("all: #{run_make_in_sub_dirs_command("all", sub_dirs)} install: #{run_make_in_sub_dirs_command("install", sub_dirs)} site-install: #{run_make_in_sub_dirs_command("site-install", sub_dirs)} clean: #{run_make_in_sub_dirs_command("clean", sub_dirs)} ") if /mswin/ =~ RUBY_PLATFORM makefile.print(" @if exist extconf.h del extconf.h @if exist conftest.* del conftest.* @if exist *.lib del *.lib @if exist *~ del *~ @if exist mkmf.log del mkmf.log ") else makefile.print(" distclean: clean #{run_make_in_sub_dirs_command("distclean", sub_dirs)} @rm -f Makefile extconf.h conftest.* @rm -f core *~ mkmf.log ") end end end
# File glib2/lib/mkmf-gnome2.rb, line 23 def disable_optimization_build_flag(flags) if gcc? flags.gsub(/(^|\s)?-O\d(\s|$)?/, '\1-O0\2') else flags end end
# File pango/sample/pango_cairo.rb, line 24 def draw_text(cr) # Center coordinates on the middle of the region we are drawing cr.translate(RADIUS, RADIUS); # Create a PangoLayout, set the font and text layout = cr.create_pango_layout layout.set_text("Text") desc = Pango::FontDescription.new(FONT) layout.set_font_description(desc) # Draw the layout N_WORDS times in a circle N_WORDS.times do |i| angle = (360.0 * i) / N_WORDS; cr.save do # Gradient from red at angle == 60 to blue at angle == 300 red = (1 + Math.cos((angle - 60) * Math::PI / 180.0)) / 2 cr.set_source_rgb(red, 0, 1.0 - red) cr.rotate(angle * Math::PI / 180.0) # Inform Pango to re-layout the text with the new transformation cr.update_pango_layout(layout) width, height = layout.size cr.move_to(-(width.to_f / Pango::SCALE) / 2, -RADIUS) cr.show_pango_layout(layout) end end end
# File gtk2/sample/misc/tooltips.rb, line 55 def drawingarea_query_tooltip(keyboard_tip, x, y, tooltip, rectangles) if keyboard_tip return false end for r in rectangles if r.x < x && x < r.x + 50 && r.y < y && y < r.y + 50 tooltip.markup = r.tooltip return true end end return false end
# File glib2/lib/mkmf-gnome2.rb, line 31 def enable_debug_build_flag(flags) if gcc? debug_option_pattern = /(^|\s)?-g\d?(\s|$)?/ if debug_option_pattern =~ flags flags.gsub(debug_option_pattern, '\1-g3\2') else flags + " -g3" end else flags end end
# File glib2/lib/mkmf-gnome2.rb, line 269 def ensure_objs return unless $objs.nil? source_dir = '$(srcdir)' RbConfig.expand(source_dir) pattern = "*.{#{SRC_EXT.join(',')}}" srcs = Dir[File.join(source_dir, pattern)] srcs |= Dir[File.join(".", pattern)] $objs = srcs.collect do |f| File.basename(f, ".*") + ".o" end.uniq end
# File gstreamer/sample/framestep1.rb, line 26 def event_loop(pipe) running = true bus = pipe.bus while running message = bus.timed_pop_filtered(Gst::CLOCK_TIME_NONE, Gst::MessageType::ANY) raise "message nil" if message.nil? case message.type when Gst::MessageType::EOS puts "got EOS" running = false when Gst::MessageType::WARNING warning, debug = message.parse_warning puts "Debugging info: #{debug || 'none'}" puts "Warning: #{warning.message}" when Gst::MessageType::ERROR error, debug = message.parse_error puts "Debugging info: #{debug || 'none'}" puts "Error: #{error.message}" running = false when Gst::MessageType::STEP_DONE format, amount, rate, flush, intermediate, duration, eos = message.parse_step_done if format == Gst::Format::DEFAULT puts "step done: #{gst_time(duration)} skipped in #{gst_time(amount)} frames" else puts "step done: #{gst_time(duration)} skipped" end running = false end end end
# File glib2/lib/mkmf-gnome2.rb, line 134 def find_gem_spec(package) begin require 'rubygems' if Gem::Specification.respond_to?(:find_by_name) Gem::Specification.find_by_name(package) else Gem.source_index.find_name(package).last end rescue LoadError nil end end
# File glib2/lib/mkmf-gnome2.rb, line 19 def gcc? CONFIG["GCC"] == "yes" end
# File glib2/lib/mkmf-gnome2.rb, line 441 def glib_mkenums(prefix, files, g_type_prefix, include_files, options={}) add_distcleanfile(prefix + ".h") add_distcleanfile(prefix + ".c") GLib::MkEnums.create(prefix, files, g_type_prefix, include_files, options) add_obj("#{prefix}.o") end
# File gstreamer/sample/framestep1.rb, line 61 def gst_time(time) Time.at(time / 1000000000.0).utc.strftime("%H:%M:%S.%N") end
# File glib2/lib/mkmf-gnome2.rb, line 504 def install_missing_native_package(native_package_info) platform = package_platform native_package_info = normalize_native_package_info(native_package_info) package = native_package_info[platform] return false if package.nil? package_name, *options = package package_command_line = [package_name, *options].join(" ") need_super_user_priviledge = true case platform when :debian install_command = "apt-get install -V -y #{package_command_line}" when :fedora, :redhat install_command = "yum install -y #{package_command_line}" when :suse install_command = "zypper --non-interactive install #{package_command_line}" when :homebrew need_super_user_priviledge = false install_command = "brew install #{package_command_line}" when :macports install_command = "port install -y #{package_command_line}" else return false end have_priviledge = (not need_super_user_priviledge or super_user?) unless have_priviledge sudo = find_executable("sudo") end installing_message = "installing '#{package_name}' native package... " message("%s", installing_message) failed_to_get_super_user_priviledge = false if have_priviledge succeeded = xsystem(install_command) else if sudo prompt = "[sudo] password for %u to install <#{package_name}>: " sudo_options = "-p #{Shellwords.escape(prompt)}" install_command = "#{sudo} #{sudo_options} #{install_command}" succeeded = xsystem(install_command) else succeeded = false failed_to_get_super_user_priviledge = true end end if failed_to_get_super_user_priviledge result_message = "require super user privilege" else result_message = succeeded ? "succeeded" : "failed" end Logging.postpone do "#{installing_message}#{result_message}\n" end message("#{result_message}\n") error_message = nil unless succeeded if failed_to_get_super_user_priviledge error_message = <<-EOM '#{package_name}' native package is required. run the following command as super user to install required native package: \# #{install_command} EOM else error_message = <<-EOM failed to run '#{install_command}'. EOM end end if error_message message("%s", error_message) Logging.message("%s", error_message) end Logging.message("--------------------\n\n") succeeded end
# File gtk2/sample/testgtk/testgtk.rb, line 155 def main srand Gtk::RC.parse("testgtkrc") create_main_window Gtk.main end
This is used for the library which doesn't support version info.
# File glib2/lib/mkmf-gnome2.rb, line 354 def make_version_header(app_name, pkgname, dir = "src") version = PKGConfig.modversion(pkgname).split(/\./) (0..2).each do |v| version[v] = "0" unless version[v] if /\A(\d+)/ =~ version[v] number = $1 tag = $POSTMATCH unless tag.empty? version[v] = number version[3] = tag end end end filename = "rb#{app_name.downcase}version.h" puts "creating #{filename}" add_distcleanfile(filename) FileUtils.mkdir_p(dir) out = File.open(File.join(dir, filename), "w") version_definitions = [] ["MAJOR", "MINOR", "MICRO", "TAG"].each_with_index do |type, i| _version = version[i] next if _version.nil? version_definitions << "#define #{app_name}_#{type}_VERSION (#{_version})" end out.print %Q[/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ /************************************************ #{filename} - This file was generated by mkmf-gnome2.rb. ************************************************/ #ifndef __RB#{app_name}_VERSION_H__ #define __RB#{app_name}_VERSION_H__ #{version_definitions.join("\n")} #define #{app_name}_CHECK_VERSION(major,minor,micro) \\ (#{app_name}_MAJOR_VERSION > (major) || \\ (#{app_name}_MAJOR_VERSION == (major) && #{app_name}_MINOR_VERSION > (minor)) || \\ (#{app_name}_MAJOR_VERSION == (major) && #{app_name}_MINOR_VERSION == (minor) && \\ #{app_name}_MICRO_VERSION >= (micro))) #endif /* __RB#{app_name}_VERSION_H__ */ ] out.close end
# File clutter-gstreamer/sample/video-player.rb, line 140 def new_rectangle_with_color(color) actor = Clutter::Actor.new actor.background_color = color actor end
# File glib2/lib/mkmf-gnome2.rb, line 496 def normalize_native_package_info(native_package_info) native_package_info ||= {} native_package_info = native_package_info.dup native_package_info[:fedora] ||= native_package_info[:redhat] native_package_info[:suse] ||= native_package_info[:fedora] native_package_info end
# File glib2/lib/mkmf-gnome2.rb, line 474 def package_platform if File.exist?("/etc/debian_version") :debian elsif File.exist?("/etc/fedora-release") :fedora elsif File.exist?("/etc/redhat-release") :redhat elsif File.exist?("/etc/SuSE-release") :suse elsif find_executable("brew") :homebrew elsif find_executable("port") :macports else :unknown end end
# File gstreamer/sample/gst-inspect.rb, line 34 def parse(argv) options = OpenStruct.new options.print_all = false options.print_auto_install_info = false opts = OptionParser.new do |opts| opts.banner += " [ELEMENT-NAME|PLUGIN-NAME]" opts.version = Gst.version opts.separator("") opts.on("-a", "--print-all", "Print all elements") do options.print_all = true end opts.on("--print-plugin-auto-install-info", "Print a machine-parsable list of features", "the specified plugin provides.", "Useful in connection with external", "automatic plugin installation mechanisms") do options.print_auto_install_info = true end end opts.parse!(argv) [options, argv.first] end
# File clutter-gstreamer/sample/video-player.rb, line 130 def position_controls(app, controls) stage_width, stage_height = app.stage.size bg_width, bg_height = app.control.size x = ((stage_width - bg_width) / 2).floor y = stage_height - bg_height - 28 controls.set_position(x, y) end
# File glib2/lib/mkmf-gnome2.rb, line 585 def required_pkg_config_package(package_info, native_package_info=nil) if package_info.is_a?(Array) required_package_info = package_info else required_package_info = [package_info] end return true if PKGConfig.have_package(*required_package_info) native_package_info ||= {} return false unless install_missing_native_package(native_package_info) PKGConfig.have_package(*required_package_info) end
# File glib2/lib/mkmf-gnome2.rb, line 245 def ruby_gnome2_version(glib_source_directory=nil) glib_source_directory ||= File.join(File.dirname(__FILE__), "..", "ext", "glib2") rbglib_h = File.join(glib_source_directory, "rbglib.h") return nil unless File.exist?(rbglib_h) version = nil File.open(rbglib_h) do |h_file| version_info = {} h_file.each_line do |line| case line when /\A#define RBGLIB_(MAJOR|MINOR|MICRO)_VERSION\s+(\d+)/ version_info[$1] = $2 end end version_info = [version_info["MAJOR"], version_info["MINOR"], version_info["MICRO"]].compact version = version_info.join(".") if version_info.size == 3 end version end
generate top-level Makefile
# File extconf.rb, line 108 def run_make_in_sub_dir(sub_dir, target) if /mswin/ =~ RUBY_PLATFORM " $(COMMAND) '#{sub_dir}' $(MAKE) #{target}" else " (cd '#{sub_dir}' && $(MAKE) #{target})" end end
# File glib2/lib/mkmf-gnome2.rb, line 301 def run_make_in_sub_dirs_command(command, sub_dirs) if /mswin/ =~ RUBY_PLATFORM sub_dirs.collect do |dir| " @cd #{dir} @nmake -nologo DESTDIR=$(DESTDIR) #{command} @cd .. ".chmop end.join("\n") else sub_dirs.collect do |dir| "\t@cd #{dir}; $(MAKE) #{command}" end.join("\n") end end
for creating a separating line
# File run-test.rb, line 13 def separator "-" * 80 end
# File glib2/lib/mkmf-gnome2.rb, line 112 def setup_win32(target_name, base_dir=nil) checking_for(checking_message("Win32 OS")) do case RUBY_PLATFORM when /cygwin|mingw|mswin/ import_library_name = "libruby-#{target_name}.a" $DLDFLAGS << " -Wl,--out-implib=#{import_library_name}" $cleanfiles << import_library_name base_dir ||= Pathname($0).dirname.parent.parent.expand_path base_dir = Pathname(base_dir) if base_dir.is_a?(String) binary_base_dir = base_dir + "vendor" + "local" if binary_base_dir.exist? $CFLAGS += " -I#{binary_base_dir}/include" pkg_config_dir = binary_base_dir + "lib" + "pkgconfig" PKGConfig.add_path(pkg_config_dir.to_s) end true else false end end end
# File clutter-gstreamer/sample/video-player.rb, line 85 def show_controls(app, vis) return if app.control.nil? if vis == true && app.controls_showing == true if app.controls_timeout == 0 app.controls_timeout = GLib::Timeout.add_seconds(5) do controls_timeout_cb(app) end end return end if vis == true && app.controls_showing == false app.controls_showing = true app.stage.show_cursor actor_animate(app.control, :ease_out_quint, 250, "opacity", 224) return end if vis == false && app.controls_showing == true app.controls_showing = false if app.mouse_in_window app.stage.hide_cursor end actor_animate(app.control, :ease_out_quint, 250, "opacity", 0) return end end
# File glib2/lib/mkmf-gnome2.rb, line 492 def super_user? Process.uid.zero? end
# File gtk2/sample/misc/buttonbox.rb, line 54 def test_hbbox create_bbox_window(true, "Spread", 50, 40, Gtk::ButtonBox::SPREAD) create_bbox_window(true, "Edge", 250, 40, Gtk::ButtonBox::EDGE) create_bbox_window(true, "Start", 450, 40, Gtk::ButtonBox::START) create_bbox_window(true, "End", 650, 15, Gtk::ButtonBox::END) end
# File gtk2/sample/misc/buttonbox.rb, line 61 def test_vbbox create_bbox_window(false, "Spread", 50, 40, Gtk::ButtonBox::SPREAD) create_bbox_window(false, "Edge", 250, 40, Gtk::ButtonBox::EDGE) create_bbox_window(false, "Start", 450, 40, Gtk::ButtonBox::START) create_bbox_window(false, "End", 650, 15, Gtk::ButtonBox::END) end
# File gtk2/sample/misc/tooltips.rb, line 40 def textview_query_tooltip(textview, keyboard_tip, x, y, tooltip, tag) if keyboard_tip iter = textview.buffer.get_iter_at_offset(textview.buffer.cursor_position) else bx, by = textview.window_to_buffer_coords(Gtk::TextView::WINDOW_TEXT, x, y) iter, = textview.get_iter_at_position(bx, by) end if iter.has_tag?(tag) tooltip.text = 'Tooltip on text tag' return true else return false end end
# File rsvg2/sample/svg2.rb, line 44 def to_pixbuf(input, ratio) RSVG.pixbuf_from_file_at_zoom(input, ratio, ratio) end
# File poppler/sample/pdf2.rb, line 91 def to_pixbuf_with_cairo(input, page_number, scale, rotate) doc = Poppler::Document.new(input) page = doc[page_number] width, height = page.size.collect {|x| x * scale} surface_width, surface_height = compute_size(width, height, rotate) surface = Cairo::ImageSurface.new(Cairo::FORMAT_ARGB32, surface_width, surface_height) cr = Cairo::Context.new(surface) half_width = surface_width / 2.0 half_height = surface_height / 2.0 cr.translate(half_width, half_height) cr.rotate(rotate / 180.0 * Math::PI) cr.translate(-half_width, -half_height) cr.translate((surface_width - width) / 2.0, (surface_height - height) / 2.0) cr.set_source_rgb(1, 1, 1) cr.rectangle(0, 0, width, height) cr.fill cr.scale(scale, scale) cr.render_poppler_page(page) temp = Tempfile.new("pdf2") cr.target.write_to_png(temp.path) cr.target.finish Gdk::Pixbuf.new(temp.path) end
# File clutter-gstreamer/sample/video-player.rb, line 114 def toggle_pause_state(app) return if app.vtexture.nil? if app.paused app.vtexture.playing = true app.paused = false app.control_play.hide app.control_pause.show else app.vtexture.playing = false app.paused = true app.control_pause.hide app.control_play.show end end
# File gtk2/sample/misc/tooltips.rb, line 20 def treeview_query_tooltip(treeview, keyboard_tip, x, y, tooltip) if keyboard_tip # Keyboard mode path, = treeview.cursor if not path return false end else bin_x, bin_y = treeview.convert_widget_to_bin_window_coords(x, y) # Mouse mode path, = treeview.get_path_at_pos(bin_x, bin_y) if not path return false end end data = treeview.model.get_value(treeview.model.get_iter(path), 0) tooltip.markup = "<b>Path #{path}:</b> #{data}" return true end
# File glib2/lib/mkmf-gnome2.rb, line 56 def try_compiler_option(opt, &block) checking_for "#{opt} option to compiler" do if try_compile '', opt + " -Werror", &block $CFLAGS += " #{opt}" true else false end end end