【发布时间】:2018-03-04 21:55:23
【问题描述】:
现在已经花了一些时间来了解 Gnome Builder、Glade、Vala 和 Genie - 并考虑到优秀的 Gnome 人机界面指南 (GHIG) - 为什么 Glade 不是几乎所有 GTK GUI 应用程序的起点?
例如,是否有任何程序会采用 Glade(模板)xml 文件并自动生成相应的程序化 Vala 或 Genie 源代码?例如,如果有标准 Gtk.ApplicationWindow Glade xml 文件,这些文件遵循 Glade/Gnome 附带的 GHIG,这些文件可以快速适应特定项目和带有自动生成信号的 Genie 类模板 - 加上完整的 gresource/介子/flatpak结构。这将简单地直接导入 Gnome-Builder 作为起点。有没有做过类似的事情?
更新
以下文件 application.gs 是使用 Genie 属性组合从 application.ui 自动生成的。不想在这里重新发明轮子——这就是这个问题的原因。以下删除了一些字段,但实际文件已完全完成并可以使用。除了 'application.ui' 的内容之外,唯一需要的信息是资源路径和 ui 文件名。一切都已包含在 Glade 文件中。
/*
{PROJECT_SPACE}
'{PROJECT_NAME}' is a command line tool that will parse a glade ui
template and generate a skeleton class in the Genie language
with composite widgets. It will generate GTKTemplate, GTKChild
and GTKCallback entries.
'{PROJECT_NAME}' exists within the {PROJECT_NAMESPACE} namespace.
Copyright (C) 2018 {AUTHOR_NAME} {AUTHOR_EMAIL}
This library is free software; you can redistribute it and or
or modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (as you wish) a later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the:
Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor
Boston, MA 02110-1301
USA
*/
[indent=4]
namespace {PROJECT_NAMESPACE}
[GtkTemplate (ui = "{RESOURCE_URI}/application.ui")]
class ApplicationWindow:Gtk.ApplicationWindow
[GtkChild]
application_grid:Gtk.Fixed
[GtkChild]
application_status_bar:Gtk.Statusbar
[GtkChild]
header_bar:Gtk.HeaderBar
[GtkChild]
application_button:Gtk.MenuButton
[GtkChild]
window_title:Gtk.Label
[GtkChild]
window_subtitle:Gtk.Label
[GtkChild]
tools_button:Gtk.MenuButton
[GtkChild]
application_popover:Gtk.PopoverMenu
[GtkChild]
home_menu:Gtk.Box
[GtkChild]
project_settings:Gtk.ModelButton
[GtkChild]
lateral_pressure:Gtk.ModelButton
[GtkChild]
service_life:Gtk.ModelButton
[GtkChild]
mixture_analysis:Gtk.ModelButton
[GtkChild]
general_simulation:Gtk.ModelButton
[GtkChild]
exit_application:Gtk.ModelButton
[GtkChild]
projects_menu:Gtk.Box
[GtkChild]
exit_projects:Gtk.ModelButton
[GtkChild]
new_project:Gtk.ModelButton
[GtkChild]
open_project:Gtk.ModelButton
[GtkChild]
save_project:Gtk.ModelButton
[GtkChild]
pressure_menu:Gtk.Box
[GtkChild]
exit_pressure:Gtk.ModelButton
[GtkChild]
boussinesq_3d:Gtk.ModelButton
[GtkChild]
strip_loading:Gtk.ModelButton
[GtkChild]
line_loading:Gtk.ModelButton
[GtkChild]
point_loading:Gtk.ModelButton
[GtkChild]
log_spiral:Gtk.ModelButton
[GtkChild]
service_life_menu:Gtk.Box
[GtkChild]
exit_service_life:Gtk.ModelButton
[GtkChild]
stratful_equation:Gtk.ModelButton
[GtkChild]
clear_equation:Gtk.ModelButton
[GtkChild]
relative_life:Gtk.ModelButton
[GtkChild]
diffusion_theory:Gtk.ModelButton
[GtkChild]
what_if_analysis:Gtk.ModelButton
[GtkChild]
mixture_analysis_menu:Gtk.Box
[GtkChild]
exit_mixture_analysis:Gtk.ModelButton
[GtkChild]
mixture_design:Gtk.ModelButton
[GtkChild]
volumetric_analysis:Gtk.ModelButton
[GtkChild]
particulate_analysis:Gtk.ModelButton
[GtkChild]
general_simulation_menu:Gtk.Box
[GtkChild]
exit_general_simulation:Gtk.ModelButton
[GtkChild]
construction_simulation:Gtk.ModelButton
[GtkChild]
mixture_simulation:Gtk.ModelButton
[GtkChild]
thermal_simulation:Gtk.ModelButton
[GtkCallback]
def on_exit_application_clicked( exit_application:Gtk.ModelButton )
print "Signal handler 'on_exit_application_clicked' was called ..."
[GtkCallback]
def on_new_project_clicked( new_project:Gtk.ModelButton )
print "Signal handler 'on_new_project_clicked' was called ..."
[GtkCallback]
def on_open_project_clicked( open_project:Gtk.ModelButton )
print "Signal handler 'on_open_project_clicked' was called ..."
[GtkCallback]
def on_save_project_clicked( save_project:Gtk.ModelButton )
print "Signal handler 'on_save_project_clicked' was called ..."
[GtkCallback]
def on_boussinesq_3d_clicked( boussinesq_3d:Gtk.ModelButton )
print "Signal handler 'on_boussinesq_3d_clicked' was called ..."
[GtkCallback]
def on_strip_loading_clicked( strip_loading:Gtk.ModelButton )
print "Signal handler 'on_strip_loading_clicked' was called ..."
[GtkCallback]
def on_line_loading_clicked( line_loading:Gtk.ModelButton )
print "Signal handler 'on_line_loading_clicked' was called ..."
[GtkCallback]
def on_point_loading_clicked( point_loading:Gtk.ModelButton )
print "Signal handler 'on_point_loading_clicked' was called ..."
[GtkCallback]
def on_log_spiral_clicked( log_spiral:Gtk.ModelButton )
print "Signal handler 'on_log_spiral_clicked' was called ..."
[GtkCallback]
def on_stratful_equation_clicked( stratful_equation:Gtk.ModelButton )
print "Signal handler 'on_stratful_equation_clicked' was called ..."
[GtkCallback]
def on_clear_equation_clicked( clear_equation:Gtk.ModelButton )
print "Signal handler 'on_clear_equation_clicked' was called ..."
[GtkCallback]
def on_relative_life_clicked( relative_life:Gtk.ModelButton )
print "Signal handler 'on_relative_life_clicked' was called ..."
[GtkCallback]
def on_diffusion_theory_clicked( diffusion_theory:Gtk.ModelButton )
print "Signal handler 'on_diffusion_theory_clicked' was called ..."
[GtkCallback]
def on_what_if_analysis_clicked( what_if_analysis:Gtk.ModelButton )
print "Signal handler 'on_what_if_analysis_clicked' was called ..."
[GtkCallback]
def on_mixture_design_clicked( mixture_design:Gtk.ModelButton )
print "Signal handler 'on_mixture_design_clicked' was called ..."
[GtkCallback]
def on_volumetric_analysis_clicked( volumetric_analysis:Gtk.ModelButton )
print "Signal handler 'on_volumetric_analysis_clicked' was called ..."
[GtkCallback]
def on_particulate_analysis_clicked( particulate_analysis:Gtk.ModelButton )
print "Signal handler 'on_particulate_analysis_clicked' was called ..."
[GtkCallback]
def on_construction_simulation_clicked( construction_simulation:Gtk.ModelButton )
print "Signal handler 'on_construction_simulation_clicked' was called ..."
[GtkCallback]
def on_mixture_simulation_clicked( mixture_simulation:Gtk.ModelButton )
print "Signal handler 'on_mixture_simulation_clicked' was called ..."
[GtkCallback]
def on_thermal_simulation_clicked( thermal_simulation:Gtk.ModelButton )
print "Signal handler 'on_thermal_simulation_clicked' was called ..."
construct()
print "On construction do stuff ..."
final()
print "On destruction do stuff ..."
def activate()
print "On activation do stuff ..."
def process()
print "On processing do stuff ..."
def run()
print "On run do stuff ..."
/* End of file */
【问题讨论】:
-
没有人阻止你。忙起来并发布结果,以便我可以使用它们。哈哈
-
也看看 Anjuta。
-
@theGtknerd 我正在考虑这样做,这就是我要问的原因。
-
Anjuta 与我所知道的一样接近(与您所描述的一样)。我通常可以创建一个新项目并获得一个工作示例,而不是创建基本文件来开始。这对 SO 特别好。
-
@theGtknerd 谢谢,我会看看。我喜欢新的 Gnome Builder 的地方在于 Meson/Flatpak 方向 - 所以如果 Glade 提供类似的方法会很好。