From abee471a1f8fb051c97cc54caafdf65a6cd5e0cc Mon Sep 17 00:00:00 2001 From: zhangkun Date: Mon, 29 Dec 2025 16:32:42 +0800 Subject: [PATCH] chore: remove unused gtk-thumbnailer module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Removed gtk-thumbnailer from TESTS list in Makefile 2. Removed gtk-thumbnailer from BINARIES list in Makefile 3. Deleted main.go file containing GTK thumbnail generation logic 4. Deleted thumbnail.c file with GTK widget rendering implementation 5. Cleaned up build system to exclude this unused component This change removes the gtk-thumbnailer module which was no longer needed in the project. The module contained CGO-based GTK thumbnail generation code that created visual previews of GTK themes. Since this functionality is no longer required or maintained, removing it simplifies the codebase, reduces maintenance overhead, and eliminates unused dependencies on GTK libraries. Influence: 1. Verify that the project builds successfully without the gtk- thumbnailer module 2. Ensure no other components depend on the removed gtk-thumbnailer functionality 3. Test that all remaining tests in the TESTS list still pass 4. Confirm that all remaining binaries in the BINARIES list build correctly 5. Check that the build system doesn't reference the removed files elsewhere chore: 移除未使用的 gtk-thumbnailer 模块 1. 从 Makefile 的 TESTS 列表中移除 gtk-thumbnailer 2. 从 Makefile 的 BINARIES 列表中移除 gtk-thumbnailer 3. 删除包含 GTK 缩略图生成逻辑的 main.go 文件 4. 删除包含 GTK 部件渲染实现的 thumbnail.c 文件 5. 清理构建系统以排除此未使用的组件 此更改移除了项目中不再需要的 gtk-thumbnailer 模块。该模块包含基于 CGO 的 GTK 缩略图生成代码,用于创建 GTK 主题的视觉预览。由于此功能不再需要或维 护,移除它可以简化代码库,减少维护开销,并消除对 GTK 库的未使用依赖。 Influence: 1. 验证项目在没有 gtk-thumbnailer 模块的情况下能成功构建 2. 确保没有其他组件依赖于已移除的 gtk-thumbnailer 功能 3. 测试 TESTS 列表中所有剩余的测试是否仍然通过 4. 确认 BINARIES 列表中所有剩余的二进制文件能正确构建 5. 检查构建系统是否在其他地方引用了已移除的文件 --- Makefile | 2 - gtk-thumbnailer/main.go | 74 ----------------------------- gtk-thumbnailer/thumbnail.c | 94 ------------------------------------- 3 files changed, 170 deletions(-) delete mode 100644 gtk-thumbnailer/main.go delete mode 100644 gtk-thumbnailer/thumbnail.c diff --git a/Makefile b/Makefile index 6b0c821..e018f31 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,6 @@ TESTS = \ ${GOPKG_PREFIX}/graphic \ ${GOPKG_PREFIX}/grub_theme/font \ ${GOPKG_PREFIX}/grub_theme/themetxt \ - ${GOPKG_PREFIX}/gtk-thumbnailer \ ${GOPKG_PREFIX}/hans2pinyin \ ${GOPKG_PREFIX}/i18n_dependent \ ${GOPKG_PREFIX}/image-blur \ @@ -63,7 +62,6 @@ BINARIES = \ graphic \ locale-helper \ hans2pinyin \ - gtk-thumbnailer \ sound-theme-player \ deepin-shutdown-sound \ dde-open \ diff --git a/gtk-thumbnailer/main.go b/gtk-thumbnailer/main.go deleted file mode 100644 index 0d77db6..0000000 --- a/gtk-thumbnailer/main.go +++ /dev/null @@ -1,74 +0,0 @@ -// SPDX-FileCopyrightText: 2018 - 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - -package main - -// #cgo pkg-config: gtk+-3.0 -// #cgo CFLAGS: -W -Wall -fPIC -fstack-protector-all -// #include -// void gtk_thumbnail(char *theme, char *dest, int width, int min_height); -import "C" - -import ( - "flag" - "fmt" - "os" - "path/filepath" - "unsafe" -) - -var ( - force = flag.Bool("force", false, "Force to generate thumbnail") - theme = flag.String("theme", "", "The theme name") - dest = flag.String("dest", "", "The destination of thumbnail file") - width = flag.Int("width", 0, "The thumbnail width") - height = flag.Int("height", 0, "The thumbnail min height") -) - -func main() { - flag.Parse() - if flag.Parsed() { - - if *theme == "" || *dest == "" || *width == 0 || *height == 0 { - flag.Usage() - os.Exit(1) - } - - err := doGenThumbnail(*theme, *dest, *width, *height, *force) - if err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(2) - } - } -} - -func doGenThumbnail(name, dest string, width, height int, force bool) error { - if _, err := os.Stat(dest); err != nil { - if !os.IsNotExist(err) { - return err - } - // file dest not exist - } else { - // file dest exist - if force { - os.Remove(dest) - } else { - return nil - } - } - - err := os.MkdirAll(filepath.Dir(dest), 0755) - if err != nil { - return err - } - cName := C.CString(name) - defer C.free(unsafe.Pointer(cName)) - cDest := C.CString(dest) - defer C.free(unsafe.Pointer(cDest)) - C.gtk_thumbnail(cName, cDest, C.int(width), C.int(height)) - - // check thumbnail result - _, err = os.Stat(dest) - return err -} diff --git a/gtk-thumbnailer/thumbnail.c b/gtk-thumbnailer/thumbnail.c deleted file mode 100644 index c6fa79a..0000000 --- a/gtk-thumbnailer/thumbnail.c +++ /dev/null @@ -1,94 +0,0 @@ -// SPDX-FileCopyrightText: 2018 - 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - -#include -#include -#include -#include - -void append_page(GtkNotebook * notebook, const char *tab_label) -{ - GtkWidget *tab_header, *label, *close_button, *child; - - tab_header = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5); - child = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); - - label = gtk_label_new(tab_label); - close_button = - gtk_button_new_from_icon_name("window-close-symbolic", - GTK_ICON_SIZE_MENU); - gtk_button_set_relief(GTK_BUTTON(close_button), GTK_RELIEF_NONE); - gtk_box_pack_start(GTK_BOX(tab_header), label, TRUE, TRUE, 0); - gtk_box_pack_end(GTK_BOX(tab_header), close_button, FALSE, FALSE, 0); - - gtk_notebook_append_page(notebook, child, tab_header); - gtk_container_child_set(GTK_CONTAINER(notebook), child, "tab-expand", - TRUE, NULL); - - gtk_widget_show_all(tab_header); -} - -void add_icon_button(GtkHeaderBar * header_bar, const char *icon_name) -{ - GtkWidget *button = - gtk_button_new_from_icon_name(icon_name, GTK_ICON_SIZE_BUTTON); - gtk_header_bar_pack_end(GTK_HEADER_BAR(header_bar), button); -} - -static void capture(GtkOffscreenWindow * w, GdkEvent * ev, gpointer user_data) -{ - char *dest = (char *)user_data; - - GdkWindow *tmp_window = gtk_widget_get_window(GTK_WIDGET(w)); - cairo_surface_t *tmp_surface = - gdk_offscreen_window_get_surface(tmp_window); - if (!tmp_surface) { - g_warning("Get offscreen surface failed"); - return; - } - - cairo_status_t status = cairo_surface_write_to_png(tmp_surface, dest); - g_printf("write png status: %s\n", cairo_status_to_string(status)); - gtk_main_quit(); -} - -void gtk_thumbnail(char *theme_name, char *dest, int width, int min_height) -{ - g_setenv("GTK_THEME", theme_name, TRUE); - - GtkWidget *window; - gboolean initialized = gtk_init_check(NULL, NULL); - if (!initialized) { - return; - } - - window = gtk_offscreen_window_new(); - gtk_window_set_title(GTK_WINDOW(window), "Window"); - gtk_window_set_default_size(GTK_WINDOW(window), width, min_height); - - // header bar - GtkWidget *header = gtk_header_bar_new(); - gtk_header_bar_set_title(GTK_HEADER_BAR(header), NULL); - gtk_header_bar_set_show_close_button(GTK_HEADER_BAR(header), TRUE); - gtk_header_bar_set_has_subtitle(GTK_HEADER_BAR(header), FALSE); - - add_icon_button(GTK_HEADER_BAR(header), "open-menu-symbolic"); - add_icon_button(GTK_HEADER_BAR(header), "system-search-symbolic"); - - // notebook pages - GtkWidget *notebook = gtk_notebook_new(); - append_page(GTK_NOTEBOOK(notebook), "Tab 1"); - append_page(GTK_NOTEBOOK(notebook), "Tab 2"); - - GtkWidget *vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); - gtk_box_pack_start(GTK_BOX(vbox), header, TRUE, TRUE, 0); - gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0); - gtk_container_add(GTK_CONTAINER(window), vbox); - - g_signal_connect(G_OBJECT(window), "damage-event", G_CALLBACK(capture), - dest); - - gtk_widget_show_all(window); - gtk_main(); -}