Skip to content

Commit

Permalink
Do not show Git commit info in about dialog if it could not be found
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperupcall committed Dec 31, 2022
1 parent cf22e98 commit b527a7c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 106 deletions.
4 changes: 2 additions & 2 deletions cmake/include/Version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ endif()
# Variable is set with generated stamp to PARENT_SCOPE
function(core_find_git_rev stamp)
# allow manual setting GIT_VERSION
if(GIT_VERSION)
if(DEFINED GIT_VERSION)
set(${stamp} ${GIT_VERSION} PARENT_SCOPE)
else()
find_package(Git)
Expand Down Expand Up @@ -76,7 +76,7 @@ function(core_find_git_rev stamp)
if(EXISTS ${CMAKE_SOURCE_DIR}/VERSION)
file(STRINGS ${CMAKE_SOURCE_DIR}/VERSION HASH LIMIT_INPUT 16)
else()
set(HASH "nogitfound")
set(HASH "")
endif()
endif()
cmake_parse_arguments(arg "FULL" "" "" ${ARGN})
Expand Down
36 changes: 31 additions & 5 deletions src/core/gui/dialog/AboutDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,40 @@
class GladeSearchpath;

AboutDialog::AboutDialog(GladeSearchpath* gladeSearchPath): GladeGui(gladeSearchPath, "about.glade", "aboutDialog") {
gtk_label_set_markup(GTK_LABEL(get("lbBuildDate")), __DATE__ ", " __TIME__);
gtk_label_set_markup(GTK_LABEL(get("lbVersion")), PROJECT_VERSION);
gtk_label_set_markup(GTK_LABEL(get("lbRevId")), GIT_COMMIT_ID);

auto insertPropertyKey = [](GtkGrid* grid, std::string&& str, gint top) {
auto widget = gtk_label_new(NULL);
gtk_label_set_markup(GTK_LABEL(widget), str.insert(0, "<b>").append("</b>").c_str());
gtk_widget_set_halign(widget, GtkAlign::GTK_ALIGN_START);
gtk_widget_show(widget);
gtk_grid_attach(grid, widget, 0, top, 1, 1);
};

auto insertPropertyValue = [](GtkGrid* grid, std::string const& str, gint top) {
auto widget = gtk_label_new(str.c_str());
gtk_widget_set_halign(widget, GtkAlign::GTK_ALIGN_START);
gtk_widget_show(widget);
gtk_grid_attach(grid, widget, 1, top, 1, 1);
};

auto infoGrid = GTK_GRID(get("versionInfoGrid"));

insertPropertyKey(infoGrid, _("Version"), 0);
insertPropertyValue(infoGrid, PROJECT_VERSION, 0);

insertPropertyKey(infoGrid, _("Built on"), 1);
insertPropertyValue(infoGrid, __DATE__ ", " __TIME__, 1);

insertPropertyKey(infoGrid, _("GTK Version"), 2);
char gtkVersion[10];
sprintf(gtkVersion, "%u.%u.%u", gtk_get_major_version(), gtk_get_minor_version(), gtk_get_micro_version());
insertPropertyValue(infoGrid, gtkVersion, 2);

auto const gitCommitId = std::string{GIT_COMMIT_ID};
if (!gitCommitId.empty()) {
insertPropertyKey(infoGrid, _("Git commit"), 3);
insertPropertyValue(infoGrid, gitCommitId.c_str(), 3);
}

gtk_label_set_markup(GTK_LABEL(get("lbGtkVersion")), gtkVersion);

auto w1 = get("vboxRepo");
auto linkButton1 = gtk_link_button_new("https://github.com/xournalpp/xournalpp");
Expand Down
2 changes: 0 additions & 2 deletions src/core/gui/dialog/AboutDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,4 @@ class AboutDialog: public GladeGui {

public:
void show(GtkWindow* parent) override;

private:
};
105 changes: 8 additions & 97 deletions ui/about.glade
Original file line number Diff line number Diff line change
Expand Up @@ -79,117 +79,28 @@
<property name="row-spacing">12</property>
<property name="column-spacing">10</property>
<child>
<object class="GtkLabel" id="lbVersion">
<property name="name">lbVersion</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label">X.X.X</property>
<property name="selectable">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
<placeholder/>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Built on</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
</packing>
<placeholder/>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Git commit</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
<placeholder/>
</child>
<child>
<object class="GtkLabel" id="lbRevId">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">RELEASE_IDENTIFIER</property>
<property name="selectable">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
</packing>
<placeholder/>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">with libgtk</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">3</property>
</packing>
<placeholder/>
</child>
<child>
<object class="GtkLabel" id="lbGtkVersion">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">X.X.X</property>
<property name="selectable">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">3</property>
</packing>
<placeholder/>
</child>
<child>
<object class="GtkLabel" id="lbBuildDate">
<property name="name">lbBuildDate</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label">DATE TIME</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
</packing>
<placeholder/>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Version</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
<placeholder/>
</child>
</object>
<packing>
Expand Down

0 comments on commit b527a7c

Please sign in to comment.