首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Glade作为GTK3 3/4/5(而不是Gnome-Builder)的起点

Glade作为GTK3 3/4/5(而不是Gnome-Builder)的起点
EN

Stack Overflow用户
提问于 2018-03-04 21:55:23
回答 1查看 1.3K关注 0票数 1

现在已经花了一些时间来处理Gnome、Glade、Vala和Genie --并且考虑到优秀的Gnome人机界面准则(GHIG) --为什么Glade不是几乎所有GTK GUI应用程序的起点呢?

例如,是否有任何程序将采用Glade (模板) xml文件并自动生成相应的编程Vala或Genie源代码?例如,如果有标准的GHIG Glade xml文件,而GHIG是随Glade/Gnome一起提供的,那么这些文件可以很快地适应于特定的项目和带有信号自动生成的Genie类模板,再加上完整的gresource/meson/flatpak结构。这只是直接导入作为起点。有做过这样的事吗?

更新

下面的文件application.gs是使用Genie属性组合从application.ui自动生成的。我不想在这里重新发明轮子--这就是提出这个问题的原因。下面删除了一些字段,但是实际的文件已经完全完成,可以使用了。除了“application.ui”的内容之外,唯一需要的信息是资源路径和ui文件名。所有内容都已包含在Glade文件中。

代码语言:javascript
复制
/*
  {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 */
EN

回答 1

Stack Overflow用户

发布于 2018-03-05 09:49:51

例如,是否有任何程序将采用Glade (模板) xml文件并自动生成相应的编程Vala或Genie源代码?

休想。Glade曾经有一个嵌入式特性,可以生成相应的代码来创建UI。这被删除是有一个很好的原因的:它使应用程序代码不可维护,因为您手动修改生成的代码,如果您想要更改UI,则必须重新生成源代码并解决所有冲突。

现在,使用Glade生成的UI文件是使用GtkBuilder的几行代码。不过,我同意在您的代码中插入具有正确签名的回调将是一个好处。也许侏儒生成器计划这么做?您可能需要检查GNOME Builder developper博客

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49100904

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档