Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ project('iptux', 'cpp',
meson_version: '>=0.53',
default_options: ['warning_level=3', 'cpp_std=c++14'])
add_global_arguments('-Werror=format', language : 'cpp')
add_project_arguments(
'-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_36',
language: 'cpp')
if get_option('sanitize-address')
add_project_arguments('-fsanitize=address', language: 'cpp')
add_project_link_arguments('-fsanitize=address', language: 'cpp')
Expand Down
3 changes: 3 additions & 0 deletions share/iptux/css/iptux.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.iptux-main {
color: green;
}
7 changes: 3 additions & 4 deletions src/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
#mesondefine GETTEXT_PACKAGE
#define IPTUX_RESOURCE "/io/github/iptux_src/iptux/"

#define __PIXMAPS_PATH "@SHARE_IPTUX_DIR@/pixmaps"
#define __LOCALE_PATH "@SHARE_DIR@/locale"
#define __SOUND_PATH "@SHARE_IPTUX_DIR@/sound"
#define __UI_PATH "@SHARE_IPTUX_DIR@/ui"
#define IPTUX_PIXMAPS_PATH "@SHARE_IPTUX_DIR@/pixmaps"
#define IPTUX_CSS_PATH "@SHARE_IPTUX_DIR@/css"
#define IPTUX_LOCALE_PATH "@SHARE_DIR@/locale"

