Skip to content

Commit

Permalink
gui add: when specifying nonexisting control type, fall back to text …
Browse files Browse the repository at this point in the history
…instead

could also show an error (was broken before), but this was just easier to code
  • Loading branch information
phil294 committed Dec 19, 2022
1 parent e9bb892 commit 14dfb0c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/cmd/gtk/gui/gui-add.cr
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ class Cmd::Gtk::Gui::GuiAdd < Cmd::Base
thread.runner.display.gui.gui(thread, gui_id, no_wait: true) do |gui|
widget : ::Gtk::Widget? = nil
case type.downcase
when "text"
widget = ::Gtk::Label.new text
widget.has_window = true
widget.events = ::Gdk::EventMask::BUTTON_PRESS_MASK.to_i
widget.connect "button-press-event", run_g_label
when "edit"
if opt["r"]?.try &.[:n].try &.> 1
widget = ::Gtk::ScrolledWindow.new vexpand: true, hexpand: false, shadow_type: ::Gtk::ShadowType::IN
Expand Down Expand Up @@ -75,7 +70,10 @@ class Cmd::Gtk::Gui::GuiAdd < Cmd::Base
widget.events = ::Gdk::EventMask::BUTTON_PRESS_MASK.to_i
widget.connect "button-press-event", run_g_label
else
raise Run::RuntimeException.new "Unknown Gui control '#{type}'"
widget = ::Gtk::Label.new text
widget.has_window = true
widget.events = ::Gdk::EventMask::BUTTON_PRESS_MASK.to_i
widget.connect "button-press-event", run_g_label
end

widget.override_background_color(::Gtk::StateFlags::NORMAL, gui.control_color) if gui.control_color
Expand Down

0 comments on commit 14dfb0c

Please sign in to comment.