diff --git a/.gitmodules b/.gitmodules index 83b33286..a84e19ed 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,5 +2,5 @@ path = cmake url = https://github.com/rilian-la-te/cmake-vala.git [submodule "lib/dbusmenu"] - path = lib/dbusmenu + path = dbusmenu url = https://github.com/rilian-la-te/vala-dbusmenu diff --git a/CMakeLists.txt b/CMakeLists.txt index 3053d857..b110c491 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required (VERSION 2.8) -cmake_policy (VERSION 2.8) +cmake_minimum_required (VERSION 3.3) +cmake_policy (VERSION 3.3) project (vala-panel C) enable_testing () include(GNUInstallDirs) @@ -72,7 +72,7 @@ endif(RPMTools_FOUND) add_custom_target (dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source) # Configuration -configure_file (${CMAKE_SOURCE_DIR}/lib/config.h.in ${CMAKE_BINARY_DIR}/lib/config.h) +configure_file (${CMAKE_SOURCE_DIR}/util/config.h.in ${CMAKE_BINARY_DIR}/config.h) configure_file (${CMAKE_SOURCE_DIR}/${APPNAME}.pc.cmake ${CMAKE_BINARY_DIR}/${APPNAME}.pc) # Some definitions @@ -86,46 +86,29 @@ include (ValaPrecompile) add_definitions(-DVALA_VERSION="${VALA_SHORTVER}") #add_definitions(-w) #Suppress all GCC warnings -add_definitions(-Wall -Wno-unused # Vala loves to create variables -# -pedantic - -Wno-ignored-qualifiers - -Wno-incompatible-pointer-types - -Wno-missing-field-initializers - -Wno-discarded-qualifiers - -Wno-sign-compare - -Wextra - -fstack-protector -fstack-protector-all +add_definitions(-Wall -Wextra + -Wno-unused + -Wno-unused-parameter# Vala loves to create variables + #-pedantic + -Wno-ignored-qualifiers + -Wno-incompatible-pointer-types + -Wno-missing-field-initializers + -Wno-discarded-qualifiers + -Wno-sign-compare ) #Vala often forgot cast to GtkWidget or gpointer find_package (PkgConfig) - -pkg_check_modules (A - gtk+-3.0>=3.22) - -pkg_check_modules (B - glib-2.0>=2.50) - -pkg_check_modules (C - gio-2.0>=2.50 -) +find_package(GLib REQUIRED COMPONENTS goblect gio gmodule gthread VERSION 2.50) +find_package(GTK3 REQUIRED VERSION 3.22) pkg_check_modules (GLIB_OLD QUIET gio-2.0<=2.52 ) -pkg_check_modules (D - gio-unix-2.0>=2.50) - -pkg_check_modules (E - gthread-2.0>=2.50) - -pkg_check_modules (F +pkg_check_modules (PEAS libpeas-1.0>=1.14) -pkg_check_modules (G - libpeas-gtk-1.0>=1.14) - -pkg_check_modules (H - gmodule-2.0>=2.50) +set(CORE_LIBRARIES ${GLIB_LIBRARIES} ${GLIB_GIO_LIBRARIES} ${GLIB_GOBJECT_LIBRARIES} ${GLIB_GMODULE_LIBRARIES} ${GLIB_GTHREAD_LIBRARIES} ${GTK3_LIBRARIES} ${PEAS_LIBRARIES}) +set(CORE_INCLUDE_DIRS ${GLIB_INCLUDE_DIRS} ${GTK_INCLUDE_DIRS} ${PEAS_INCLUDE_DIRS}) pkg_check_modules (CORE REQUIRED QUIET gtk+-3.0>=3.22 @@ -164,8 +147,10 @@ include_directories(${CMAKE_BINARY_DIR}/lib) set(TARGET_GLIB ${GLIB_VERSION_MAJOR}.${GLIB_VERSION_MINOR}) ADD_SUBDIRECTORY(po) -ADD_SUBDIRECTORY(lib) -ADD_SUBDIRECTORY(app) +ADD_SUBDIRECTORY(util) ADD_SUBDIRECTORY(runner) +add_subdirectory(dbusmenu) +ADD_SUBDIRECTORY(ui) +ADD_SUBDIRECTORY(app) ADD_SUBDIRECTORY(applets) ADD_SUBDIRECTORY(data) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index ccde3430..d0c739d0 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -15,6 +15,12 @@ set(APP_SOURCES application.c application.h) add_executable(${APPNAME} ${APP_SOURCES} ) target_link_libraries (${APPNAME} ${LIBNAME} ${CORE_LIBRARIES}) -target_include_directories(${APPNAME} PRIVATE ${CORE_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/lib/c-lib ${CMAKE_SOURCE_DIR}/lib ${CMAKE_BINARY_DIR}/lib) +target_include_directories(${APPNAME} PRIVATE + ${CORE_INCLUDE_DIRS} + ${CMAKE_SOURCE_DIR} + ${CMAKE_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/ui + ${CMAKE_SOURCE_DIR}/util + ${CMAKE_BINARY_DIR}/ui) install (TARGETS ${APPNAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin) diff --git a/app/app-pref.ui b/app/app-pref.ui old mode 100755 new mode 100644 diff --git a/app/application.c b/app/application.c index 46d9322c..f6a40e4e 100644 --- a/app/application.c +++ b/app/application.c @@ -19,11 +19,7 @@ #include "config.h" #include "application.h" -#include "lib/css.h" -#include "lib/definitions.h" -#include "lib/launcher.h" -#include "lib/misc.h" -#include "lib/panel-platform.h" +#include "server.h" #include "vala-panel-compat.h" #include "vala-panel-platform-standalone-x11.h" @@ -466,6 +462,8 @@ static inline void file_chooser_helper(GtkFileChooser *self, ValaPanelApplicatio g_object_set(app, VALA_PANEL_KEY_CSS, file, NULL); } +/* TODO: Move activate_menu to hidden toplevel interface, it is not X11-specific */ + static void activate_menu(GSimpleAction *simple, GVariant *param, gpointer data) { GtkApplication *app = GTK_APPLICATION(data); diff --git a/app/vala-panel-platform-standalone-x11.c b/app/vala-panel-platform-standalone-x11.c index 25696c47..fb91f982 100644 --- a/app/vala-panel-platform-standalone-x11.c +++ b/app/vala-panel-platform-standalone-x11.c @@ -19,11 +19,9 @@ #include "config.h" #include "applet-widget.h" +#include "definitions.h" #include "gio/gsettingsbackend.h" -#include "lib/definitions.h" -#include "lib/settings-manager.h" -//#include "lib/toplevel.h" -#include "vala-panel-compat.h" +#include "server.h" #include "vala-panel-platform-standalone-x11.h" struct _ValaPanelPlatformX11 diff --git a/applets/CMakeLists.txt b/applets/CMakeLists.txt index 91f81daa..62aef8dc 100644 --- a/applets/CMakeLists.txt +++ b/applets/CMakeLists.txt @@ -1,4 +1,4 @@ -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/util ${CMAKE_SOURCE_DIR}/ui ${CMAKE_BINARY_DIR}/ui) add_subdirectory(core) add_subdirectory(drawing) add_subdirectory(wnck) diff --git a/applets/core/menumodel/system-menus.ui b/applets/core/menumodel/system-menus.ui old mode 100755 new mode 100644 diff --git a/applets/wnck/tasklist-xfce/tasklist-widget.c b/applets/wnck/tasklist-xfce/tasklist-widget.c index f499656f..19f7951d 100644 --- a/applets/wnck/tasklist-xfce/tasklist-widget.c +++ b/applets/wnck/tasklist-xfce/tasklist-widget.c @@ -31,10 +31,11 @@ #include #endif -#include "lib/css.h" -#include "lib/definitions.h" -#include "lib/vala-panel-compat.h" +#include "definitions.h" #include "tasklist-widget.h" +#include "util-gtk.h" +#include "util.h" +#include "vala-panel-compat.h" #include "xfce-arrow-button.h" #define DEFAULT_BUTTON_SIZE (25) diff --git a/applets/wnck/tasklist-xfce/xfce-arrow-button.c b/applets/wnck/tasklist-xfce/xfce-arrow-button.c index 0cf65a5c..23797711 100644 --- a/applets/wnck/tasklist-xfce/xfce-arrow-button.c +++ b/applets/wnck/tasklist-xfce/xfce-arrow-button.c @@ -24,7 +24,8 @@ #include -#include "lib/css.h" +#include "util-gtk.h" +#include "util.h" #include "xfce-arrow-button.h" /** diff --git a/cmake b/cmake index 96bc8d9e..ed527e48 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit 96bc8d9ea16ca0ee7ac35c950ac84f61c848f047 +Subproject commit ed527e4836ace92e454404613396ae581255c6d4 diff --git a/data/gschemas/org.valapanel.gschema.xml b/data/gschemas/org.valapanel.gschema.xml old mode 100755 new mode 100644 diff --git a/data/gschemas/org.valapanel.toplevel.gschema.xml b/data/gschemas/org.valapanel.toplevel.gschema.xml old mode 100755 new mode 100644 diff --git a/data/ui/panel-menus.ui b/data/ui/panel-menus.ui old mode 100755 new mode 100644 diff --git a/data/ui/pref.ui b/data/ui/pref.ui old mode 100755 new mode 100644 diff --git a/dbusmenu b/dbusmenu new file mode 160000 index 00000000..a5562801 --- /dev/null +++ b/dbusmenu @@ -0,0 +1 @@ +Subproject commit a5562801b66aa9f8f67eafc55b486fd0d1602987 diff --git a/lib/dbusmenu b/lib/dbusmenu deleted file mode 160000 index 07917250..00000000 --- a/lib/dbusmenu +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 07917250b59a1ddb1169bdccdf0e33266026827b diff --git a/runner/CMakeLists.txt b/runner/CMakeLists.txt index 8eeb679e..f71628b6 100644 --- a/runner/CMakeLists.txt +++ b/runner/CMakeLists.txt @@ -2,12 +2,8 @@ INCLUDE(GResource) set(RUNNER_SOURCES runner.c runner.h - info-data.c - info-data.h - boxed-wrapper.c - boxed-wrapper.h - glistmodel-filter.c - glistmodel-filter.h + runner-app.c + runner-app.h ) add_definitions(-DG_SETTINGS_ENABLE_BACKEND) glib_compile_resources(GLIB_RESOURCES_APP @@ -20,11 +16,9 @@ glib_compile_resources(GLIB_RESOURCES_APP ##### add_executable(${APPNAME}-runner ${GLIB_RESOURCES_APP} - ${RUNNER_SOURCES} - runner-app.c - runner-app.h - ${CMAKE_SOURCE_DIR}/lib/css.c - ${CMAKE_SOURCE_DIR}/lib/launcher.c) -target_link_libraries (${APPNAME}-runner ${CORE_LIBRARIES} m) -target_include_directories(${APPNAME}-runner PRIVATE ${CORE_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) + ${RUNNER_SOURCES}) +add_dependencies(${APPNAME}-runner util-gtk) +target_link_libraries(${APPNAME}-runner util-gtk) +target_link_libraries (${APPNAME}-runner ${GTK3_LIBRARIES} ${GLIB_LIBRARIES} ${GLIB_GIO_LIBRARIES} ${GLIB_GOBJECT_LIBRARIES} ${GLIB_GMODULE_LIBRARIES} ${GLIB_GTHREAD_LIBRARIES} m) +target_include_directories(${APPNAME}-runner PRIVATE ${CORE_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/util ${CMAKE_BINARY_DIR}) install (TARGETS ${APPNAME}-runner RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin) diff --git a/runner/runner-app.c b/runner/runner-app.c index 1beaa615..0dd9ad97 100644 --- a/runner/runner-app.c +++ b/runner/runner-app.c @@ -17,11 +17,9 @@ */ #include "runner-app.h" -#include "lib/config.h" -#include "lib/definitions.h" +#include "config.h" #include "runner.h" -#include - +#include "util.h" #include struct _ValaPanelRunApplication @@ -52,7 +50,7 @@ static void vala_panel_run_application_activate(GApplication *application) static void vala_panel_run_application_finalize(GObject *app) { - gtk_widget_destroy0(VALA_PANEL_RUN_APPLICATION(app)->run_dialog); + g_clear_pointer(&VALA_PANEL_RUN_APPLICATION(app)->run_dialog, gtk_widget_destroy); (*G_OBJECT_CLASS(vala_panel_run_application_parent_class)->finalize)(app); } static void vala_panel_run_application_init(ValaPanelRunApplication *self) diff --git a/runner/runner.c b/runner/runner.c index 784baf15..6a2d33a5 100644 --- a/runner/runner.c +++ b/runner/runner.c @@ -16,17 +16,15 @@ * along with this program. If not, see . */ -#include "runner.h" -#include "boxed-wrapper.h" -#include "glistmodel-filter.h" -#include "info-data.h" -#include "lib/css.h" -#include "lib/definitions.h" -#include "lib/launcher.h" #include #include #include +#include "config.h" + +#include "runner.h" +#include "util-gtk.h" + #define MAX_SEARCH_RESULTS 30 struct _ValaPanelRunner @@ -122,7 +120,7 @@ static void vala_panel_runner_response(GtkDialog *dlg, gint response) launch = false; if (!launch) { - g_object_unref0(app_info); + g_clear_pointer(&app_info, g_object_unref); g_autoptr(GError) err = NULL; app_info = g_app_info_create_from_commandline( gtk_entry_get_text(GTK_ENTRY(self->main_entry)), @@ -331,14 +329,14 @@ static void vala_panel_runner_destroy(GtkWidget *obj) G_TYPE_CHECK_INSTANCE_CAST(obj, vala_panel_runner_get_type(), ValaPanelRunner); gtk_window_set_application((GtkWindow *)self, NULL); g_cancellable_cancel(self->cancellable); - g_object_unref0(self->cancellable); - g_object_unref0(self->task); - gtk_widget_destroy0(self->main_entry); - gtk_widget_destroy0(self->bottom_revealer); - gtk_widget_destroy0(self->app_box); - gtk_widget_destroy0(self->terminal_button); - g_object_unref0(self->model); - g_object_unref0(self->filter); + g_clear_pointer(&self->cancellable, g_object_unref); + g_clear_pointer(&self->task, g_object_unref); + g_clear_pointer(&self->main_entry, gtk_widget_destroy); + g_clear_pointer(&self->bottom_revealer, gtk_widget_destroy); + g_clear_pointer(&self->app_box, gtk_widget_destroy); + g_clear_pointer(&self->terminal_button, gtk_widget_destroy); + g_clear_pointer(&self->model, g_object_unref); + g_clear_pointer(&self->filter, g_object_unref); GTK_WIDGET_CLASS(vala_panel_runner_parent_class)->destroy(obj); } diff --git a/lib/CMakeLists.txt b/ui/CMakeLists.txt similarity index 88% rename from lib/CMakeLists.txt rename to ui/CMakeLists.txt index 3c753225..45751a3b 100644 --- a/lib/CMakeLists.txt +++ b/ui/CMakeLists.txt @@ -1,6 +1,5 @@ add_subdirectory(applets-new) add_subdirectory(c-lib) -add_subdirectory(dbusmenu) include(GLibHelpers) set(ENUM_FILES panel-platform.h @@ -13,14 +12,12 @@ if (ENABLE_NEW_INTERFACE) set(NEW_DEFINE -D NEW) endif() set(LIBVALAPANEL_HEADERS + client.h + server.h applet-widget-api.h applet-widget.h - ${CMAKE_CURRENT_BINARY_DIR}/config.h - constants.h - misc.h + misc-gtk.h menu-maker.h - css.h - launcher.h generic-config-dialog.h settings-manager.h panel-platform.h @@ -28,11 +25,9 @@ set(LIBVALAPANEL_HEADERS toplevel-config.h ${ENUMSH}) set(LIBVALAPANEL_C_SOURCES - misc.c + misc-gtk.c menu-maker.c - css.c toplevel-config.c - launcher.c generic-config-dialog.c settings-manager.c panel-platform.c @@ -40,11 +35,6 @@ set(LIBVALAPANEL_C_SOURCES toplevel.c ${ENUMSC}) INCLUDE(GResource) -if(GLIB_OLD_FOUND) - list(APPEND LIBVALAPANEL_C_SOURCES - guuid.c - guuid.h) -endif() set(VALA_FILES configurator.vala applet-holder.vala @@ -79,7 +69,7 @@ glib_compile_resources(GLIB_RESOURCES_LIB # Build library for plugins and application set (LIBS ${CORE_LIBRARIES} -lm) set (LIB_PATHS ${CORE_LIBRARY_DIRS}) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/util; ${CMAKE_SOURCE_DIR}/ui) link_directories (${LIB_PATHS}) set (LIB_FILES ${VALA_C}) @@ -93,7 +83,7 @@ add_library (${LIBNAME} SHARED definitions.h ) -target_link_libraries (${LIBNAME} ${LIBS}) +target_link_libraries (${LIBNAME} ${LIBS} util util-gtk) target_include_directories(${LIBNAME} PRIVATE ${CORE_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) set_target_properties (${LIBNAME} PROPERTIES diff --git a/lib/applet-holder.vala b/ui/applet-holder.vala similarity index 100% rename from lib/applet-holder.vala rename to ui/applet-holder.vala diff --git a/lib/applet-widget-api.h b/ui/applet-widget-api.h similarity index 100% rename from lib/applet-widget-api.h rename to ui/applet-widget-api.h diff --git a/lib/applet-widget.c b/ui/applet-widget.c similarity index 100% rename from lib/applet-widget.c rename to ui/applet-widget.c diff --git a/lib/applet-widget.h b/ui/applet-widget.h similarity index 100% rename from lib/applet-widget.h rename to ui/applet-widget.h diff --git a/lib/applets-new/CMakeLists.txt b/ui/applets-new/CMakeLists.txt similarity index 87% rename from lib/applets-new/CMakeLists.txt rename to ui/applets-new/CMakeLists.txt index 43a442fa..8a5ea842 100644 --- a/lib/applets-new/CMakeLists.txt +++ b/ui/applets-new/CMakeLists.txt @@ -14,7 +14,7 @@ set (LIBS ${CORE_LIBRARIES} -lm) set (LIB_PATHS ${CORE_LIBRARY_DIRS}) link_directories (${LIB_PATHS}) target_link_libraries (applet-api-new ${LIBS}) -target_include_directories(applet-api-new PRIVATE ${CORE_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/lib) +target_include_directories(applet-api-new PRIVATE ${CORE_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/ui) set_target_properties (applet-api-new PROPERTIES VERSION ${VERSION} SOVERSION ${SOVERSION}) diff --git a/lib/applets-new/applet-api-marshal.list b/ui/applets-new/applet-api-marshal.list similarity index 100% rename from lib/applets-new/applet-api-marshal.list rename to ui/applets-new/applet-api-marshal.list diff --git a/lib/applets-new/applet-api.h b/ui/applets-new/applet-api.h similarity index 100% rename from lib/applets-new/applet-api.h rename to ui/applets-new/applet-api.h diff --git a/lib/applets-new/applet-engine.c b/ui/applets-new/applet-engine.c similarity index 100% rename from lib/applets-new/applet-engine.c rename to ui/applets-new/applet-engine.c diff --git a/lib/applets-new/applet-engine.h b/ui/applets-new/applet-engine.h similarity index 100% rename from lib/applets-new/applet-engine.h rename to ui/applets-new/applet-engine.h diff --git a/lib/applets-new/applet-info.c b/ui/applets-new/applet-info.c similarity index 99% rename from lib/applets-new/applet-info.c rename to ui/applets-new/applet-info.c index 58b613fe..28398ffc 100644 --- a/lib/applets-new/applet-info.c +++ b/ui/applets-new/applet-info.c @@ -1,5 +1,5 @@ #include "applet-info.h" -#include "lib/definitions.h" +#include "definitions.h" #define G_SETTINGS_ENABLE_BACKEND #include diff --git a/lib/applets-new/applet-info.h b/ui/applets-new/applet-info.h similarity index 100% rename from lib/applets-new/applet-info.h rename to ui/applets-new/applet-info.h diff --git a/lib/applets-new/vala-applet-enums.c.template b/ui/applets-new/vala-applet-enums.c.template similarity index 100% rename from lib/applets-new/vala-applet-enums.c.template rename to ui/applets-new/vala-applet-enums.c.template diff --git a/lib/applets-new/vala-applet-enums.h.template b/ui/applets-new/vala-applet-enums.h.template similarity index 100% rename from lib/applets-new/vala-applet-enums.h.template rename to ui/applets-new/vala-applet-enums.h.template diff --git a/lib/c-lib/CMakeLists.txt b/ui/c-lib/CMakeLists.txt similarity index 68% rename from lib/c-lib/CMakeLists.txt rename to ui/c-lib/CMakeLists.txt index 1d676a9b..2ee8d47d 100644 --- a/lib/c-lib/CMakeLists.txt +++ b/ui/c-lib/CMakeLists.txt @@ -6,21 +6,24 @@ set(ENUM_FILES include(GLibHelpers) add_glib_enumtypes(ENUMSC ENUMSH vala-panel-enums ${ENUM_FILES}) add_library(cvalapanel SHARED - panel-layout.h panel-layout.c applet-manager.c applet-engine-module.c - private.h -# conf-gsettings.c -# conf-gsettings.h - - ) + private.h) set (LIBS ${CORE_LIBRARIES} -lm) set (LIB_PATHS ${CORE_LIBRARY_DIRS}) link_directories (${LIB_PATHS}) target_link_libraries (cvalapanel ${LIBS} ${LIBNAME}) -target_include_directories(cvalapanel PRIVATE ${CORE_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/lib) +target_include_directories(cvalapanel PRIVATE + ${CORE_INCLUDE_DIRS} + ${CMAKE_SOURCE_DIR} + ${CMAKE_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/ui + ${CMAKE_SOURCE_DIR}/util + ${CMAKE_SOURCE_DIR}/ui/applets-new) set_target_properties (cvalapanel PROPERTIES VERSION ${VERSION} SOVERSION ${SOVERSION}) diff --git a/lib/c-lib/applet-engine-module.c b/ui/c-lib/applet-engine-module.c similarity index 99% rename from lib/c-lib/applet-engine-module.c rename to ui/c-lib/applet-engine-module.c index e2ca1252..4f4a6d85 100644 --- a/lib/c-lib/applet-engine-module.c +++ b/ui/c-lib/applet-engine-module.c @@ -1,4 +1,6 @@ #include "applet-engine-module.h" +#include "config.h" +#include "util.h" #include struct _ValaPanelAppletEngineIfaceModule diff --git a/lib/c-lib/applet-engine-module.h b/ui/c-lib/applet-engine-module.h similarity index 90% rename from lib/c-lib/applet-engine-module.h rename to ui/c-lib/applet-engine-module.h index 63b430e6..c3369154 100644 --- a/lib/c-lib/applet-engine-module.h +++ b/ui/c-lib/applet-engine-module.h @@ -1,9 +1,8 @@ #ifndef APPLETENGINEMODULE_H #define APPLETENGINEMODULE_H -#include "lib/applets-new/applet-api.h" -#include "lib/config.h" -#include "lib/definitions.h" +#include "applet-api.h" +#include "definitions.h" #include #include diff --git a/lib/c-lib/applet-manager.c b/ui/c-lib/applet-manager.c similarity index 97% rename from lib/c-lib/applet-manager.c rename to ui/c-lib/applet-manager.c index 99ba0b7c..f166b68e 100644 --- a/lib/c-lib/applet-manager.c +++ b/ui/c-lib/applet-manager.c @@ -1,7 +1,7 @@ #include "applet-manager.h" +#include "applet-api.h" #include "applet-engine-module.h" -#include "lib/applets-new/applet-api.h" -#include "lib/definitions.h" +#include "definitions.h" #include "private.h" #define PLUGIN_SETTINGS_SCHEMA_BASE "org.valapanel.toplevel.%s" diff --git a/lib/c-lib/applet-manager.h b/ui/c-lib/applet-manager.h similarity index 91% rename from lib/c-lib/applet-manager.h rename to ui/c-lib/applet-manager.h index 72a159ea..29439bb3 100644 --- a/lib/c-lib/applet-manager.h +++ b/ui/c-lib/applet-manager.h @@ -1,11 +1,11 @@ #ifndef APPLETMANAGER_C #define APPLETMANAGER_C -#include "lib/config.h" +#include "config.h" +#include "applet-api.h" #include "applet-engine-module.h" -#include "lib/applets-new/applet-api.h" -#include "lib/panel-platform.h" +#include "panel-platform.h" #include G_BEGIN_DECLS diff --git a/lib/c-lib/panel-layout.c b/ui/c-lib/panel-layout.c similarity index 99% rename from lib/c-lib/panel-layout.c rename to ui/c-lib/panel-layout.c index 4be2285f..6febb54a 100644 --- a/lib/c-lib/panel-layout.c +++ b/ui/c-lib/panel-layout.c @@ -1,6 +1,6 @@ #include "panel-layout.h" -#include "lib/applets-new/applet-api.h" -#include "lib/settings-manager.h" +#include "applet-api.h" +#include "settings-manager.h" struct _ValaPanelAppletLayout { diff --git a/lib/c-lib/panel-layout.h b/ui/c-lib/panel-layout.h similarity index 98% rename from lib/c-lib/panel-layout.h rename to ui/c-lib/panel-layout.h index a8ee3109..eb6f6716 100644 --- a/lib/c-lib/panel-layout.h +++ b/ui/c-lib/panel-layout.h @@ -6,7 +6,7 @@ #include #include "applet-manager.h" -#include "lib/misc.h" +#include "util.h" G_BEGIN_DECLS diff --git a/lib/c-lib/private.h b/ui/c-lib/private.h similarity index 94% rename from lib/c-lib/private.h rename to ui/c-lib/private.h index 4b32899a..38344b75 100644 --- a/lib/c-lib/private.h +++ b/ui/c-lib/private.h @@ -1,6 +1,6 @@ #ifndef APPLETSPRIVATE_H #define APPLETSPRIVATE_H -#include "lib/applets-new/applet-api.h" +#include "applet-api.h" GSList *vala_panel_applet_engine_iface_get_available_types(ValaPanelAppletEngineIface *self); ValaPanelAppletInfo *vala_panel_applet_engine_iface_get_applet_info_for_type( diff --git a/ui/client.h b/ui/client.h new file mode 100644 index 00000000..33615ca7 --- /dev/null +++ b/ui/client.h @@ -0,0 +1,35 @@ +/* + * vala-panel + * Copyright (C) 2015-2018 Konstantin Pugin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +#ifndef CLIENT_H +#define CLIENT_H + +#include + +G_BEGIN_DECLS + +#include +#include +#include +#include +#include +#include + +G_END_DECLS + +#endif diff --git a/lib/configurator.vala b/ui/configurator.vala similarity index 100% rename from lib/configurator.vala rename to ui/configurator.vala diff --git a/lib/definitions.h b/ui/definitions.h similarity index 100% rename from lib/definitions.h rename to ui/definitions.h diff --git a/lib/generic-config-dialog.c b/ui/generic-config-dialog.c similarity index 99% rename from lib/generic-config-dialog.c rename to ui/generic-config-dialog.c index 43c23107..8f1bdf61 100644 --- a/lib/generic-config-dialog.c +++ b/ui/generic-config-dialog.c @@ -20,8 +20,7 @@ #include #include "generic-config-dialog.h" -#include "lib/applets-new/applet-api.h" -#include "lib/misc.h" +#include "misc-gtk.h" typedef struct { diff --git a/lib/generic-config-dialog.h b/ui/generic-config-dialog.h similarity index 100% rename from lib/generic-config-dialog.h rename to ui/generic-config-dialog.h diff --git a/lib/libvalapanel.gresource.xml b/ui/libvalapanel.gresource.xml similarity index 100% rename from lib/libvalapanel.gresource.xml rename to ui/libvalapanel.gresource.xml diff --git a/lib/menu-maker.c b/ui/menu-maker.c similarity index 100% rename from lib/menu-maker.c rename to ui/menu-maker.c diff --git a/lib/menu-maker.h b/ui/menu-maker.h similarity index 100% rename from lib/menu-maker.h rename to ui/menu-maker.h diff --git a/lib/misc.c b/ui/misc-gtk.c similarity index 84% rename from lib/misc.c rename to ui/misc-gtk.c index 57fb28c3..d3a8e5ad 100644 --- a/lib/misc.c +++ b/ui/misc-gtk.c @@ -22,6 +22,7 @@ #include "css.h" #include "definitions.h" +#include "misc-gtk.h" #include "misc.h" #include "toplevel.h" @@ -130,19 +131,6 @@ void vala_panel_scale_button_set_value_labeled(GtkScaleButton *b, gint value) gtk_button_set_label(GTK_BUTTON(b), str); } -void vala_panel_add_prop_as_action(GActionMap *map, const char *prop) -{ - g_autoptr(GAction) action = G_ACTION(g_property_action_new(prop, map, prop)); - g_action_map_add_action(map, action); -} - -void vala_panel_add_gsettings_as_action(GActionMap *map, GSettings *settings, const char *prop) -{ - vala_panel_bind_gsettings(map, settings, prop); - g_autoptr(GAction) action = G_ACTION(g_settings_create_action(settings, prop)); - g_action_map_add_action(map, action); -} - int vala_panel_monitor_num_from_mon(GdkDisplay *disp, GdkMonitor *mon) { int mons = gdk_display_get_n_monitors(disp); @@ -154,29 +142,6 @@ int vala_panel_monitor_num_from_mon(GdkDisplay *disp, GdkMonitor *mon) return -1; } -void vala_panel_reset_schema(GSettings *settings) -{ - g_autoptr(GSettingsSchema) schema = NULL; - g_object_get(settings, "settings-schema", &schema, NULL); - g_auto(GStrv) keys = g_settings_schema_list_keys(schema); - for (int i = 0; keys[i]; i++) - g_settings_reset(settings, keys[i]); -} - -void vala_panel_reset_schema_with_children(GSettings *settings) -{ - g_settings_delay(settings); - vala_panel_reset_schema(settings); - g_auto(GStrv) children = g_settings_list_children(settings); - for (int i = 0; children[i]; i++) - { - g_autoptr(GSettings) child = g_settings_get_child(settings, children[i]); - vala_panel_reset_schema(child); - } - g_settings_apply(settings); - g_settings_sync(); -} - void vala_panel_generate_error_dialog(GtkWindow *parent, const char *error) { GtkMessageDialog *dlg; diff --git a/lib/misc.h b/ui/misc-gtk.h similarity index 84% rename from lib/misc.h rename to ui/misc-gtk.h index 032937fe..b9ec4d5a 100644 --- a/lib/misc.h +++ b/ui/misc-gtk.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef MISC_H -#define MISC_H +#ifndef MISC_GTK_H +#define MISC_GTK_H #include #include @@ -34,12 +34,8 @@ void vala_panel_setup_icon_button(GtkButton *btn, GIcon *icon, const char *label ValaPanelToplevel *top); void vala_panel_scale_button_set_range(GtkScaleButton *b, gint lower, gint upper); void vala_panel_scale_button_set_value_labeled(GtkScaleButton *b, gint value); -void vala_panel_add_prop_as_action(GActionMap *map, const char *prop); -void vala_panel_add_gsettings_as_action(GActionMap *map, GSettings *settings, const char *prop); void vala_panel_apply_window_icon(GtkWindow *win); int vala_panel_monitor_num_from_mon(GdkDisplay *disp, GdkMonitor *mon); -void vala_panel_reset_schema(GSettings *settings); -void vala_panel_reset_schema_with_children(GSettings *settings); void vala_panel_generate_error_dialog(GtkWindow *parent, const char *error); bool vala_panel_generate_confirmation_dialog(GtkWindow *parent, const char *error); G_END_DECLS diff --git a/lib/panel-layout.vala b/ui/panel-layout.vala similarity index 100% rename from lib/panel-layout.vala rename to ui/panel-layout.vala diff --git a/lib/panel-platform.c b/ui/panel-platform.c similarity index 100% rename from lib/panel-platform.c rename to ui/panel-platform.c diff --git a/lib/panel-platform.h b/ui/panel-platform.h similarity index 100% rename from lib/panel-platform.h rename to ui/panel-platform.h diff --git a/lib/pref.ui b/ui/pref.ui old mode 100755 new mode 100644 similarity index 100% rename from lib/pref.ui rename to ui/pref.ui diff --git a/ui/server.h b/ui/server.h new file mode 100644 index 00000000..cff7e30a --- /dev/null +++ b/ui/server.h @@ -0,0 +1,35 @@ +/* + * vala-panel + * Copyright (C) 2015-2018 Konstantin Pugin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +#ifndef SERVER_H +#define SERVER_H + +#include + +G_BEGIN_DECLS + +#include +#include +#include +#include +#include +#include + +G_END_DECLS + +#endif diff --git a/lib/settings-manager.c b/ui/settings-manager.c similarity index 100% rename from lib/settings-manager.c rename to ui/settings-manager.c diff --git a/lib/settings-manager.h b/ui/settings-manager.h similarity index 100% rename from lib/settings-manager.h rename to ui/settings-manager.h diff --git a/lib/toplevel-config.c b/ui/toplevel-config.c similarity index 99% rename from lib/toplevel-config.c rename to ui/toplevel-config.c index ef1023b2..b0388f06 100644 --- a/lib/toplevel-config.c +++ b/ui/toplevel-config.c @@ -18,6 +18,7 @@ #include "toplevel-config.h" #include "definitions.h" +#include "misc-gtk.h" #include "misc.h" #include "toplevel.h" diff --git a/lib/toplevel-config.h b/ui/toplevel-config.h similarity index 100% rename from lib/toplevel-config.h rename to ui/toplevel-config.h diff --git a/lib/toplevel.c b/ui/toplevel.c similarity index 99% rename from lib/toplevel.c rename to ui/toplevel.c index 6746a9d7..bbf1d19e 100644 --- a/lib/toplevel.c +++ b/ui/toplevel.c @@ -17,9 +17,9 @@ */ #include "toplevel.h" -#include "css.h" #include "definitions.h" -#include "misc.h" +#include "misc-gtk.h" +#include "util-gtk.h" #include "vala-panel-enums.h" #include "vala-panel-compat.h" diff --git a/lib/toplevel.h b/ui/toplevel.h similarity index 100% rename from lib/toplevel.h rename to ui/toplevel.h diff --git a/lib/vala-panel-enums.c.template b/ui/vala-panel-enums.c.template similarity index 100% rename from lib/vala-panel-enums.c.template rename to ui/vala-panel-enums.c.template diff --git a/lib/vala-panel-enums.h.template b/ui/vala-panel-enums.h.template similarity index 100% rename from lib/vala-panel-enums.h.template rename to ui/vala-panel-enums.h.template diff --git a/lib/vala-panel.deps b/ui/vala-panel.deps similarity index 100% rename from lib/vala-panel.deps rename to ui/vala-panel.deps diff --git a/lib/vala-panel.vapi b/ui/vala-panel.vapi similarity index 97% rename from lib/vala-panel.vapi rename to ui/vala-panel.vapi index da911ed3..e8edec8d 100644 --- a/lib/vala-panel.vapi +++ b/ui/vala-panel.vapi @@ -151,13 +151,13 @@ namespace ValaPanel { [NoAccessorMethod] public int width { get; internal set; } } - [CCode (cheader_filename = "misc.h")] + [CCode (cheader_filename = "misc-gtk.h")] public static void setup_icon (Gtk.Image img, GLib.Icon icon, ValaPanel.Toplevel? top = null, int size = -1); - [CCode (cheader_filename = "misc.h")] + [CCode (cheader_filename = "misc-gtk.h")] public static void setup_icon_button (Gtk.Button btn, GLib.Icon? icon = null, string? label = null, ValaPanel.Toplevel? top = null); - [CCode (cheader_filename="misc.h")] + [CCode (cheader_filename="misc-gtk.h")] public static void apply_window_icon(Window w); - [CCode (cheader_filename="misc.h")] + [CCode (cheader_filename="misc-gtk.h")] public static int monitor_num_from_mon(Gdk.Display display, Gdk.Monitor monitor); [CCode (cheader_filename="misc.h")] public static void reset_schema(GLib.Settings settings); @@ -167,13 +167,13 @@ namespace ValaPanel { public static void settings_as_action(ActionMap map, GLib.Settings settings, string prop); [CCode(cname = "vala_panel_bind_gsettings",cheader_filename="definitions.h")] public static void settings_bind(Object map, GLib.Settings settings, string prop); - [CCode (cheader_filename="misc.h")] + [CCode (cheader_filename="misc-gtk.h")] public static void setup_button(Button b, Image? img = null, string? label = null); - [CCode (cheader_filename="misc.h")] + [CCode (cheader_filename="misc-gtk.h")] public static void setup_label(Label label, string text, bool bold, double factor); - [CCode (cheader_filename="misc.h")] + [CCode (cheader_filename="misc-gtk.h")] public static void scale_button_set_range(ScaleButton b, int lower, int upper); - [CCode (cheader_filename="misc.h")] + [CCode (cheader_filename="misc-gtk.h")] public static void scale_button_set_value_labeled(ScaleButton b, int val); [CCode (cheader_filename="definitions.h")] public static Gtk.Orientation orient_from_gravity(Gravity gravity); diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt new file mode 100644 index 00000000..376a1483 --- /dev/null +++ b/util/CMakeLists.txt @@ -0,0 +1,70 @@ +set(UTIL_HEADERS + boxed-wrapper.h + glistmodel-filter.h + ${CMAKE_BINARY_DIR}/config.h + constants.h + misc.h + info-data.h + launcher.h + util.h + ) +set(UTIL_SOURCES + boxed-wrapper.c + glistmodel-filter.c + misc.c + info-data.c + launcher.c) + +set(UTIL_GTK_HEADERS + css.h + util-gtk.h + launcher-gtk.h + ) + +set(UTIL_GTK_SOURCES + css.c + launcher-gtk.c) + +INCLUDE(GResource) +if(GLIB_OLD_FOUND) + list(APPEND LIBVALAPANEL_C_SOURCES + guuid.c + guuid.h) +endif() +#glib_compile_resources(GLIB_RESOURCES_LIB +# source +# libvalapanel.gresource.xml +#) + +##### +# Core Library +##### + +add_library (util STATIC + ${UTIL_SOURCES} + ${UTIL_HEADERS} + ${GLIB_RESOURCES_LIB} +) + +target_link_libraries (util ${GLIB_LIBRARIES} ${GLIB_GIO_LIBRARIES} ${GLIB_GOBJECT_LIBRARIES} ${GLIB_GMODULE_LIBRARIES} ${GLIB_GTHREAD_LIBRARIES}) +target_include_directories(util PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CORE_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/util) + +set_target_properties (util PROPERTIES + VERSION ${VERSION} + SOVERSION ${SOVERSION}) + +add_library (util-gtk STATIC + ${UTIL_GTK_SOURCES} + ${UTIL_GTK_HEADERS} + ${GLIB_RESOURCES_LIB} +) +add_dependencies(util-gtk util) +target_link_libraries (util-gtk util ${GTK3_LIBRARIES} ${GLIB_LIBRARIES} ${GLIB_GIO_LIBRARIES} ${GLIB_GOBJECT_LIBRARIES} ${GLIB_GMODULE_LIBRARIES} ${GLIB_GTHREAD_LIBRARIES}) +target_include_directories(util-gtk PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CORE_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/util) + +set_target_properties (util-gtk PROPERTIES + VERSION ${VERSION} + SOVERSION ${SOVERSION}) + +install (FILES ${UTIL_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/vala-panel/ COMPONENT dev) + diff --git a/runner/boxed-wrapper.c b/util/boxed-wrapper.c similarity index 100% rename from runner/boxed-wrapper.c rename to util/boxed-wrapper.c diff --git a/runner/boxed-wrapper.h b/util/boxed-wrapper.h similarity index 100% rename from runner/boxed-wrapper.h rename to util/boxed-wrapper.h diff --git a/lib/config.h.in b/util/config.h.in similarity index 100% rename from lib/config.h.in rename to util/config.h.in diff --git a/lib/constants.h b/util/constants.h similarity index 100% rename from lib/constants.h rename to util/constants.h diff --git a/lib/css.c b/util/css.c similarity index 100% rename from lib/css.c rename to util/css.c diff --git a/lib/css.h b/util/css.h similarity index 100% rename from lib/css.h rename to util/css.h diff --git a/runner/glistmodel-filter.c b/util/glistmodel-filter.c similarity index 99% rename from runner/glistmodel-filter.c rename to util/glistmodel-filter.c index 8345f370..d9e95dce 100644 --- a/runner/glistmodel-filter.c +++ b/util/glistmodel-filter.c @@ -18,7 +18,6 @@ #include "glistmodel-filter.h" #include "boxed-wrapper.h" -#include "info-data.h" struct _ValaPanelListModelFilter { diff --git a/runner/glistmodel-filter.h b/util/glistmodel-filter.h similarity index 100% rename from runner/glistmodel-filter.h rename to util/glistmodel-filter.h diff --git a/lib/guuid.c b/util/guuid.c similarity index 100% rename from lib/guuid.c rename to util/guuid.c diff --git a/lib/guuid.h b/util/guuid.h similarity index 100% rename from lib/guuid.h rename to util/guuid.h diff --git a/runner/info-data.c b/util/info-data.c similarity index 99% rename from runner/info-data.c rename to util/info-data.c index 41eb6235..aa4a528a 100644 --- a/runner/info-data.c +++ b/util/info-data.c @@ -16,8 +16,7 @@ * along with this program. If not, see . */ -#include "info-data.h" -#include "boxed-wrapper.h" +#include "util.h" #include #include diff --git a/runner/info-data.h b/util/info-data.h similarity index 100% rename from runner/info-data.h rename to util/info-data.h diff --git a/lib/launcher.c b/util/launcher-gtk.c similarity index 64% rename from lib/launcher.c rename to util/launcher-gtk.c index a21b542e..5cb9bbbc 100644 --- a/lib/launcher.c +++ b/util/launcher-gtk.c @@ -19,17 +19,8 @@ #include #include -#include "launcher.h" - -typedef struct -{ - pid_t pid; -} SpawnData; - -void child_spawn_func(void *data) -{ - setpgid(0, getpgid(getppid())); -} +#include "launcher-gtk.h" +#include "util/launcher.h" bool vala_panel_launch(GDesktopAppInfo *app_info, GList *uris, GtkWidget *parent) { @@ -38,41 +29,6 @@ bool vala_panel_launch(GDesktopAppInfo *app_info, GList *uris, GtkWidget *parent return vala_panel_launch_with_context(app_info, cxt, uris); } -bool vala_panel_launch_with_context(GDesktopAppInfo *app_info, GAppLaunchContext *cxt, GList *uris) -{ - g_autoptr(GError) err = NULL; - bool ret = g_desktop_app_info_launch_uris_as_manager(G_DESKTOP_APP_INFO(app_info), - uris, - cxt, - G_SPAWN_SEARCH_PATH, - child_spawn_func, - NULL, - NULL, - NULL, - &err); - if (err) - g_warning("%s\n", err->message); - return ret; -} - -GAppInfo *vala_panel_get_default_for_uri(const char *uri) -{ - /* g_file_query_default_handler() calls - * g_app_info_get_default_for_uri_scheme() too, but we have to do it - * here anyway in case GFile can't parse @uri correctly. - */ - GAppInfo *app_info = NULL; - g_autofree char *uri_scheme = g_uri_parse_scheme(uri); - if (uri_scheme != NULL && strlen(uri_scheme) <= 0) - app_info = g_app_info_get_default_for_uri_scheme(uri_scheme); - if (app_info == NULL) - { - g_autoptr(GFile) file = g_file_new_for_uri(uri); - app_info = g_file_query_default_handler(file, NULL, NULL); - } - return app_info; -} - void activate_menu_launch_id(GSimpleAction *action, GVariant *param, gpointer user_data) { const gchar *id = g_variant_get_string(param, NULL); diff --git a/lib/launcher.h b/util/launcher-gtk.h similarity index 84% rename from lib/launcher.h rename to util/launcher-gtk.h index ff2c5074..54bbed74 100644 --- a/lib/launcher.h +++ b/util/launcher-gtk.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef LAUNCHER_H -#define LAUNCHER_H +#ifndef LAUNCHER_GTK_H +#define LAUNCHER_GTK_H #include #include @@ -25,9 +25,6 @@ #include bool vala_panel_launch(GDesktopAppInfo *app_info, GList *uris, GtkWidget *parent); -bool vala_panel_launch_with_context(GDesktopAppInfo *app_info, GAppLaunchContext *cxt, GList *uris); -GAppInfo *vala_panel_get_default_for_uri(const char *uri); -void child_spawn_func(void *data); void activate_menu_launch_id(GSimpleAction *action, GVariant *param, gpointer user_data); void activate_menu_launch_uri(GSimpleAction *action, GVariant *param, gpointer user_data); void activate_menu_launch_command(GSimpleAction *action, GVariant *param, gpointer user_data); diff --git a/util/launcher.c b/util/launcher.c new file mode 100644 index 00000000..474f2319 --- /dev/null +++ b/util/launcher.c @@ -0,0 +1,67 @@ +/* + * vala-panel + * Copyright (C) 2015-2016 Konstantin Pugin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +#include +#include + +#include "launcher.h" + +typedef struct +{ + pid_t pid; +} SpawnData; + +void child_spawn_func(void *data) +{ + setpgid(0, getpgid(getppid())); +} + +bool vala_panel_launch_with_context(GDesktopAppInfo *app_info, GAppLaunchContext *cxt, GList *uris) +{ + g_autoptr(GError) err = NULL; + bool ret = g_desktop_app_info_launch_uris_as_manager(G_DESKTOP_APP_INFO(app_info), + uris, + cxt, + G_SPAWN_SEARCH_PATH, + child_spawn_func, + NULL, + NULL, + NULL, + &err); + if (err) + g_warning("%s\n", err->message); + return ret; +} + +GAppInfo *vala_panel_get_default_for_uri(const char *uri) +{ + /* g_file_query_default_handler() calls + * g_app_info_get_default_for_uri_scheme() too, but we have to do it + * here anyway in case GFile can't parse @uri correctly. + */ + GAppInfo *app_info = NULL; + g_autofree char *uri_scheme = g_uri_parse_scheme(uri); + if (uri_scheme != NULL && strlen(uri_scheme) <= 0) + app_info = g_app_info_get_default_for_uri_scheme(uri_scheme); + if (app_info == NULL) + { + g_autoptr(GFile) file = g_file_new_for_uri(uri); + app_info = g_file_query_default_handler(file, NULL, NULL); + } + return app_info; +} diff --git a/util/launcher.h b/util/launcher.h new file mode 100644 index 00000000..6b8c064c --- /dev/null +++ b/util/launcher.h @@ -0,0 +1,30 @@ +/* + * vala-panel + * Copyright (C) 2015-2016 Konstantin Pugin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +#ifndef LAUNCHER_H +#define LAUNCHER_H + +#include +#include +#include + +bool vala_panel_launch_with_context(GDesktopAppInfo *app_info, GAppLaunchContext *cxt, GList *uris); +GAppInfo *vala_panel_get_default_for_uri(const char *uri); +void child_spawn_func(void *data); + +#endif // LAUNCHER_H diff --git a/util/misc.c b/util/misc.c new file mode 100644 index 00000000..04cb20d3 --- /dev/null +++ b/util/misc.c @@ -0,0 +1,63 @@ +/* + * vala-panel + * Copyright (C) 2015-2016 Konstantin Pugin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +#include +#include + +#include "misc.h" + +void vala_panel_add_prop_as_action(GActionMap *map, const char *prop) +{ + g_autoptr(GAction) action = G_ACTION(g_property_action_new(prop, map, prop)); + g_action_map_add_action(map, action); +} + +void vala_panel_add_gsettings_as_action(GActionMap *map, GSettings *settings, const char *prop) +{ + g_settings_bind(settings, + prop, + map, + prop, + (GSettingsBindFlags)(G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET | + G_SETTINGS_BIND_DEFAULT)); + g_autoptr(GAction) action = G_ACTION(g_settings_create_action(settings, prop)); + g_action_map_add_action(map, action); +} + +void vala_panel_reset_schema(GSettings *settings) +{ + g_autoptr(GSettingsSchema) schema = NULL; + g_object_get(settings, "settings-schema", &schema, NULL); + g_auto(GStrv) keys = g_settings_schema_list_keys(schema); + for (int i = 0; keys[i]; i++) + g_settings_reset(settings, keys[i]); +} + +void vala_panel_reset_schema_with_children(GSettings *settings) +{ + g_settings_delay(settings); + vala_panel_reset_schema(settings); + g_auto(GStrv) children = g_settings_list_children(settings); + for (int i = 0; children[i]; i++) + { + g_autoptr(GSettings) child = g_settings_get_child(settings, children[i]); + vala_panel_reset_schema(child); + } + g_settings_apply(settings); + g_settings_sync(); +} diff --git a/util/misc.h b/util/misc.h new file mode 100644 index 00000000..ef83e890 --- /dev/null +++ b/util/misc.h @@ -0,0 +1,33 @@ +/* + * vala-panel + * Copyright (C) 2015-2016 Konstantin Pugin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +#ifndef MISC_H +#define MISC_H + +#include + +G_BEGIN_DECLS + +void vala_panel_add_prop_as_action(GActionMap *map, const char *prop); +void vala_panel_add_gsettings_as_action(GActionMap *map, GSettings *settings, const char *prop); +void vala_panel_reset_schema(GSettings *settings); +void vala_panel_reset_schema_with_children(GSettings *settings); + +G_END_DECLS + +#endif // MISC_H diff --git a/util/util-gtk.h b/util/util-gtk.h new file mode 100644 index 00000000..7d949ab7 --- /dev/null +++ b/util/util-gtk.h @@ -0,0 +1,26 @@ +/* + * vala-panel + * Copyright (C) 2015-2018 Konstantin Pugin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +#ifndef UTIL_GTK_H +#define UTIL_GTK_H + +#include "css.h" +#include "launcher-gtk.h" +#include "util.h" + +#endif diff --git a/util/util.h b/util/util.h new file mode 100644 index 00000000..418df93c --- /dev/null +++ b/util/util.h @@ -0,0 +1,29 @@ +/* + * vala-panel + * Copyright (C) 2015-2018 Konstantin Pugin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +#ifndef UTIL_H +#define UTIL_H + +#include "boxed-wrapper.h" +#include "constants.h" +#include "glistmodel-filter.h" +#include "info-data.h" +#include "launcher.h" +#include "misc.h" + +#endif