#define IPTUX_PATH "/iptux"
#define LOG_PATH "/iptux/log"
Expand Down
2 changes: 1 addition & 1 deletion src/iptux-core/internal/UdpData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ string UdpData::GetPalIcon() {
const char* ptr;

if ((ptr = iptux_skip_string(buf, size, 2)) && *ptr != '\0') {
string res = stringFormat(__PIXMAPS_PATH "/icon/%s", ptr);
string res = stringFormat(IPTUX_PIXMAPS_PATH "/icon/%s", ptr);
if (access(res.c_str(), F_OK) == 0)
return ptr;
}
Expand Down
24 changes: 20 additions & 4 deletions src/iptux/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ void iptux_init(LogSystem* logSystem) {

void init_theme(Application* app) {
auto theme = gtk_icon_theme_get_default();
gtk_icon_theme_prepend_search_path(theme, __PIXMAPS_PATH "/icon");
gtk_icon_theme_prepend_search_path(theme, __PIXMAPS_PATH "/menu");
gtk_icon_theme_prepend_search_path(theme, __PIXMAPS_PATH "/tip");
gtk_icon_theme_prepend_search_path(theme, IPTUX_PIXMAPS_PATH "/icon");
gtk_icon_theme_prepend_search_path(theme, IPTUX_PIXMAPS_PATH "/menu");
gtk_icon_theme_prepend_search_path(theme, IPTUX_PIXMAPS_PATH "/tip");
gtk_icon_theme_prepend_search_path(
theme, app->getCoreThread()->getUserIconPath().c_str());
}
Expand Down Expand Up @@ -150,7 +150,7 @@ void Application::onStartup(Application& self) {
gtk_application_set_menubar(GTK_APPLICATION(self.app), self.menu());
}
}

self.LoadCss();
self.window = new MainWindow(&self, *self.cthrd);

GActionEntry app_entries[] = {
Expand Down Expand Up @@ -192,6 +192,22 @@ void Application::onStartup(Application& self) {
#endif
}

void Application::LoadCss() {
auto cssProvider = gtk_css_provider_new();
GError* error = nullptr;
gtk_css_provider_load_from_path(cssProvider, IPTUX_CSS_PATH "/iptux.css",
&error);
if (error) {
LOG_WARN("load css failed: %s", error->message);
g_error_free(error);
return;
}
gtk_style_context_add_provider_for_screen(
gdk_screen_get_default(), GTK_STYLE_PROVIDER(cssProvider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref(cssProvider);
}

void Application::onActivate(Application& self) {
if (self.started) {
return;
Expand Down
1 change: 1 addition & 0 deletions src/iptux/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class Application {
void _ForTestProcessEvents() { ProcessEvents(this); }

private:
void LoadCss();
void onEvent(std::shared_ptr<const Event> event);
void onConfigChanged();
void updateItemToTransTree(const TransFileModel& para);
Expand Down
6 changes: 3 additions & 3 deletions src/iptux/DataSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ void DataSettings::FillIconModel(GtkTreeModel* model) {
char* file;

theme = gtk_icon_theme_get_default();
if ((dir = opendir(__PIXMAPS_PATH "/icon"))) {
if ((dir = opendir(IPTUX_PIXMAPS_PATH "/icon"))) {
while ((dirt = readdir(dir))) {
if (strcmp(dirt->d_name, ".") == 0 || strcmp(dirt->d_name, "..") == 0)
continue;
Expand Down Expand Up @@ -817,7 +817,7 @@ void DataSettings::ObtainPersonalValue() {
gtk_tree_model_get(model, &iter, 1, &file, -1);
if (file) {
if (strcmp(g_progdt->myicon.c_str(), file) != 0) {
snprintf(path, MAX_PATHLEN, __PIXMAPS_PATH "/icon/%s", file);
snprintf(path, MAX_PATHLEN, IPTUX_PIXMAPS_PATH "/icon/%s", file);
if (access(path, F_OK) != 0) {
g_progdt->myicon = "my-icon";
snprintf(path, MAX_PATHLEN, "%s" ICON_PATH "/my-icon",
Expand Down Expand Up @@ -914,7 +914,7 @@ string DataSettings::ObtainSystemValue(bool dryrun) {
gtk_tree_model_get_iter_from_string(model, &iter, path);
gtk_tree_model_get(model, &iter, 1, &file, -1);
if (strcmp(progdt->palicon, file) != 0) {
snprintf(path, MAX_PATHLEN, __PIXMAPS_PATH "/icon/%s", file);
snprintf(path, MAX_PATHLEN, IPTUX_PIXMAPS_PATH "/icon/%s", file);
if (access(path, F_OK) != 0) {
g_free(file);
g_free(progdt->palicon);
Expand Down
4 changes: 2 additions & 2 deletions src/iptux/RevisePal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ void RevisePal::ApplyReviseData() {
gtk_tree_model_get_iter_from_string(model, &iter, path);
gtk_tree_model_get(model, &iter, 1, &file, -1);
if (pal->icon_file() != file) {
snprintf(path, MAX_PATHLEN, __PIXMAPS_PATH "/icon/%s", file);
snprintf(path, MAX_PATHLEN, IPTUX_PIXMAPS_PATH "/icon/%s", file);
if (access(path, F_OK) != 0) {
g_free(file);
snprintf(path, MAX_PATHLEN, "%s" ICON_PATH "/%" PRIx32,
Expand Down Expand Up @@ -318,7 +318,7 @@ void RevisePal::FillIconModel(GtkTreeModel* model) {
char* file;

theme = gtk_icon_theme_get_default();
if ((dir = opendir(__PIXMAPS_PATH "/icon"))) {
if ((dir = opendir(IPTUX_PIXMAPS_PATH "/icon"))) {
while ((dirt = readdir(dir))) {
if (strcmp(dirt->d_name, ".") == 0 || strcmp(dirt->d_name, "..") == 0)
continue;
Expand Down
4 changes: 2 additions & 2 deletions src/iptux/UiCoreThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ void UiCoreThread::CheckIconTheme() {
char pathbuf[MAX_PATHLEN];
GdkPixbuf* pixbuf;

snprintf(pathbuf, MAX_PATHLEN, __PIXMAPS_PATH "/icon/%s",
snprintf(pathbuf, MAX_PATHLEN, IPTUX_PIXMAPS_PATH "/icon/%s",
programData->myicon.c_str());
if (access(pathbuf, F_OK) != 0) {
snprintf(pathbuf, MAX_PATHLEN, "%s" ICON_PATH "/%s",
Expand All @@ -561,7 +561,7 @@ void UiCoreThread::CheckIconTheme() {
}
}

snprintf(pathbuf, MAX_PATHLEN, __PIXMAPS_PATH "/icon/%s",
snprintf(pathbuf, MAX_PATHLEN, IPTUX_PIXMAPS_PATH "/icon/%s",
programData->palicon);
if (access(pathbuf, F_OK) != 0) {
snprintf(pathbuf, MAX_PATHLEN, "%s" ICON_PATH "/%s",
Expand Down
2 changes: 1 addition & 1 deletion src/main/iptux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ static void dealLog(const IptuxConfig& config) {
int main(int argc, char** argv) {
installCrashHandler();
setlocale(LC_ALL, "");
bindtextdomain(GETTEXT_PACKAGE, __LOCALE_PATH);
bindtextdomain(GETTEXT_PACKAGE, IPTUX_LOCALE_PATH);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
textdomain(GETTEXT_PACKAGE);

Expand Down