Add Mode key for list

This commit is contained in:
daleclack 2024-01-19 19:00:05 +08:00
parent 015e9c3089
commit 5bb679604a
4 changed files with 31 additions and 12 deletions

View File

@ -7,14 +7,18 @@ class ModelColumns : public Glib::Object
{ {
public: public:
// Create a new object // Create a new object
static Glib::RefPtr<ModelColumns> create(Glib::ustring &branch1, Glib::ustring &version1) static Glib::RefPtr<ModelColumns> create(Glib::ustring &branch1,
Glib::ustring &version1, guint mode1)
{ {
return Glib::make_refptr_for_instance<ModelColumns>(new ModelColumns(branch1, version1)); return Glib::make_refptr_for_instance<ModelColumns>(
new ModelColumns(branch1, version1, mode1));
} }
static Glib::RefPtr<ModelColumns> create(const char *branch1, const char *version1) static Glib::RefPtr<ModelColumns> create(const char *branch1,
const char *version1, guint mode1)
{ {
Glib::ustring temp_branch(branch1), temp_version(version1); Glib::ustring temp_branch(branch1), temp_version(version1);
return Glib::make_refptr_for_instance<ModelColumns>(new ModelColumns(temp_branch, temp_version)); return Glib::make_refptr_for_instance<ModelColumns>(
new ModelColumns(temp_branch, temp_version, mode1));
} }
// Get Value of branch and version // Get Value of branch and version
@ -28,6 +32,11 @@ public:
return version_prep.get_value(); return version_prep.get_value();
} }
guint get_branch_mode()
{
return branch_mode.get_value();
}
// Get PropertyProxy // Get PropertyProxy
Glib::PropertyProxy<Glib::ustring> property_branch() Glib::PropertyProxy<Glib::ustring> property_branch()
{ {
@ -39,17 +48,24 @@ public:
return version_prep.get_proxy(); return version_prep.get_proxy();
} }
Glib::PropertyProxy<guint> property_branch_mode()
{
return branch_mode.get_proxy();
}
private: private:
// Use Glib::Property to bind // Use Glib::Property to bind
Glib::Property<Glib::ustring> branch_prep, version_prep; Glib::Property<Glib::ustring> branch_prep, version_prep;
Glib::Property<guint> branch_mode;
protected: protected:
// Register type and initalize properties // Register type and initalize properties
ModelColumns(Glib::ustring branch, Glib::ustring version) ModelColumns(Glib::ustring branch, Glib::ustring version, guint mode)
: Glib::ObjectBase(typeid(ModelColumns)), : Glib::ObjectBase(typeid(ModelColumns)),
Glib::Object(), Glib::Object(),
branch_prep(*this, "branch", branch), branch_prep(*this, "branch", branch),
version_prep(*this, "version", version) version_prep(*this, "version", version),
branch_mode(*this, "branch-mode", mode)
{ {
} }
}; };

View File

@ -286,7 +286,7 @@ void MyWin::on_window_hide(Gtk::Window *window)
void MyWin::main_releases() void MyWin::main_releases()
{ {
// Get Selection // Get Selection
int version = drop_down.get_selected(); guint version = drop_down.get_selected();
char str[57]; char str[57];
// Get Version string // Get Version string

View File

@ -126,8 +126,8 @@ void release_mode_1(struct tm *local, const XeVer &version1, char *callback_str)
int year2 = local->tm_year + 1900, int year2 = local->tm_year + 1900,
month2 = local->tm_mon + 1, day2 = local->tm_mday; month2 = local->tm_mon + 1, day2 = local->tm_mday;
// get release version // get release version
lts_ver = total_year_day(longterm_year, year2) - lts_ver = total_year_day(version1.year, year2) -
total_day(longterm_year, longterm_month, longterm_day) + total_day(version1.year, longterm_month, version1.day) +
total_day(year2, month2, day2); total_day(year2, month2, day2);
// For show in dialog or console // For show in dialog or console
snprintf(callback_str, 57, "Xeinit %s version:%s.%d\n", snprintf(callback_str, 57, "Xeinit %s version:%s.%d\n",
@ -151,8 +151,8 @@ void release_mode_2(struct tm *local, const XeVer &version1, char *callback_str)
int year2 = local->tm_year + 1900, int year2 = local->tm_year + 1900,
month2 = local->tm_mon + 1, day2 = local->tm_mday; month2 = local->tm_mon + 1, day2 = local->tm_mday;
// get release version // get release version
devel1 = total_year_day(stable_year, year2) - devel1 = total_year_day(version1.year, year2) -
total_day(stable_year, stable_month, stable_day) + total_day(version1.year, stable_month, version1.day) +
total_day(year2, month2, day2); total_day(year2, month2, day2);
snprintf(callback_str, 57, "Xeinit %s Version:%s.%d\n", snprintf(callback_str, 57, "Xeinit %s Version:%s.%d\n",
version1.branch, version1.version, devel1); version1.branch, version1.version, devel1);

View File

@ -7,6 +7,9 @@
using json = nlohmann::json; using json = nlohmann::json;
typedef struct{ typedef struct{
int year;
int month;
int day;
char *branch; char *branch;
char *version; char *version;
}XeVer; }XeVer;
@ -21,7 +24,7 @@ void release_mode_2(struct tm *local,const XeVer &version1, char *callback_str);
void json_config_init(json &user_data); void json_config_init(json &user_data);
void dale(struct tm *local); // void dale(struct tm *local);
// void longterm(struct tm *local,const char * lts,char *str); // void longterm(struct tm *local,const char * lts,char *str);