永久更改 GTK 颜色选择器中的调色板
当使用颜色选择器小部件 GTK 应用程序时,我经常使用与默认给定的调色板不同的调色板,如下图所示。当程序运行时,我可以更改默认颜色并且它们保持更改状态,但是,当我关闭程序时,这些修改就会消失。
我想知道如何将这些修改永久保存在磁盘中。
When using the color picker widget GTK applications I often use a different color Palette to the one given by default, as shown in the picture below. While the program is running I can change the defaults colors and they stay changed, however, when I close the program those modifications disappear.
I wonder how I can make those modifications to persistent in disk.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从您选择的标签来看,应用程序名称似乎是 Dia。在应用程序中,没有任何东西可以让您设置此选项。所以简短的回答是:不。
问题是 Dia 使用现已弃用的
GtkColorSelectionDialog
(转而使用GtkColorChooserDialog
)。在已弃用的版本中,有一个标志告诉小部件显示/隐藏调色板,但这几乎是您拥有的唯一控件(请参阅gtk_color_selection_set_has_palette
)。在新的小部件版本中(顺便说一下,它看起来完全不同),您可以直接访问
gtk_color_chooser_add_palette
:您可以看到,就自定义调色板而言,您有更多选项。您甚至可以决定颜色。这意味着您可以将当前选择保存在调色板中。然后,在应用程序退出时,您可以将所有调色板的颜色保存在某种设置中,并在应用程序启动时加载它们。
最后一点,我查看了 Dia 源代码,发现他们似乎正在寻求迁移到新的小部件。这是摘录:
来自评论代码,看来他们正试图采取行动......
From the tags you chose, the application name seems to be Dia. In the application, nothing lets you set this option. So the short answer is: no.
The issue is that Dia uses the now deprecated
GtkColorSelectionDialog
(in favor ofGtkColorChooserDialog
). In the deprecated version, there is a flag to tell the widget to show/hide the color palette, but that's pretty much the only control you have (seegtk_color_selection_set_has_palette
).In the new widget version (which, by the way, looks totally different), you have direct access to a
gtk_color_chooser_add_palette
:You can see you have much more options as far as customizing the palette is concerned. You even have the ability to decide the colors. This means you could save your current selection in the palette. Then, at application quit, you could save all the palette's colors in some sort of settings, and load them back at application start.
As a final note, I looked at the Dia source code and found that they seem to be looking to make the move to the new widget. Here is an excerpt:
From the commented code, it seems they are trying to make the move...