更新版本号
This commit is contained in:
parent
bc01826e79
commit
0649f33883
|
@ -1,3 +1,11 @@
|
|||
libkysdk-base (2.3.0.0-0k0.10) nile; urgency=medium
|
||||
|
||||
* BUG号 : 无
|
||||
* 需求号 : 无
|
||||
* 其他修改 : conf2模块创建用户配置目录时所有者为root的问题处理
|
||||
|
||||
-- tian-shaoshuai <tianshaoshuai@kylinos.cn> Mon, 04 Dec 2023 17:24:42 +0800
|
||||
|
||||
libkysdk-base (2.3.0.0-0k0.9) nile; urgency=medium
|
||||
|
||||
* BUG号 : 无
|
||||
|
|
|
@ -2,4 +2,6 @@ usr/lib/*/libkyconf2.so*
|
|||
usr/bin/kconf2 usr/bin
|
||||
src/conf2/service/conf2-server.py usr/bin
|
||||
src/conf2/service/kysdk-conf2.conf etc/dbus-1/system.d
|
||||
src/conf2/service/kysdk-conf2.service lib/systemd/system
|
||||
src/conf2/service/kysdk-conf2.service lib/systemd/system
|
||||
src/conf2/service/conf2-session-server.py usr/bin
|
||||
src/conf2/service/kysdk-conf2.desktop etc/xdg/autostart/
|
|
@ -0,0 +1,528 @@
|
|||
From: tianshaoshuai <tianshaoshuai@kylinos.cn>
|
||||
Date: Mon, 4 Dec 2023 17:29:30 +0800
|
||||
Subject: =?utf-8?b?5pu05paw54mI5pys5Y+3?=
|
||||
|
||||
---
|
||||
src/conf2/service/conf2-server.py | 50 +++---
|
||||
src/conf2/service/conf2-session-server.py | 33 ++++
|
||||
src/conf2/service/kysdk-conf2.desktop | 9 +
|
||||
src/conf2/tools/kconf2-editor.c | 266 ++++++++++++++++++------------
|
||||
4 files changed, 219 insertions(+), 139 deletions(-)
|
||||
create mode 100644 src/conf2/service/conf2-session-server.py
|
||||
create mode 100644 src/conf2/service/kysdk-conf2.desktop
|
||||
|
||||
diff --git a/src/conf2/service/conf2-server.py b/src/conf2/service/conf2-server.py
|
||||
index f6a9ace..953bb47 100644
|
||||
--- a/src/conf2/service/conf2-server.py
|
||||
+++ b/src/conf2/service/conf2-server.py
|
||||
@@ -1,3 +1,4 @@
|
||||
+#!/usr/bin/python3
|
||||
import yaml, sqlite3
|
||||
import os, re
|
||||
|
||||
@@ -15,14 +16,9 @@ class KYSettingsDBusService(dbus.service.Object):
|
||||
|
||||
def __init__(self, bus_name, object_path):
|
||||
dbus.service.Object.__init__(self, bus_name, object_path)
|
||||
-
|
||||
- # if sys.pa ('/etc/kylin-config/basic'))
|
||||
- # self.__read_only_view.update(self.__load_config__('/etc/kylin-config/production'))
|
||||
- # self.__read_only_view.update(self.__load_config__('/etc/kylin-config/vendor'))
|
||||
- # self.__read_only_view.update(self.__load_config__('/etc/kylin-config/industry'))
|
||||
- # self.__read_only_view.update(self.__load_config__('/etc/kylin-config/project'))
|
||||
- # self.__read_only_view.update(self.__load_config__('/etc/kylin-config/control'))
|
||||
|
||||
+ os.makedirs('/etc/kylin-config', exist_ok=True)
|
||||
+
|
||||
# 监听SessionNew信号 创建对应用户的数据库
|
||||
self.__login_bus = dbus.SystemBus()
|
||||
self.__login_obj = self.__login_bus.get_object('org.freedesktop.login1', '/org/freedesktop/login1')
|
||||
@@ -51,24 +47,24 @@ class KYSettingsDBusService(dbus.service.Object):
|
||||
|
||||
def __creat_db_file__(self):
|
||||
# 系统级配置
|
||||
- if not os.path.exists('/root/.config/kylin-config/user.db'):
|
||||
+ if not os.path.exists('/etc/kylin-config/user.db'):
|
||||
if self.__root_view == {}:
|
||||
self.__load_read_only_view__()
|
||||
- self.__dict2db__(self.__read_only_view, '/root/.config/kylin-config/user.db')
|
||||
+ self.__dict2db__(self.__read_only_view, '/etc/kylin-config/user.db')
|
||||
else:
|
||||
- self.__dict2db__(self.__root_view, '/root/.config/kylin-config/user.db')
|
||||
+ self.__dict2db__(self.__root_view, '/etc/kylin-config/user.db')
|
||||
if self.__root_view == {}:
|
||||
- self.__root_view = self.__format_db_file('/root/.config/kylin-config/user.db')
|
||||
+ self.__root_view = self.__format_db_file('/etc/kylin-config/user.db')
|
||||
# 用户级配置 可能需要链接用户登录信号
|
||||
- if self.__user_name is not None:
|
||||
- if not os.path.exists(f'/home/{self.__user_name}/.config/kylin-config/user.db'):
|
||||
- if self.__user_view == {}:
|
||||
- self.__load_read_only_view__()
|
||||
- self.__dict2db__(self.__read_only_view, f'/home/{self.__user_name}/.config/kylin-config/user.db')
|
||||
- else:
|
||||
- self.__dict2db__(self.__user_view, f'/home/{self.__user_name}/.config/kylin-config/user.db')
|
||||
- if self.__user_view == {}:
|
||||
- self.__user_view = self.__format_db_file(f'/home/{self.__user_name}/.config/kylin-config/user.db')
|
||||
+ # if self.__user_name is not None:
|
||||
+ # if not os.path.exists(f'/home/{self.__user_name}/.config/kylin-config/user.db'):
|
||||
+ # if self.__user_view == {}:
|
||||
+ # self.__load_read_only_view__()
|
||||
+ # self.__dict2db__(self.__read_only_view, f'/home/{self.__user_name}/.config/kylin-config/user.db')
|
||||
+ # else:
|
||||
+ # self.__dict2db__(self.__user_view, f'/home/{self.__user_name}/.config/kylin-config/user.db')
|
||||
+ # if self.__user_view == {}:
|
||||
+ # self.__user_view = self.__format_db_file(f'/home/{self.__user_name}/.config/kylin-config/user.db')
|
||||
|
||||
def __covert_app_table__(self,data: dict, cursor: sqlite3.Cursor):
|
||||
# 创建app表
|
||||
@@ -232,10 +228,6 @@ class KYSettingsDBusService(dbus.service.Object):
|
||||
data = self.__load_config__('/etc/kylin-config/control')
|
||||
self.__merge_dict(self.__read_only_view, data)
|
||||
|
||||
- # 测试文件
|
||||
- data = self.__load_config__(f'/home/{self.__user_name}/yaml')
|
||||
- self.__merge_dict(self.__read_only_view, data)
|
||||
-
|
||||
def __dict2db__(self, dict, path):
|
||||
try:
|
||||
# 连接到数据库(如果不存在则创建)
|
||||
@@ -354,7 +346,7 @@ class KYSettingsDBusService(dbus.service.Object):
|
||||
view = {}
|
||||
if user == 'root':
|
||||
view = self.__root_view
|
||||
- sql_path = '/root/.config/kylin-config/user.db'
|
||||
+ sql_path = '/etc/kylin-config/user.db'
|
||||
else:
|
||||
view = self.__user_view
|
||||
sql_path = f'/home/{user}/.config/kylin-config/user.db'
|
||||
@@ -398,7 +390,7 @@ class KYSettingsDBusService(dbus.service.Object):
|
||||
view = {}
|
||||
if user == 'root':
|
||||
view = self.__root_view
|
||||
- sql_path = '/root/.config/kylin-config/user.db'
|
||||
+ sql_path = '/etc/kylin-config/user.db'
|
||||
else:
|
||||
view = self.__user_view
|
||||
sql_path = f'/home/{user}/.config/kylin-config/user.db'
|
||||
@@ -439,7 +431,7 @@ class KYSettingsDBusService(dbus.service.Object):
|
||||
view = {}
|
||||
if user == 'root':
|
||||
view = self.__root_view
|
||||
- sql_path = '/root/.config/kylin-config/user.db'
|
||||
+ sql_path = '/etc/kylin-config/user.db'
|
||||
else:
|
||||
view = self.__user_view
|
||||
sql_path = f'/home/{user}/.config/kylin-config/user.db'
|
||||
@@ -477,14 +469,12 @@ class KYSettingsDBusService(dbus.service.Object):
|
||||
self.__merge_dict(self.__root_view, self.__read_only_view)
|
||||
self.__merge_dict(self.__user_view, self.__read_only_view)
|
||||
|
||||
- if 0 == self.__dict2db__(self.__root_view, '/root/.config/kylin-config/user.db'):
|
||||
+ if 0 == self.__dict2db__(self.__root_view, '/etc/kylin-config/user.db'):
|
||||
pass
|
||||
if 0 == self.__dict2db__(self.__user_view, f'/home/{self.__user_name}/.config/kylin-config/user.db'):
|
||||
pass
|
||||
self.updated()
|
||||
return 1
|
||||
-
|
||||
-
|
||||
|
||||
if __name__ == "__main__":
|
||||
# 初始化DBus主循环
|
||||
diff --git a/src/conf2/service/conf2-session-server.py b/src/conf2/service/conf2-session-server.py
|
||||
new file mode 100644
|
||||
index 0000000..690bf28
|
||||
--- /dev/null
|
||||
+++ b/src/conf2/service/conf2-session-server.py
|
||||
@@ -0,0 +1,33 @@
|
||||
+#!/usr/bin/python3
|
||||
+import dbus
|
||||
+import dbus.service
|
||||
+from dbus.mainloop.glib import DBusGMainLoop
|
||||
+from gi.repository import GLib
|
||||
+
|
||||
+import os, shutil
|
||||
+
|
||||
+class KYSettingsDBusSessionService(dbus.service.Object):
|
||||
+ def __init__(self, bus_name, object_path):
|
||||
+ dbus.service.Object.__init__(self, bus_name, object_path)
|
||||
+
|
||||
+ @dbus.service.method("com.kylin.kysdk.conf2")
|
||||
+ def Init(self):
|
||||
+ source_file = '/etc/kylin-config/user.db'
|
||||
+ destination_file = '~/.config/kylin-config/user.db'
|
||||
+ destination_file = os.path.expanduser(destination_file)
|
||||
+ if not os.path.exists(destination_file):
|
||||
+ os.makedirs(os.path.dirname(destination_file), exist_ok=True)
|
||||
+ shutil.copyfile(source_file, destination_file)
|
||||
+
|
||||
+if __name__ == "__main__":
|
||||
+
|
||||
+ DBusGMainLoop(set_as_default=True)
|
||||
+
|
||||
+ bus_session = dbus.SessionBus()
|
||||
+ object_path = '/com/kylin/kysdk/conf2'
|
||||
+ bus_sesssion_name = dbus.service.BusName("com.kylin.kysdk.conf2", bus = bus_session)
|
||||
+ my_dbus_session_service = KYSettingsDBusSessionService(bus_sesssion_name, object_path)
|
||||
+ my_dbus_session_service.Init()
|
||||
+
|
||||
+ mainloop = GLib.MainLoop()
|
||||
+ mainloop.run()
|
||||
\ No newline at end of file
|
||||
diff --git a/src/conf2/service/kysdk-conf2.desktop b/src/conf2/service/kysdk-conf2.desktop
|
||||
new file mode 100644
|
||||
index 0000000..2d8a161
|
||||
--- /dev/null
|
||||
+++ b/src/conf2/service/kysdk-conf2.desktop
|
||||
@@ -0,0 +1,9 @@
|
||||
+[Desktop Entry]
|
||||
+Type=Application
|
||||
+Exec=/usr/bin/conf2-session-server.py
|
||||
+TryExec=/usr/bin/conf2-session-server.py
|
||||
+Name=KYSDK-CONF2-SESSION-BUS
|
||||
+Icon=
|
||||
+Keywords=session;kysdk-conf2-session
|
||||
+Comment=This session date you into sdk
|
||||
+NoDisplay=true
|
||||
\ No newline at end of file
|
||||
diff --git a/src/conf2/tools/kconf2-editor.c b/src/conf2/tools/kconf2-editor.c
|
||||
index fde4618..9514289 100644
|
||||
--- a/src/conf2/tools/kconf2-editor.c
|
||||
+++ b/src/conf2/tools/kconf2-editor.c
|
||||
@@ -13,6 +13,8 @@ static GtkTreeView *table_configure = NULL;
|
||||
|
||||
static GHashTable *configure_models = NULL;
|
||||
|
||||
+static guint row_activated_id = 0;
|
||||
+
|
||||
enum ConfigureAttr
|
||||
{
|
||||
COLUMN_NAME,
|
||||
@@ -22,7 +24,112 @@ enum ConfigureAttr
|
||||
COLUMN_COUNT
|
||||
};
|
||||
|
||||
-static const char* title_array[] = {"111", "222"};
|
||||
+static const char *title_array[] = {"名称\n",
|
||||
+ "路径\n",
|
||||
+ "摘要\n",
|
||||
+ "描述\n",
|
||||
+ "类型\n",
|
||||
+ "最小值\n",
|
||||
+ "最大值\n",
|
||||
+ "默认值\n",
|
||||
+ "当前值\n"};
|
||||
+
|
||||
+static void on_row_activated(GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data)
|
||||
+{
|
||||
+ GtkTreeModel *model = gtk_tree_view_get_model(treeview);
|
||||
+
|
||||
+ GtkTreeIter iter;
|
||||
+ if (gtk_tree_model_get_iter(model, &iter, path))
|
||||
+ {
|
||||
+ GtkTreeSelection *selection = user_data;
|
||||
+ GtkTreeModel *folder_model;
|
||||
+ GtkTreeIter folder_selected;
|
||||
+ if (!gtk_tree_selection_get_selected(selection, &folder_model, &folder_selected))
|
||||
+ return;
|
||||
+ GtkTreePath *path = gtk_tree_model_get_path(folder_model, &folder_selected);
|
||||
+ KSettingsSchema *schema = g_hash_table_lookup(configure_models, gtk_tree_path_to_string(path));
|
||||
+
|
||||
+ char *name = NULL;
|
||||
+ gtk_tree_model_get(model, &iter, COLUMN_NAME, &name, -1);
|
||||
+ GHashTable *schema_key = g_hash_table_lookup(schema->values, name);
|
||||
+
|
||||
+ char tmp[4096] = "";
|
||||
+
|
||||
+ GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
|
||||
+
|
||||
+ sprintf(tmp,"%s%s", title_array[0], g_hash_table_lookup(schema_key, "property"));
|
||||
+ GtkWidget *name_label = gtk_label_new(tmp);
|
||||
+ gtk_widget_set_halign(name_label, GTK_ALIGN_START);
|
||||
+ gtk_box_pack_start(vbox, name_label, TRUE, TRUE, 0);
|
||||
+
|
||||
+ sprintf(tmp,"%s%s", title_array[1], schema->id);
|
||||
+ GtkWidget *id_label = gtk_label_new(tmp);
|
||||
+ gtk_widget_set_halign(id_label, GTK_ALIGN_START);
|
||||
+ gtk_box_pack_start(vbox, id_label, TRUE, TRUE, 0);
|
||||
+
|
||||
+ sprintf(tmp,"%s%s", title_array[2], g_hash_table_lookup(schema_key, "summary"));
|
||||
+ GtkWidget *summary_label = gtk_label_new(tmp);
|
||||
+ gtk_widget_set_halign(summary_label, GTK_ALIGN_START);
|
||||
+ gtk_box_pack_start(vbox, summary_label, TRUE, TRUE, 0);
|
||||
+
|
||||
+ sprintf(tmp, "%s%s", title_array[3], g_hash_table_lookup(schema_key, "description"));
|
||||
+ GtkWidget *description_label = gtk_label_new(tmp);
|
||||
+ gtk_widget_set_halign(description_label, GTK_ALIGN_START);
|
||||
+ gtk_box_pack_start(vbox, description_label, TRUE, TRUE, 0);
|
||||
+
|
||||
+ sprintf(tmp,"%s%s", title_array[4], g_hash_table_lookup(schema_key, "attr_type"));
|
||||
+ GtkWidget *type_label = gtk_label_new(tmp);
|
||||
+ gtk_widget_set_halign(type_label, GTK_ALIGN_START);
|
||||
+ gtk_box_pack_start(vbox, type_label, TRUE, TRUE, 0);
|
||||
+
|
||||
+ char *range = g_hash_table_lookup(schema_key, "range");
|
||||
+ if(NULL != range && 0 != strcmp("emun", g_hash_table_lookup(schema_key, "attr_type")))
|
||||
+ {
|
||||
+ char **list = g_strsplit(range,",",-1);
|
||||
+ sprintf(tmp, "%s%s", title_array[5], list[0]);
|
||||
+ GtkWidget *min_tabel = gtk_label_new(tmp);
|
||||
+ gtk_widget_set_halign(min_tabel, GTK_ALIGN_START);
|
||||
+ gtk_box_pack_start(vbox, min_tabel, TRUE, TRUE, 0);
|
||||
+
|
||||
+ sprintf(tmp, "%s%s", title_array[6], list[1]);
|
||||
+ GtkWidget *max_tabel = gtk_label_new(tmp);
|
||||
+ gtk_widget_set_halign(max_tabel, GTK_ALIGN_START);
|
||||
+ gtk_box_pack_start(vbox, max_tabel, TRUE, TRUE, 0);
|
||||
+
|
||||
+ g_strfreev(list);
|
||||
+ }
|
||||
+
|
||||
+ sprintf(tmp,"%s%s", title_array[7], g_hash_table_lookup(schema_key, "default_value"));
|
||||
+ GtkWidget *default_label = gtk_label_new(tmp);
|
||||
+ gtk_widget_set_halign(default_label, GTK_ALIGN_START);
|
||||
+ gtk_box_pack_start(vbox, default_label, TRUE, TRUE, 0);
|
||||
+
|
||||
+ int is_default = strcmp(g_hash_table_lookup(schema_key, "default_value"), g_hash_table_lookup(schema_key, "attr"));
|
||||
+ sprintf(tmp,"%s%s", title_array[8], is_default ? g_hash_table_lookup(schema_key, "attr") : "默认值");
|
||||
+ GtkWidget *value_label = gtk_label_new(tmp);
|
||||
+ gtk_widget_set_halign(value_label, GTK_ALIGN_START);
|
||||
+ gtk_box_pack_start(vbox, value_label, TRUE, TRUE, 0);
|
||||
+
|
||||
+ // GtkWidget *entry_vbox = gtk_vbox_new(FALSE, 0);
|
||||
+ // gtk_box_pack_start(vbox, entry_vbox, TRUE, TRUE, 0);
|
||||
+
|
||||
+ // GtkWidget *entry_label = gtk_label_new("自定义值");
|
||||
+ // gtk_widget_set_halign(entry_label, GTK_ALIGN_START);
|
||||
+ // gtk_widget_set_valign(entry_label, GTK_ALIGN_START);
|
||||
+ // gtk_box_pack_start(entry_vbox, entry_label, TRUE, TRUE, 0);
|
||||
+
|
||||
+ // GtkWidget *entry = gtk_entry_new();
|
||||
+ // gtk_widget_set_halign(entry, GTK_ALIGN_START);
|
||||
+ // gtk_editable_set_editable(GTK_EDITABLE(entry), FALSE);
|
||||
+ // gtk_entry_set_text(entry, g_hash_table_lookup(schema_key, "attr"));
|
||||
+ // gtk_box_pack_start(entry_vbox, entry, TRUE, TRUE, 0);
|
||||
+
|
||||
+ gtk_container_remove(GTK_CONTAINER(right_scrolled_window), table_configure);
|
||||
+ gtk_container_add(GTK_CONTAINER(right_scrolled_window), vbox);
|
||||
+
|
||||
+ gtk_widget_show_all(GTK_WIDGET(right_scrolled_window));
|
||||
+ }
|
||||
+}
|
||||
|
||||
// 选择变化的回调函数
|
||||
void on_selection_changed(GtkTreeSelection *selection, gpointer data)
|
||||
@@ -37,6 +144,17 @@ void on_selection_changed(GtkTreeSelection *selection, gpointer data)
|
||||
else
|
||||
return;
|
||||
|
||||
+ GList *list = gtk_container_get_children(GTK_CONTAINER(right_scrolled_window));
|
||||
+ for (GList *tmp = list; tmp; tmp = tmp->next)
|
||||
+ {
|
||||
+ if (tmp->data != table_configure)
|
||||
+ {
|
||||
+ gtk_container_remove(GTK_CONTAINER(right_scrolled_window), tmp->data);
|
||||
+ gtk_container_add(GTK_CONTAINER(right_scrolled_window), table_configure);
|
||||
+ }
|
||||
+ }
|
||||
+ g_list_free(list);
|
||||
+
|
||||
GtkTreeView *table_configure = data;
|
||||
GtkTreePath *path = gtk_tree_model_get_path(model, &iter);
|
||||
KSettingsSchema *schema = g_hash_table_lookup(configure_models, gtk_tree_path_to_string(path));
|
||||
@@ -61,7 +179,21 @@ void on_selection_changed(GtkTreeSelection *selection, gpointer data)
|
||||
COLUMN_SUMMARY, g_hash_table_lookup(value, "summary"),
|
||||
-1);
|
||||
}
|
||||
- gtk_widget_queue_draw(GTK_WIDGET(table_configure));
|
||||
+ gtk_widget_show_all(GTK_WIDGET(right_scrolled_window));
|
||||
+}
|
||||
+
|
||||
+void on_back_button_clicked(GtkWidget *widget, gpointer data)
|
||||
+{
|
||||
+ GList *list = gtk_container_get_children(GTK_CONTAINER(right_scrolled_window));
|
||||
+ for (GList *tmp = list; tmp; tmp = tmp->next)
|
||||
+ {
|
||||
+ if (tmp->data != table_configure)
|
||||
+ {
|
||||
+ gtk_container_remove(GTK_CONTAINER(right_scrolled_window), tmp->data);
|
||||
+ gtk_container_add(GTK_CONTAINER(right_scrolled_window), table_configure);
|
||||
+ }
|
||||
+ }
|
||||
+ g_list_free(list);
|
||||
}
|
||||
|
||||
// 回调函数,在左侧 GTreeView 的行被单击时被触发
|
||||
@@ -98,50 +230,6 @@ gboolean on_left_tree_view_button_press(GtkWidget *widget, GdkEventButton *event
|
||||
}
|
||||
}
|
||||
|
||||
-static void on_row_activated(GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data)
|
||||
-{
|
||||
- printf("11111\n");
|
||||
- // GtkTreeView *table_configure = user_data;
|
||||
- // GtkTreeModel *model;
|
||||
- // GtkTreeIter iter;
|
||||
-
|
||||
- // model = gtk_tree_view_get_model(treeview);
|
||||
-
|
||||
- // if (gtk_tree_model_get_iter(model, &iter, path))
|
||||
- // {
|
||||
- // KSettingsSchema *schema = g_hash_table_lookup(configure_models, gtk_tree_path_to_string(path));
|
||||
-
|
||||
- // if (NULL == schema)
|
||||
- // return;
|
||||
-
|
||||
- // model = gtk_tree_view_get_model(table_configure);
|
||||
- // GtkListStore *store = GTK_LIST_STORE(model);
|
||||
- // // gtk_list_store_clear(store);
|
||||
- // g_object_unref(store);
|
||||
-
|
||||
- // store = gtk_list_store_new(COLUMN_COUNT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
|
||||
- // gtk_tree_view_set_model(table_configure, GTK_TREE_MODEL(store));
|
||||
-
|
||||
- // GtkTreeIter iter;
|
||||
- // char *key;
|
||||
- // GHashTable *value;
|
||||
- // GHashTableIter iter_hash;
|
||||
- // g_hash_table_iter_init(&iter_hash, schema->values);
|
||||
- // while (g_hash_table_iter_next(&iter_hash, &key, &value))
|
||||
- // {
|
||||
- // gtk_list_store_append(store, &iter);
|
||||
- // gtk_list_store_set(store, &iter,
|
||||
- // COLUMN_NAME, g_hash_table_lookup(value, "property"),
|
||||
- // COLUMN_TYPE, g_hash_table_lookup(value, "attr_type"),
|
||||
- // COLUMN_VALUE, g_hash_table_lookup(value, "attr"),
|
||||
- // COLUMN_SUMMARY, g_hash_table_lookup(value, "summary"),
|
||||
- // -1);
|
||||
- // }
|
||||
- // gtk_widget_queue_draw(GTK_WIDGET(table_configure));
|
||||
- // gtk_widget_show_all(window);
|
||||
- // }
|
||||
-}
|
||||
-
|
||||
static void creat_configure_widget_recursively(GtkTreeStore *store, GtkTreeIter *iter_parent, GHashTable *hash_configure, char *id, char *path)
|
||||
{
|
||||
if (NULL == configure_models)
|
||||
@@ -232,35 +320,47 @@ int main(int argc, char *argv[])
|
||||
gtk_container_add(GTK_CONTAINER(window), GTK_PANED(splitter));
|
||||
gtk_paned_set_position(GTK_PANED(splitter), 200);
|
||||
|
||||
- //创建左侧滚动视图,存放组件树
|
||||
+ // 创建左侧滚动视图,存放组件树
|
||||
left_scrolled_window = gtk_scrolled_window_new(NULL, NULL);
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(left_scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||
gtk_paned_add1(GTK_PANED(splitter), GTK_WIDGET(left_scrolled_window));
|
||||
|
||||
- //创建右侧组件树
|
||||
+ // 创建右侧组件树
|
||||
tree_folders = gtk_tree_view_new();
|
||||
gtk_container_add(GTK_CONTAINER(left_scrolled_window), tree_folders);
|
||||
|
||||
- //创建列
|
||||
+ // 创建列
|
||||
GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes("Folders", gtk_cell_renderer_text_new(), "text", 0, NULL);
|
||||
gtk_tree_view_insert_column(GTK_TREE_VIEW(tree_folders), column, -1);
|
||||
- gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree_folders), TRUE);
|
||||
+ gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree_folders), TRUE);
|
||||
|
||||
- //设置为单选模式
|
||||
+ // 设置为单选模式
|
||||
GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_folders));
|
||||
gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
|
||||
|
||||
- //创建右侧滚动窗口
|
||||
+ GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
|
||||
+ gtk_paned_add2(GTK_PANED(splitter), GTK_WIDGET(vbox));
|
||||
+
|
||||
+ GtkWidget *back_button = gtk_button_new();
|
||||
+ GtkWidget *arrow_icon = gtk_image_new_from_icon_name("go-up-symbolic", GTK_ICON_SIZE_BUTTON);
|
||||
+ gtk_button_set_image(GTK_CONTAINER(back_button), arrow_icon);
|
||||
+ gtk_widget_set_size_request(back_button, 10, 10);
|
||||
+ gtk_widget_set_size_request(back_button, 10, 10);
|
||||
+ gtk_box_pack_start(GTK_BOX(vbox), back_button, FALSE, FALSE, 0);
|
||||
+
|
||||
+ // 创建右侧滚动窗口
|
||||
right_scrolled_window = gtk_scrolled_window_new(NULL, NULL);
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(right_scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||
- gtk_paned_add2(GTK_PANED(splitter), GTK_WIDGET(right_scrolled_window));
|
||||
+ // gtk_paned_add2(GTK_PANED(splitter), GTK_WIDGET(right_scrolled_window));
|
||||
+ gtk_box_pack_start(GTK_BOX(vbox), right_scrolled_window, TRUE, TRUE, 0);
|
||||
|
||||
- //创建表格
|
||||
+ // 创建表格
|
||||
table_configure = gtk_tree_view_new();
|
||||
+ g_object_ref(table_configure);
|
||||
gtk_tree_view_set_grid_lines(GTK_TREE_VIEW(table_configure), GTK_TREE_VIEW_GRID_LINES_BOTH);
|
||||
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(table_configure), TRUE);
|
||||
g_object_ref(table_configure);
|
||||
- // gtk_container_add(GTK_CONTAINER(right_scrolled_window), GTK_WIDGET(table_configure));
|
||||
+ gtk_container_add(GTK_CONTAINER(right_scrolled_window), GTK_WIDGET(table_configure));
|
||||
|
||||
// name列
|
||||
GtkCellRenderer *renderer_name = gtk_cell_renderer_text_new();
|
||||
@@ -295,62 +395,10 @@ int main(int argc, char *argv[])
|
||||
GtkListStore *store = gtk_list_store_new(COLUMN_COUNT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
|
||||
gtk_tree_view_set_model(table_configure, GTK_TREE_MODEL(store));
|
||||
|
||||
- GtkWidget *grid = gtk_grid_new();
|
||||
- gtk_container_add(GTK_CONTAINER(right_scrolled_window), GTK_WIDGET(grid));
|
||||
-
|
||||
- GtkWidget *name_label = gtk_label_new("摘要\n saefwiowerfjio");
|
||||
- gtk_widget_set_halign(name_label, GTK_ALIGN_START); // 设置按钮水平对齐方式为左对齐
|
||||
-
|
||||
- gtk_grid_attach(GTK_GRID(grid), name_label, 0, 0, 1, 1);
|
||||
-
|
||||
- GtkWidget *id_label = gtk_label_new("摘要\n saefwiowerfjio");
|
||||
- gtk_widget_set_halign(id_label, GTK_ALIGN_START); // 设置按钮水平对齐方式为左对齐
|
||||
- gtk_grid_attach(GTK_GRID(grid), id_label, 0, 1, 1, 1);
|
||||
-
|
||||
- GtkWidget *summary_label = gtk_label_new("摘要\n saefwiowerfjio");
|
||||
- gtk_widget_set_halign(summary_label, GTK_ALIGN_START); // 设置按钮水平对齐方式为左对齐
|
||||
- gtk_grid_attach(GTK_GRID(grid), summary_label, 0, 2, 1, 1);
|
||||
-
|
||||
- GtkWidget *description_label = gtk_label_new("摘要\n saefwiowerfjioddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd");
|
||||
- gtk_widget_set_halign(description_label, GTK_ALIGN_START); // 设置按钮水平对齐方式为左对齐
|
||||
- // gtk_label_set_line_wrap(GTK_LABEL(description_label), TRUE);
|
||||
- // g_object_set(label, "wrap", TRUE, "wrap-width", 200, NULL); // 设置标签自动换行和换行宽度
|
||||
- gtk_grid_attach(GTK_GRID(grid), description_label, 0, 3, 1, 1);
|
||||
-
|
||||
- GtkWidget *type_label = gtk_label_new("摘要\n saefwiowerfjio");
|
||||
- gtk_widget_set_halign(type_label, GTK_ALIGN_START); // 设置按钮水平对齐方式为左对齐
|
||||
- gtk_grid_attach(GTK_GRID(grid), type_label, 0, 4, 1, 1);
|
||||
-
|
||||
- GtkWidget *default_label = gtk_label_new("摘要\n saefwiowerfjio");
|
||||
- gtk_widget_set_halign(default_label, GTK_ALIGN_START); // 设置按钮水平对齐方式为左对齐
|
||||
- gtk_grid_attach(GTK_GRID(grid), default_label, 0, 5, 1, 1);
|
||||
-
|
||||
- GtkWidget *value_label = gtk_label_new("摘要\n saefwiowerfjio");
|
||||
- gtk_widget_set_halign(value_label, GTK_ALIGN_START); // 设置按钮水平对齐方式为左对齐
|
||||
- gtk_grid_attach(GTK_GRID(grid), value_label, 0, 6, 1, 1);
|
||||
-
|
||||
- // 创建一个输入框和一个开关按钮
|
||||
- GtkEntryBuffer *buffer = gtk_entry_buffer_new("1234",4);
|
||||
- GtkWidget *entry = gtk_entry_new_with_buffer(buffer);
|
||||
- gtk_widget_set_halign(entry, GTK_ALIGN_START); // 设置按钮水平对齐方式为左对齐
|
||||
- // gtk_widget_set_hexpand(entry, TRUE);
|
||||
- // GtkWidget *toggle_button = gtk_toggle_button_new_with_label("Enable Input");
|
||||
-
|
||||
- // 将输入框添加到Grid布局中,设置宽度占满窗体
|
||||
- gtk_grid_attach(GTK_GRID(grid), entry, 0, 7, 3, 3);
|
||||
- // gtk_widget_set_hexpand(entry, TRUE);
|
||||
-
|
||||
- // // 将开关按钮添加到Grid布局中,设置在输入框的左上方
|
||||
- // gtk_grid_attach(GTK_GRID(grid), toggle_button, 0, 7, 1, 1);
|
||||
- // gtk_widget_set_halign(toggle_button, GTK_ALIGN_START);
|
||||
- // gtk_widget_set_valign(toggle_button, GTK_ALIGN_START);
|
||||
-
|
||||
-
|
||||
// 监听组件树选择变化的回调函数
|
||||
g_signal_connect(G_OBJECT(selection), "changed", G_CALLBACK(on_selection_changed), table_configure);
|
||||
- g_signal_connect(G_OBJECT(table_configure), "row-activated", G_CALLBACK(on_row_activated), right_scrolled_window);
|
||||
- // g_signal_connect(G_OBJECT(tree_folders), "button-press-event", G_CALLBACK(on_left_tree_view_button_press), table_configure);
|
||||
-
|
||||
+ g_signal_connect(G_OBJECT(table_configure), "row-activated", G_CALLBACK(on_row_activated), selection);
|
||||
+ g_signal_connect(G_OBJECT(back_button), "clicked", G_CALLBACK(on_back_button_clicked),NULL);
|
||||
|
||||
draw_scrolled_window(tree_folders);
|
||||
|
|
@ -7,3 +7,4 @@
|
|||
0007-conf2-pc.patch
|
||||
0008-conf2-pc.patch
|
||||
0009-conf2-Requires-shlib.patch
|
||||
0010-.patch
|
||||
|
|
Loading…
Reference in New Issue