diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index d9d373e2..a79d0a95 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -44,13 +44,10 @@ set(APP_SOURCES set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}/${CMAKE_PROJECT_NAME}/") add_custom_target(vala-ide-app SOURCES ${VALA_FILES}) add_executable (${APPNAME} ${VALA_C} ${APP_SOURCES}) -add_executable(${APPNAME}-new ${APP_SOURCES} application-new.c application-new.h) target_link_libraries (${APPNAME} ${LIBNAME} ${CORE_LIBRARIES}) -target_link_libraries (${APPNAME}-new ${CORE_LIBRARIES} ${LIBNAME}) 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_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/lib) -target_include_directories(${APPNAME}-new PRIVATE ${CORE_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/lib/c-lib ${CMAKE_SOURCE_DIR}/lib ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/lib) -install (TARGETS ${APPNAME} ${APPNAME}-new RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin) +install (TARGETS ${APPNAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin) add_executable(${APPNAME}-runner ${GLIB_RESOURCES_APP} diff --git a/app/application-new.c b/app/application-new.c deleted file mode 100644 index d3432303..00000000 --- a/app/application-new.c +++ /dev/null @@ -1,481 +0,0 @@ -/* - * vala-panel - * Copyright (C) 2015-2017 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 "config.h" - -#include "application-new.h" -#include "launcher.h" -#include "lib/css.h" -#include "lib/definitions.h" - -#include -#include -#include - -struct _ValaPanelApplication -{ - bool started; - bool restart; - GtkDialog *pref_dialog; - GSettings *config; - bool dark; - bool custom; - char *css; - GtkCssProvider *provider; - char *profile; - char *run_command; - char *terminal_command; - char *logout_command; - char *shutdown_command; -}; - -G_DEFINE_TYPE(ValaPanelApplication, vala_panel_application, GTK_TYPE_APPLICATION) - -static void activate_command(GSimpleAction *simple, GVariant *param, gpointer data); -static void activate_exit(GSimpleAction *simple, GVariant *param, gpointer data); - -static const GOptionEntry entries[] = - { { "version", 'v', 0, G_OPTION_ARG_NONE, NULL, N_("Print version and exit"), NULL }, - { "profile", 'p', 0, G_OPTION_ARG_STRING, NULL, N_("Use specified profile"), N_("profile") }, - { "command", - 'c', - 0, - G_OPTION_ARG_STRING, - NULL, - N_("Run command on already opened panel"), - N_("cmd") }, - { NULL } }; - -static const GActionEntry vala_panel_application_app_entries[6] = { - // { "preferences", - // activate_preferences, NULL, - // NULL, NULL , { 0 } }, - // { "panel-preferences", - // activate_panel_preferences, - // "s", NULL, NULL, { 0 } }, - // { "about", activate_about, - // NULL, NULL, NULL, { 0 } }, - // { "menu", - // activate_menu, - // NULL, NULL, NULL, { 0 } }, - { "session-command", activate_command, "s", NULL, NULL, { 0 } }, - { "quit", activate_exit, "b", NULL, NULL, { 0 } }, -}; -static const GActionEntry vala_panel_application_menu_entries[3] = - { { "launch-id", activate_menu_launch_id, "s", NULL, NULL, { 0 } }, - { "launch-uri", activate_menu_launch_uri, "s", NULL, NULL, { 0 } }, - { "launch-command", activate_menu_launch_command, "s", NULL, NULL, { 0 } } }; - -enum -{ - VALA_PANEL_APP_DUMMY_PROPERTY, - VALA_PANEL_APP_PROFILE, - VALA_PANEL_APP_RUN_COMMAND, - VALA_PANEL_APP_TERMINAL_COMMAND, - VALA_PANEL_APP_LOGOUT_COMMAND, - VALA_PANEL_APP_SHUTDOWN_COMMAND, - VALA_PANEL_APP_IS_DARK, - VALA_PANEL_APP_IS_CUSTOM, - VALA_PANEL_APP_CSS -}; -#define system_config_file_name(profile, dir, filename) \ - g_build_filename(dir, GETTEXT_PACKAGE, profile, filename, NULL) - -ValaPanelApplication *vala_panel_application_new() -{ - return (ValaPanelApplication *)g_object_new(vala_panel_application_get_type(), - "application-id", - "org.valapanel.application", - "flags", - G_APPLICATION_HANDLES_COMMAND_LINE, - "resource-base-path", - "/org/vala-panel/app", - NULL); -} - -static void vala_panel_application_init(ValaPanelApplication *self) -{ - self->started = false; - self->restart = false; - self->profile = g_strdup("default"); - g_application_add_main_option_entries(G_APPLICATION(self), entries); -} - -static void vala_panel_application_startup(GApplication *base) -{ - ValaPanelApplication *self = (ValaPanelApplication *)base; - G_APPLICATION_CLASS(vala_panel_application_parent_class) - ->startup((GApplication *)G_TYPE_CHECK_INSTANCE_CAST(self, - gtk_application_get_type(), - GtkApplication)); - g_application_mark_busy((GApplication *)self); - setlocale(LC_CTYPE, ""); - bindtextdomain(CONFIG_GETTEXT_PACKAGE, CONFIG_LOCALE_DIR); - bind_textdomain_codeset(CONFIG_GETTEXT_PACKAGE, "UTF-8"); - textdomain(CONFIG_GETTEXT_PACKAGE); - gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), CONFIG_DATADIR "/images"); - g_action_map_add_action_entries((GActionMap *)self, - vala_panel_application_app_entries, - G_N_ELEMENTS(vala_panel_application_app_entries), - self); - g_action_map_add_action_entries((GActionMap *)self, - vala_panel_application_menu_entries, - G_N_ELEMENTS(vala_panel_application_menu_entries), - self); -} - -static void vala_panel_application_shutdown(GApplication *base) -{ - g_autoptr(GSList) list = NULL; - GList *lst = gtk_application_get_windows(GTK_APPLICATION(base)); - for (GList *il = lst; il != NULL; il = il->next) - list = g_slist_append(list, il->data); - for (GSList *il = list; il != NULL; il = il->next) - { - GtkWindow *w = GTK_WINDOW(il->data); - gtk_window_set_application(w, NULL); - gtk_widget_destroy(GTK_WIDGET(w)); - } - G_APPLICATION_CLASS(vala_panel_application_parent_class) - ->shutdown((GApplication *)G_TYPE_CHECK_INSTANCE_CAST(base, - gtk_application_get_type(), - GtkApplication)); - if (VALA_PANEL_APPLICATION(base)->restart) - { - char cwd[1024]; - getcwd(cwd, 1024); - const char *argv[] = { CONFIG_GETTEXT_PACKAGE, - "-p", - VALA_PANEL_APPLICATION(base)->profile }; - g_auto(GStrv) envp = g_get_environ(); - g_spawn_async(cwd, - (GStrv)argv, - envp, - G_SPAWN_SEARCH_PATH, - child_spawn_func, - NULL, - NULL, - NULL); - } -} - -static gint vala_panel_app_handle_local_options(GApplication *application, GVariantDict *options) -{ - if (g_variant_dict_contains(options, "version")) - { - g_print(_("%s - Version %s\n"), g_get_application_name(), CONFIG_VERSION); - return 0; - } - return -1; -} - -static int vala_panel_app_command_line(GApplication *application, - GApplicationCommandLine *commandline) -{ - g_autofree gchar *profile_name = NULL; - g_autoptr(GVariantDict) options; - g_autofree gchar *ccommand = NULL; - options = g_application_command_line_get_options_dict(commandline); - if (g_variant_dict_lookup(options, "profile", "&s", &profile_name)) - g_object_set(G_OBJECT(application), "profile", profile_name, NULL); - if (g_variant_dict_lookup(options, "command", "&s", &ccommand)) - { - g_autofree gchar *name = NULL; - g_autoptr(GVariant) param = NULL; - g_autoptr(GError) err = NULL; - g_action_parse_detailed_name(ccommand, &name, ¶m, &err); - if (err) - g_warning("%s\n", err->message); - else if (g_action_map_lookup_action(G_ACTION_MAP(application), name)) - g_action_group_activate_action(G_ACTION_GROUP(application), name, param); - else - { - g_auto(GStrv) listv = - g_action_group_list_actions(G_ACTION_GROUP(application)); - g_autofree gchar *list = g_strjoinv(" ", listv); - g_application_command_line_printerr( - commandline, - _("%s: invalid command - %s. Doing nothing.\nValid commands: %s\n"), - g_get_application_name(), - ccommand, - list); - } - } - g_application_activate(application); - return 0; -} - -static void vala_panel_app_finalize(GObject *object) -{ - ValaPanelApplication *app = VALA_PANEL_APPLICATION(object); - if (app->css) - g_free(app->css); - if (app->terminal_command) - g_free(app->terminal_command); - if (app->run_command) - g_free(app->run_command); - if (app->logout_command) - g_free(app->logout_command); - if (app->shutdown_command) - g_free(app->shutdown_command); - if (app->provider) - g_object_unref(app->provider); - g_free(app->profile); -} - -void apply_styling(ValaPanelApplication *app) -{ - if (gtk_settings_get_default() != NULL) - g_object_set(gtk_settings_get_default(), - "gtk-application-prefer-dark-theme", - app->dark, - NULL); - if (app->custom) - { - if (app->provider) - gtk_style_context_remove_provider_for_screen(gdk_screen_get_default(), - app->provider); - app->provider = css_apply_from_file_to_app_with_provider(app->css); - } - else if (app->provider) - { - gtk_style_context_remove_provider_for_screen(gdk_screen_get_default(), - app->provider); - app->provider = NULL; - } -} - -static void vala_panel_app_set_property(GObject *object, guint prop_id, const GValue *value, - GParamSpec *pspec) -{ - ValaPanelApplication *app; - g_return_if_fail(VALA_PANEL_IS_APPLICATION(object)); - - app = VALA_PANEL_APPLICATION(object); - - switch (prop_id) - { - case VALA_PANEL_APP_IS_DARK: - app->dark = g_value_get_boolean(value); - apply_styling(app); - break; - case VALA_PANEL_APP_IS_CUSTOM: - app->custom = g_value_get_boolean(value); - apply_styling(app); - break; - case VALA_PANEL_APP_TERMINAL_COMMAND: - if (app->terminal_command) - g_free(app->terminal_command); - app->terminal_command = g_strdup(g_value_get_string(value)); - break; - case VALA_PANEL_APP_RUN_COMMAND: - if (app->run_command) - g_free(app->run_command); - app->run_command = g_strdup(g_value_get_string(value)); - break; - case VALA_PANEL_APP_LOGOUT_COMMAND: - if (app->logout_command) - g_free(app->logout_command); - app->logout_command = g_strdup(g_value_get_string(value)); - break; - case VALA_PANEL_APP_SHUTDOWN_COMMAND: - if (app->shutdown_command) - g_free(app->shutdown_command); - app->shutdown_command = g_strdup(g_value_get_string(value)); - break; - case VALA_PANEL_APP_PROFILE: - if (app->profile) - g_free(app->profile); - app->profile = g_strdup(g_value_get_string(value)); - break; - case VALA_PANEL_APP_CSS: - if (app->css) - g_free(app->css); - app->css = g_strdup(g_value_get_string(value)); - apply_styling(app); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void vala_panel_app_get_property(GObject *object, guint prop_id, GValue *value, - GParamSpec *pspec) -{ - ValaPanelApplication *app; - g_return_if_fail(VALA_PANEL_IS_APPLICATION(object)); - - app = VALA_PANEL_APPLICATION(object); - - switch (prop_id) - { - case VALA_PANEL_APP_IS_DARK: - g_value_set_boolean(value, app->dark); - break; - case VALA_PANEL_APP_IS_CUSTOM: - g_value_set_boolean(value, app->custom); - break; - case VALA_PANEL_APP_RUN_COMMAND: - g_value_set_string(value, app->run_command); - break; - case VALA_PANEL_APP_TERMINAL_COMMAND: - g_value_set_string(value, app->terminal_command); - break; - case VALA_PANEL_APP_LOGOUT_COMMAND: - g_value_set_string(value, app->logout_command); - break; - case VALA_PANEL_APP_SHUTDOWN_COMMAND: - g_value_set_string(value, app->shutdown_command); - break; - case VALA_PANEL_APP_PROFILE: - g_value_set_string(value, app->profile); - break; - case VALA_PANEL_APP_CSS: - g_value_set_string(value, app->css); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void activate_command(GSimpleAction *simple, GVariant *param, gpointer data) -{ - g_autofree gchar *command; - const char *cmd = g_variant_get_string(param, NULL); - GtkApplication *app = GTK_APPLICATION(data); - g_object_get(app, cmd, &command, NULL); - g_autoptr(GVariant) par = g_variant_new_string(command); - activate_menu_launch_command(NULL, par, NULL); -} - -static void activate_exit(GSimpleAction *simple, GVariant *param, gpointer data) -{ - bool restart = g_variant_get_boolean(param); - ValaPanelApplication *app = (ValaPanelApplication *)data; - app->restart = restart; - g_application_quit(G_APPLICATION(app)); -} - -static void vala_panel_application_class_init(ValaPanelApplicationClass *klass) -{ - vala_panel_application_parent_class = g_type_class_peek_parent(klass); - ((GApplicationClass *)klass)->startup = vala_panel_application_startup; - ((GApplicationClass *)klass)->shutdown = vala_panel_application_shutdown; - // ((GApplicationClass *) klass)->activate = vala_panel_app_real_activate; - ((GApplicationClass *)klass)->handle_local_options = vala_panel_app_handle_local_options; - ((GApplicationClass *)klass)->command_line = vala_panel_app_command_line; - G_OBJECT_CLASS(klass)->get_property = vala_panel_app_get_property; - G_OBJECT_CLASS(klass)->set_property = vala_panel_app_set_property; - G_OBJECT_CLASS(klass)->finalize = vala_panel_app_finalize; - g_object_class_install_property(G_OBJECT_CLASS(klass), - VALA_PANEL_APP_PROFILE, - g_param_spec_string("profile", - "profile", - "profile", - NULL, - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB | - G_PARAM_READABLE | - G_PARAM_WRITABLE)); - g_object_class_install_property(G_OBJECT_CLASS(klass), - VALA_PANEL_APP_RUN_COMMAND, - g_param_spec_string("run-command", - "run-command", - "run-command", - NULL, - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB | - G_PARAM_READABLE | - G_PARAM_WRITABLE)); - g_object_class_install_property(G_OBJECT_CLASS(klass), - VALA_PANEL_APP_TERMINAL_COMMAND, - g_param_spec_string("terminal-command", - "terminal-command", - "terminal-command", - NULL, - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB | - G_PARAM_READABLE | - G_PARAM_WRITABLE)); - g_object_class_install_property(G_OBJECT_CLASS(klass), - VALA_PANEL_APP_LOGOUT_COMMAND, - g_param_spec_string("logout-command", - "logout-command", - "logout-command", - NULL, - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB | - G_PARAM_READABLE | - G_PARAM_WRITABLE)); - g_object_class_install_property(G_OBJECT_CLASS(klass), - VALA_PANEL_APP_SHUTDOWN_COMMAND, - g_param_spec_string("shutdown-command", - "shutdown-command", - "shutdown-command", - NULL, - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB | - G_PARAM_READABLE | - G_PARAM_WRITABLE)); - g_object_class_install_property(G_OBJECT_CLASS(klass), - VALA_PANEL_APP_IS_DARK, - g_param_spec_boolean("is-dark", - "is-dark", - "is-dark", - false, - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB | - G_PARAM_READABLE | - G_PARAM_WRITABLE)); - g_object_class_install_property(G_OBJECT_CLASS(klass), - VALA_PANEL_APP_IS_CUSTOM, - g_param_spec_boolean("is-custom", - "is-custom", - "is-custom", - false, - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB | - G_PARAM_READABLE | - G_PARAM_WRITABLE)); - g_object_class_install_property(G_OBJECT_CLASS(klass), - VALA_PANEL_APP_CSS, - g_param_spec_string("css", - "css", - "css", - NULL, - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB | - G_PARAM_READABLE | - G_PARAM_WRITABLE)); -} - -int main(int argc, char *argv[]) -{ - g_autoptr(ValaPanelApplication) app = vala_panel_application_new(); - return g_application_run(G_APPLICATION(app), argc, argv); -} diff --git a/app/application-new.h b/app/application-new.h deleted file mode 100644 index b82a866e..00000000 --- a/app/application-new.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef APPLICATIONNEW_H -#define APPLICATIONNEW_H - -#include -#include - -G_BEGIN_DECLS - -G_DECLARE_FINAL_TYPE(ValaPanelApplication, vala_panel_application, VALA_PANEL, APPLICATION, - GtkApplication) - -G_END_DECLS - -#endif // APPLICATIONNEW_H diff --git a/app/vala-panel-platform-standalone-x11.c b/app/vala-panel-platform-standalone-x11.c index 7d10e8c4..6d2183a9 100644 --- a/app/vala-panel-platform-standalone-x11.c +++ b/app/vala-panel-platform-standalone-x11.c @@ -18,8 +18,7 @@ #include "vala-panel-platform-standalone-x11.h" #include "gio/gsettingsbackend.h" -#include "lib/applets-new/applet-api.h" -#include "lib/c-lib/toplevel.h" +#include "lib/settings-manager.h" #include "lib/definitions.h" struct _ValaPanelPlatformX11 @@ -56,14 +55,14 @@ static GSettings *vala_panel_platform_x11_get_settings_for_scheme(ValaPanelPlatf const char *scheme, const char *path) { - ValaPanelPlatformX11 *self = VALA_PANEL_PLATFORM_X11(obj); - g_autoptr(GSettingsBackend) backend = - g_keyfile_settings_backend_new(_user_config_file_name(GETTEXT_PACKAGE, - self->profile, - NULL), - DEFAULT_PLUGIN_PATH, - "main-settings"); - return g_settings_new_with_backend_and_path(scheme, backend, path); +// ValaPanelPlatformX11 *self = VALA_PANEL_PLATFORM_X11(obj); +// g_autoptr(GSettingsBackend) backend = +// g_keyfile_settings_backend_new(_user_config_file_name(GETTEXT_PACKAGE, +// self->profile, +// NULL), +// DEFAULT_PLUGIN_PATH, +// "main-settings"); +// return g_settings_new_with_backend_and_path(scheme, backend, path); } static void vala_panel_platform_x11_remove_settings_path(ValaPanelPlatform *obj, const char *path, @@ -87,27 +86,27 @@ static bool vala_panel_platform_x11_start_panels_from_profile(ValaPanelPlatform GtkApplication *app, const char *profile) { - ValaPanelPlatformX11 *self = VALA_PANEL_PLATFORM_X11(obj); - g_autoptr(GKeyFile) f = g_key_file_new(); - g_key_file_load_from_config(f, self->profile); - g_autoptr(GSettingsBackend) backend = - g_keyfile_settings_backend_new(_user_config_file_name(GETTEXT_PACKAGE, - self->profile, - NULL), - DEFAULT_PLUGIN_PATH, - "main-settings"); - g_autoptr(GSettings) s = - g_settings_new_with_backend_and_path(VALA_PANEL_APPLICATION_SETTINGS, - backend, - DEFAULT_PLUGIN_PATH); - g_autoptr(GSettings) settings = g_settings_get_child(s, profile); - g_auto(GStrv) panels = g_settings_get_strv(settings, VALA_PANEL_APPLICATION_PANELS); - for (int i = 0; panels[i] != NULL; i++) - { +// ValaPanelPlatformX11 *self = VALA_PANEL_PLATFORM_X11(obj); +// g_autoptr(GKeyFile) f = g_key_file_new(); +// g_key_file_load_from_config(f, self->profile); +// g_autoptr(GSettingsBackend) backend = +// g_keyfile_settings_backend_new(_user_config_file_name(GETTEXT_PACKAGE, +// self->profile, +// NULL), +// DEFAULT_PLUGIN_PATH, +// "main-settings"); +// g_autoptr(GSettings) s = +// g_settings_new_with_backend_and_path(VALA_PANEL_APPLICATION_SETTINGS, +// backend, +// DEFAULT_PLUGIN_PATH); +// g_autoptr(GSettings) settings = g_settings_get_child(s, profile); +// g_auto(GStrv) panels = g_settings_get_strv(settings, VALA_PANEL_APPLICATION_PANELS); +// for (int i = 0; panels[i] != NULL; i++) +// { // ValaPanelToplevelUnit *unit = // vala_panel_toplevel_unit_new_from_uid(app, panels[i]); // gtk_application_add_window(app, GTK_WINDOW(unit)); - } +// } return true; } diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 20a5d772..0a84cc2b 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,5 +1,3 @@ -add_subdirectory(applets-new) -add_subdirectory(c-lib) include(GLibHelpers) set(ENUM_FILES panel-platform.h diff --git a/lib/applets-new/CMakeLists.txt b/lib/applets-new/CMakeLists.txt deleted file mode 100644 index 10f3e2e6..00000000 --- a/lib/applets-new/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -include(GResource) -include(GLibHelpers) -add_glib_marshal(MARSHALS MARSHALH "applet-api-marshal" g_cclosure_user_marshal) -set(ENUM_FILES - applet-widget.h) -add_glib_enumtypes(ENUMSC ENUMSH vala-applet-enums ${ENUM_FILES}) -add_library(applet-api-new SHARED - applet-widget.c - applet-info.c - applet-engine.c - applet-api.h - ${MARSHALS} - ${ENUMSC} - ${ENUMSH} - ${MARSHALH} - ) -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) -set_target_properties (applet-api-new PROPERTIES - VERSION ${VERSION} - SOVERSION ${SOVERSION}) -install (TARGETS applet-api-new DESTINATION ${CMAKE_INSTALL_LIBDIR}/${CMAKE_PROJECT_NAME}/ COMPONENT bin) - diff --git a/lib/applets-new/applet-api-marshal.list b/lib/applets-new/applet-api-marshal.list deleted file mode 100644 index 94949b14..00000000 --- a/lib/applets-new/applet-api-marshal.list +++ /dev/null @@ -1,2 +0,0 @@ -VOID: ENUM,INT,INT -VOID: OBJECT,OBJECT diff --git a/lib/applets-new/applet-api.h b/lib/applets-new/applet-api.h deleted file mode 100644 index cd11f3d7..00000000 --- a/lib/applets-new/applet-api.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef APPLETAPI_H -#define APPLETAPI_H - -#include "applet-engine.h" -#include "applet-info.h" -#include "applet-widget.h" - -#endif // APPLETAPI_H diff --git a/lib/applets-new/applet-engine.c b/lib/applets-new/applet-engine.c deleted file mode 100644 index 46f77293..00000000 --- a/lib/applets-new/applet-engine.c +++ /dev/null @@ -1,38 +0,0 @@ -#include "applet-engine.h" - -G_DEFINE_INTERFACE(ValaPanelAppletEngine, vala_panel_applet_engine, G_TYPE_OBJECT) - -GSList *vala_panel_applet_engine_get_available_types(ValaPanelAppletEngine *self) -{ - if (self) - return VALA_PANEL_APPLET_ENGINE_GET_IFACE(self)->get_available_types(self); - return NULL; -} - -ValaPanelAppletInfo *vala_panel_applet_engine_get_applet_info_for_type(ValaPanelAppletEngine *self, - const char *applet_type) -{ - if (self && g_slist_find(vala_panel_applet_engine_get_available_types(self), applet_type)) - return VALA_PANEL_APPLET_ENGINE_GET_IFACE(self) - ->get_applet_info_for_type(self, applet_type); - return NULL; -} - -ValaPanelAppletWidget *vala_panel_applet_engine_get_applet_widget_for_type( - ValaPanelAppletEngine *self, const char *applet_type, GSettings *settings, const char *uuid) -{ - if (self && g_slist_find(vala_panel_applet_engine_get_available_types(self), applet_type)) - return VALA_PANEL_APPLET_ENGINE_GET_IFACE(self) - ->get_applet_widget_for_type(self, applet_type, settings, uuid); - return NULL; -} - -bool vala_panel_applet_engine_contains_applet(ValaPanelAppletEngine *self, const char *applet_type) -{ - return g_slist_find(vala_panel_applet_engine_get_available_types(self), applet_type) != - NULL; -} - -void vala_panel_applet_engine_default_init(ValaPanelAppletEngineInterface *iface) -{ -} diff --git a/lib/applets-new/applet-engine.h b/lib/applets-new/applet-engine.h deleted file mode 100644 index b14664d7..00000000 --- a/lib/applets-new/applet-engine.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef APPLETENGINE_H -#define APPLETENGINE_H - -#include "applet-info.h" -#include -#include - -G_BEGIN_DECLS - -G_DECLARE_INTERFACE(ValaPanelAppletEngine, vala_panel_applet_engine, VALA_PANEL, APPLET_ENGINE, - GObject) - -struct _ValaPanelAppletEngineInterface -{ - GTypeInterface g_iface; - GSList *(*get_available_types)(ValaPanelAppletEngine *self); - ValaPanelAppletInfo *(*get_applet_info_for_type)(ValaPanelAppletEngine *self, - const char *applet_type); - ValaPanelAppletWidget *(*get_applet_widget_for_type)(ValaPanelAppletEngine *self, - const char *applet_type, - GSettings *settings, const char *uuid); - gpointer padding[12]; -}; - -G_END_DECLS - -#endif // APPLETENGINE_H diff --git a/lib/applets-new/applet-info.c b/lib/applets-new/applet-info.c deleted file mode 100644 index 32a3d2ef..00000000 --- a/lib/applets-new/applet-info.c +++ /dev/null @@ -1,350 +0,0 @@ -#include "applet-info.h" -#include "lib/definitions.h" - -#define G_SETTINGS_ENABLE_BACKEND -#include - -#include - -struct _ValaPanelAppletInfo -{ - ValaPanelAppletWidget *applet; - GSettings *settings; - gchar *icon; - gchar *applet_type; - gchar *name; - gchar *description; - gchar *uuid; - gchar *profile; - GtkAlign alignment; - GtkOrientation orientation; - gint position; - bool expand; -}; - -enum -{ - VALA_PANEL_APPLET_INFO_DUMMY_PROPERTY, - VALA_PANEL_APPLET_INFO_APPLET, - VALA_PANEL_APPLET_INFO_SETTINGS, - VALA_PANEL_APPLET_INFO_ICON, - VALA_PANEL_APPLET_INFO_APPLET_TYPE, - VALA_PANEL_APPLET_INFO_NAME, - VALA_PANEL_APPLET_INFO_DESCRIPTION, - VALA_PANEL_APPLET_INFO_UUID, - VALA_PANEL_APPLET_INFO_FILENAME, - VALA_PANEL_APPLET_INFO_ALIGNMENT, - VALA_PANEL_APPLET_INFO_ORIENTATION, - VALA_PANEL_APPLET_INFO_POSITION, - VALA_PANEL_APPLET_INFO_EXPAND -}; - -G_DEFINE_TYPE(ValaPanelAppletInfo, vala_panel_applet_info, G_TYPE_OBJECT) - -// static ValaPanelAppletInfo* -// vala_panel_applet_info_new_libpeas(PeasPluginInfo* plugin_info, const char* uuid, -// const char* filename, ValaPanelAppletWidget* applet) -//{ -// return g_object_new(vala_panel_applet_info_get_type(), "icon", -// peas_plugin_info_get_icon_name(plugin_info), "name", -// peas_plugin_info_get_name(plugin_info), "description", -// peas_plugin_info_get_description(plugin_info), "uuid", -// uuid, "applet", applet, "filename", filename, NULL); -//} - -void vala_panel_applet_info_init(ValaPanelAppletInfo *self) -{ -} - -static void vala_panel_applet_info_bind_settings(ValaPanelAppletInfo *self) -{ - g_settings_bind(self->settings, - "position", - (GObject *)self, - "position", - (G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET) | G_SETTINGS_BIND_DEFAULT); - g_settings_bind(self->settings, - "alignment", - (GObject *)self, - "alignment", - (G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET) | G_SETTINGS_BIND_DEFAULT); - g_settings_bind(self->settings, - "expand", - (GObject *)self, - "expand", - (G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET) | G_SETTINGS_BIND_DEFAULT); -} - -static void vala_panel_applet_info_unbind_settings(ValaPanelAppletInfo *self) -{ - g_settings_unbind(self->settings, "position"); - g_settings_unbind(self->settings, "alignment"); - g_settings_unbind(self->settings, "expand"); -} - -static void vala_panel_applet_info_constructed(ValaPanelAppletInfo *self) -{ - // GSettings must not be accessed directly!!! Need a Manager-based access. - // g_autofree gchar *path = g_build_path("/", DEFAULT_PLUGIN_PATH, self->uuid, - // NULL); - // g_autofree char *filename = _user_config_file_name(path, self->profile, self->uuid); - // g_autoptr(GSettingsBackend) bck = - // g_keyfile_settings_backend_new(filename, path, DEFAULT_PLUGIN_GROUP); - // self->settings = g_settings_new_with_backend(DEFAULT_PLUGIN_SETTINGS_ID, bck); - // gchar *str = g_strdup(g_strstrip(g_strdelimit(self->name, " '", '_'))); - // g_ascii_inplace_tolower(str); - // self->applet_type = str; - G_OBJECT_CLASS(vala_panel_applet_info_parent_class)->constructed(G_OBJECT(self)); -} - -static void vala_panel_applet_info_get_property(GObject *object, guint property_id, GValue *value, - GParamSpec *pspec) -{ - ValaPanelAppletInfo *self; - self = G_TYPE_CHECK_INSTANCE_CAST(object, - vala_panel_applet_info_get_type(), - ValaPanelAppletInfo); - switch (property_id) - { - case VALA_PANEL_APPLET_INFO_APPLET: - g_value_set_object(value, self->applet); - break; - case VALA_PANEL_APPLET_INFO_SETTINGS: - g_value_set_object(value, self->settings); - break; - case VALA_PANEL_APPLET_INFO_ICON: - g_value_set_string(value, self->icon); - break; - case VALA_PANEL_APPLET_INFO_APPLET_TYPE: - g_value_set_string(value, self->applet_type); - break; - case VALA_PANEL_APPLET_INFO_NAME: - g_value_set_string(value, self->name); - break; - case VALA_PANEL_APPLET_INFO_DESCRIPTION: - g_value_set_string(value, self->description); - break; - case VALA_PANEL_APPLET_INFO_UUID: - g_value_set_string(value, self->uuid); - break; - case VALA_PANEL_APPLET_INFO_FILENAME: - g_value_set_string(value, self->profile); - break; - case VALA_PANEL_APPLET_INFO_ALIGNMENT: - g_value_set_enum(value, self->alignment); - break; - case VALA_PANEL_APPLET_INFO_ORIENTATION: - g_value_set_enum(value, self->orientation); - break; - case VALA_PANEL_APPLET_INFO_POSITION: - g_value_set_int(value, self->position); - break; - case VALA_PANEL_APPLET_INFO_EXPAND: - g_value_set_boolean(value, self->expand); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - break; - } -} - -static void vala_panel_applet_info_set_property(GObject *object, guint property_id, - const GValue *value, GParamSpec *pspec) -{ - ValaPanelAppletInfo *self; - self = G_TYPE_CHECK_INSTANCE_CAST(object, - vala_panel_applet_info_get_type(), - ValaPanelAppletInfo); - switch (property_id) - { - case VALA_PANEL_APPLET_INFO_APPLET: - self->applet = g_value_get_object(value); - break; - case VALA_PANEL_APPLET_INFO_ICON: - g_value_replace_string(self->icon, value); - break; - case VALA_PANEL_APPLET_INFO_APPLET_TYPE: - g_value_replace_string(self->applet_type, value); - break; - case VALA_PANEL_APPLET_INFO_NAME: - g_value_replace_string(self->name, value); - break; - case VALA_PANEL_APPLET_INFO_DESCRIPTION: - g_value_replace_string(self->description, value); - break; - case VALA_PANEL_APPLET_INFO_UUID: - g_value_replace_string(self->uuid, value); - break; - case VALA_PANEL_APPLET_INFO_FILENAME: - g_value_replace_string(self->profile, value); - break; - case VALA_PANEL_APPLET_INFO_ALIGNMENT: - self->alignment = g_value_get_enum(value); - break; - case VALA_PANEL_APPLET_INFO_ORIENTATION: - self->orientation = g_value_get_enum(value); - break; - case VALA_PANEL_APPLET_INFO_POSITION: - self->position = g_value_get_int(value); - break; - case VALA_PANEL_APPLET_INFO_EXPAND: - self->expand = g_value_get_boolean(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - break; - } -} - -static void vala_panel_applet_info_finalize(GObject *obj) -{ - ValaPanelAppletInfo *self; - self = - G_TYPE_CHECK_INSTANCE_CAST(obj, vala_panel_applet_info_get_type(), ValaPanelAppletInfo); - g_object_unref(self->settings); - g_free0(self->icon); - g_free0(self->applet_type); - g_free0(self->name); - g_free0(self->description); - g_free0(self->uuid); - g_free0(self->profile); - G_OBJECT_CLASS(vala_panel_applet_info_parent_class)->finalize(obj); -} - -void vala_panel_applet_info_class_init(ValaPanelAppletInfoClass *klass) -{ - vala_panel_applet_info_parent_class = g_type_class_peek_parent(klass); - G_OBJECT_CLASS(klass)->constructed = vala_panel_applet_info_constructed; - G_OBJECT_CLASS(klass)->get_property = vala_panel_applet_info_get_property; - G_OBJECT_CLASS(klass)->set_property = vala_panel_applet_info_set_property; - G_OBJECT_CLASS(klass)->finalize = vala_panel_applet_info_finalize; - g_object_class_install_property(G_OBJECT_CLASS(klass), - VALA_PANEL_APPLET_INFO_APPLET, - g_param_spec_object("applet", - "applet", - "applet", - vala_panel_applet_widget_get_type(), - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB | - G_PARAM_READABLE | - G_PARAM_WRITABLE)); - g_object_class_install_property(G_OBJECT_CLASS(klass), - VALA_PANEL_APPLET_INFO_SETTINGS, - g_param_spec_object("settings", - "settings", - "settings", - G_TYPE_SETTINGS, - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB | - G_PARAM_READABLE)); - g_object_class_install_property(G_OBJECT_CLASS(klass), - VALA_PANEL_APPLET_INFO_ICON, - g_param_spec_string("icon", - "icon", - "icon", - NULL, - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB | - G_PARAM_READABLE)); - g_object_class_install_property(G_OBJECT_CLASS(klass), - VALA_PANEL_APPLET_INFO_APPLET_TYPE, - g_param_spec_string("applet-type", - "applet-type", - "applet-type", - NULL, - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB | - G_PARAM_READABLE)); - g_object_class_install_property(G_OBJECT_CLASS(klass), - VALA_PANEL_APPLET_INFO_NAME, - g_param_spec_string("name", - "name", - "name", - NULL, - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB | - G_PARAM_READABLE)); - g_object_class_install_property(G_OBJECT_CLASS(klass), - VALA_PANEL_APPLET_INFO_DESCRIPTION, - g_param_spec_string("description", - "description", - "description", - NULL, - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB | - G_PARAM_READABLE)); - g_object_class_install_property(G_OBJECT_CLASS(klass), - VALA_PANEL_APPLET_INFO_UUID, - g_param_spec_string("uuid", - "uuid", - "uuid", - NULL, - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB | - G_PARAM_READABLE | - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY)); - g_object_class_install_property(G_OBJECT_CLASS(klass), - VALA_PANEL_APPLET_INFO_FILENAME, - g_param_spec_string("filename", - "filename", - "filename", - NULL, - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB | - G_PARAM_READABLE | - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY)); - g_object_class_install_property(G_OBJECT_CLASS(klass), - VALA_PANEL_APPLET_INFO_ALIGNMENT, - g_param_spec_enum("alignment", - "alignment", - "alignment", - GTK_TYPE_ALIGN, - 0, - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB | - G_PARAM_READABLE | G_PARAM_WRITABLE)); - g_object_class_install_property(G_OBJECT_CLASS(klass), - VALA_PANEL_APPLET_INFO_ORIENTATION, - g_param_spec_enum("orientation", - "orientation", - "orientation", - GTK_TYPE_ORIENTATION, - 0, - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB | - G_PARAM_READABLE | G_PARAM_WRITABLE)); - g_object_class_install_property(G_OBJECT_CLASS(klass), - VALA_PANEL_APPLET_INFO_POSITION, - g_param_spec_int("position", - "position", - "position", - G_MININT, - G_MAXINT, - 0, - G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB | - G_PARAM_READABLE | G_PARAM_WRITABLE)); - g_object_class_install_property(G_OBJECT_CLASS(klass), - VALA_PANEL_APPLET_INFO_EXPAND, - g_param_spec_boolean("expand", - "expand", - "expand", - false, - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB | - G_PARAM_READABLE | - G_PARAM_WRITABLE)); -} diff --git a/lib/applets-new/applet-info.h b/lib/applets-new/applet-info.h deleted file mode 100644 index f31d134a..00000000 --- a/lib/applets-new/applet-info.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef APPLETINFO_H -#define APPLETINFO_H - -#include -#include - -#include "applet-widget.h" - -G_BEGIN_DECLS - -#define DEFAULT_PLUGIN_SETTINGS_ID "org.valapanel.toplevel.applet" -#define DEFAULT_PLUGIN_PATH "/org/vala-panel/objects/" -#define DEFAULT_PLUGIN_GROUP "position" - -#define DEFAULT_PLUGIN_NAME_KEY "plugin-type" -#define DEFAULT_PLUGIN_KEY_EXPAND "is-expanded" -#define DEFAULT_PLUGIN_KEY_POSITION "position" -#define DEFAULT_PLUGIN_KEY_ALIGNMENT "alignment" -#define DEFAULT_PLUGIN_KEY_ORIENTATION "orientation" - -G_DECLARE_FINAL_TYPE(ValaPanelAppletInfo, vala_panel_applet_info, VALA_PANEL, APPLET_INFO, GObject) - -G_END_DECLS - -#endif // APPLETINFO_H diff --git a/lib/applets-new/applet-widget.c b/lib/applets-new/applet-widget.c deleted file mode 100644 index 2e91bdcd..00000000 --- a/lib/applets-new/applet-widget.c +++ /dev/null @@ -1,205 +0,0 @@ -#define G_SETTINGS_ENABLE_BACKEND 1 -#include - -#include "applet-api-marshal.h" -#include "applet-api.h" -#include "applet-widget.h" -#include "lib/definitions.h" - -typedef struct -{ - const char *uuid; - GSettings *settings; - const char *panel; - GVariant *actions; -} ValaPanelAppletWidgetPrivate; - -enum -{ - VALA_PANEL_APPLET_WIDGET_DUMMY_PROPERTY, - VALA_PANEL_APPLET_WIDGET_UUID, - VALA_PANEL_APPLET_WIDGET_SETTINGS, - VALA_PANEL_APPLET_WIDGET_PANEL, - VALA_PANEL_APPLET_WIDGET_ACTIONS -}; - -G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE(ValaPanelAppletWidget, vala_panel_applet_widget, GTK_TYPE_BIN) - -static void vala_panel_applet_widget_get_property(GObject *object, guint property_id, GValue *value, - GParamSpec *pspec) -{ - ValaPanelAppletWidget *self = VALA_PANEL_APPLET_WIDGET(object); - self = G_TYPE_CHECK_INSTANCE_CAST(object, - vala_panel_applet_widget_get_type(), - ValaPanelAppletWidget); - ValaPanelAppletWidgetPrivate *priv = - (ValaPanelAppletWidgetPrivate *)vala_panel_applet_widget_get_instance_private(self); - switch (property_id) - { - case VALA_PANEL_APPLET_WIDGET_UUID: - g_value_set_string(value, priv->uuid); - break; - case VALA_PANEL_APPLET_WIDGET_SETTINGS: - g_value_set_object(value, priv->settings); - break; - case VALA_PANEL_APPLET_WIDGET_PANEL: - g_value_set_string(value, priv->panel); - break; - case VALA_PANEL_APPLET_WIDGET_ACTIONS: - g_value_set_variant(value, priv->actions); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - break; - } -} -static void vala_panel_applet_widget_set_property(GObject *object, guint property_id, - const GValue *value, GParamSpec *pspec) -{ - ValaPanelAppletWidget *self = VALA_PANEL_APPLET_WIDGET(object); - self = G_TYPE_CHECK_INSTANCE_CAST(object, - vala_panel_applet_widget_get_type(), - ValaPanelAppletWidget); - ValaPanelAppletWidgetPrivate *priv = - (ValaPanelAppletWidgetPrivate *)vala_panel_applet_widget_get_instance_private(self); - switch (property_id) - { - case VALA_PANEL_APPLET_WIDGET_UUID: - priv->uuid = g_value_get_string(value); - break; - case VALA_PANEL_APPLET_WIDGET_SETTINGS: - priv->settings = G_SETTINGS(g_value_get_object(value)); - break; - case VALA_PANEL_APPLET_WIDGET_PANEL: - priv->panel = g_value_get_string(value); - break; - case VALA_PANEL_APPLET_WIDGET_ACTIONS: - priv->actions = g_value_get_variant(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - break; - } -} -static void vala_panel_applet_widget_finalize(GObject *obj) -{ - ValaPanelAppletWidgetPrivate *priv = - (ValaPanelAppletWidgetPrivate *)vala_panel_applet_widget_get_instance_private( - (ValaPanelAppletWidget *)obj); - g_object_unref(priv->settings); - g_variant_unref(priv->actions); - G_OBJECT_CLASS(vala_panel_applet_widget_parent_class)->finalize(obj); -} - -static void vala_panel_applet_widget_class_init(ValaPanelAppletWidgetClass *klass) -{ - vala_panel_applet_widget_parent_class = g_type_class_peek_parent(klass); - g_type_class_add_private(klass, sizeof(ValaPanelAppletWidgetPrivate)); - G_OBJECT_CLASS(klass)->get_property = vala_panel_applet_widget_get_property; - G_OBJECT_CLASS(klass)->set_property = vala_panel_applet_widget_set_property; - G_OBJECT_CLASS(klass)->finalize = vala_panel_applet_widget_finalize; - // klass->update_popup = NULL; - g_object_class_install_property(G_OBJECT_CLASS(klass), - VALA_PANEL_APPLET_WIDGET_UUID, - g_param_spec_string("uuid", - "uuid", - "uuid", - NULL, - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB | - G_PARAM_READABLE | - G_PARAM_WRITABLE)); - g_object_class_install_property(G_OBJECT_CLASS(klass), - VALA_PANEL_APPLET_WIDGET_SETTINGS, - g_param_spec_object("settings", - "settings", - "settings", - G_TYPE_SETTINGS, - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB | - G_PARAM_READABLE | - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY)); - g_object_class_install_property(G_OBJECT_CLASS(klass), - VALA_PANEL_APPLET_WIDGET_PANEL, - g_param_spec_string("panel", - "panel", - "panel", - NULL, - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB | - G_PARAM_READABLE | - G_PARAM_WRITABLE)); - g_object_class_install_property(G_OBJECT_CLASS(klass), - VALA_PANEL_APPLET_WIDGET_ACTIONS, - g_param_spec_variant("actions", - "actions", - "actions", - "as", - NULL, - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_READABLE | - G_PARAM_WRITABLE)); - g_signal_new("panel-size-changed", - vala_panel_applet_widget_get_type(), - G_SIGNAL_RUN_LAST, - 0, - NULL, - NULL, - g_cclosure_user_marshal_VOID__ENUM_INT_INT, - G_TYPE_NONE, - 3, - GTK_TYPE_ORIENTATION, - G_TYPE_INT, - G_TYPE_INT); -} - -static void vala_panel_applet_widget_init(ValaPanelAppletWidget *self) -{ - ValaPanelAppletWidgetPrivate *priv = - (ValaPanelAppletWidgetPrivate *)vala_panel_applet_widget_get_instance_private(self); - gtk_widget_set_can_focus(GTK_WIDGET(self), false); -} - -// void vala_panel_applet_widget_update_popup(ValaPanelAppletWidget *self, ValaPanelPopupManager -// *mgr) -//{ -// if (self) -// { -// ValaPanelAppletWidgetClass *klass = VALA_PANEL_APPLET_WIDGET_GET_CLASS(self); -// if (klass->update_popup) -// klass->update_popup(self, mgr); -// } -//} - -void vala_panel_applet_widget_invoke_applet_action(ValaPanelAppletWidget *self, const char *action, - GVariantDict *param) -{ - if (self) - { - ValaPanelAppletWidgetClass *klass = VALA_PANEL_APPLET_WIDGET_GET_CLASS(self); - ValaPanelAppletWidgetPrivate *priv = - (ValaPanelAppletWidgetPrivate *)vala_panel_applet_widget_get_instance_private( - self); - g_autofree const char **actions = g_variant_get_strv(priv->actions, NULL); - if (klass->invoke_applet_action && g_strv_contains(actions, action)) - klass->invoke_applet_action(self, action, param); - } -} - -GtkWidget *vala_panel_applet_widget_get_settings_ui(ValaPanelAppletWidget *self) -{ - if (self) - { - ValaPanelAppletWidgetClass *klass = VALA_PANEL_APPLET_WIDGET_GET_CLASS(self); - if (klass->get_settings_ui) - klass->get_settings_ui(self); - } - return NULL; -} diff --git a/lib/applets-new/applet-widget.h b/lib/applets-new/applet-widget.h deleted file mode 100644 index 61ac7fd4..00000000 --- a/lib/applets-new/applet-widget.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef APPLETWIDGET_H -#define APPLETWIDGET_H - -#include -#include -#include -#include - -G_BEGIN_DECLS - -G_DECLARE_DERIVABLE_TYPE(ValaPanelAppletWidget, vala_panel_applet_widget, VALA_PANEL, APPLET_WIDGET, - GtkBin) - -struct _ValaPanelAppletWidgetClass -{ - GObjectClass parent_class; - // void (*update_popup)(ValaPanelAppletWidget *self, ValaPanelPopupManager *mgr); - void (*invoke_applet_action)(ValaPanelAppletWidget *self, const gchar *action, - GVariantDict *params); - GtkWidget *(*get_settings_ui)(ValaPanelAppletWidget *self); - gpointer padding[12]; -}; - -// void vala_panel_applet_widget_update_popup(ValaPanelAppletWidget *self, ValaPanelPopupManager -// *mgr); -void vala_panel_applet_widget_invoke_applet_action(ValaPanelAppletWidget *self, const char *action, - GVariantDict *param); -GtkWidget *vala_panel_applet_widget_get_settings_ui(ValaPanelAppletWidget *self); - -G_END_DECLS - -#endif // APPLETWIDGET_H diff --git a/lib/applets-new/vala-applet-enums.c.template b/lib/applets-new/vala-applet-enums.c.template deleted file mode 100644 index 1ba30f48..00000000 --- a/lib/applets-new/vala-applet-enums.c.template +++ /dev/null @@ -1,40 +0,0 @@ -/*** BEGIN file-header ***/ -#include "vala-applet-enums.h" - -/*** END file-header ***/ - -/*** BEGIN file-production ***/ -/* enumerations from "@filename@" */ -#include "@filename@" - -/*** END file-production ***/ - -/*** BEGIN value-header ***/ -GType -@enum_name@_get_type (void) -{ - static GType the_type = 0; - - if (the_type == 0) - { - static const G@Type@Value values[] = { -/*** END value-header ***/ - -/*** BEGIN value-production ***/ - { @VALUENAME@, - "@VALUENAME@", - "@valuenick@" }, -/*** END value-production ***/ - -/*** BEGIN value-tail ***/ - { 0, NULL, NULL } - }; - the_type = g_@type@_register_static ( - g_intern_static_string ("@EnumName@"), - values); - } - return the_type; -} - -/*** END value-tail ***/ - diff --git a/lib/applets-new/vala-applet-enums.h.template b/lib/applets-new/vala-applet-enums.h.template deleted file mode 100644 index 63c2274c..00000000 --- a/lib/applets-new/vala-applet-enums.h.template +++ /dev/null @@ -1,27 +0,0 @@ -/*** BEGIN file-header ***/ -#ifndef VALA_PANEL_ENUM_TYPES_H -#define VALA_PANEL_ENUM_TYPES_H - -#include - -G_BEGIN_DECLS - -/*** END file-header ***/ - -/*** BEGIN file-production ***/ -/* Enumerations from "@filename@" */ - -/*** END file-production ***/ - -/*** BEGIN enumeration-production ***/ -#define VALA_PANEL_TYPE_@ENUMSHORT@ (@enum_name@_get_type()) -GType @enum_name@_get_type (void) G_GNUC_CONST; - -/*** END enumeration-production ***/ - -/*** BEGIN file-tail ***/ -G_END_DECLS - -#endif /* VALA_PANEL_ENUM_TYPES_H */ -/*** END file-tail ***/ - diff --git a/lib/c-lib/CMakeLists.txt b/lib/c-lib/CMakeLists.txt deleted file mode 100644 index ce50303b..00000000 --- a/lib/c-lib/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -include(GResource) -set(ENUM_FILES - panel-platform.h - generic-config-dialog.h - toplevel.h - panel-layout.h - ) -add_glib_enumtypes(ENUMSC ENUMSH vala-panel-enums ${ENUM_FILES}) -add_library(cvalapanel SHARED - - panel-layout.h - panel-layout.c - toplevel.c - toplevel.h - applet-manager.c - applet-engine-module.c - private.h -# conf-gsettings.c -# conf-gsettings.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) -set_target_properties (cvalapanel PROPERTIES - VERSION ${VERSION} - SOVERSION ${SOVERSION}) -install (TARGETS cvalapanel DESTINATION ${CMAKE_INSTALL_LIBDIR}/${CMAKE_PROJECT_NAME}/ COMPONENT bin) diff --git a/lib/c-lib/applet-engine-module.c b/lib/c-lib/applet-engine-module.c deleted file mode 100644 index 59327ba1..00000000 --- a/lib/c-lib/applet-engine-module.c +++ /dev/null @@ -1,164 +0,0 @@ -#include "applet-engine-module.h" -#include - -struct _ValaPanelAppletEngineModule -{ - GTypeModule __parent__; - char *filename; - ValaPanelAppletEngine *engine; - GModule *library; - GType plugin_type; -}; - -G_DEFINE_TYPE(ValaPanelAppletEngineModule, vala_panel_applet_engine_module, G_TYPE_TYPE_MODULE) - -ValaPanelAppletEngineModule *vala_panel_applet_engine_module_new_from_ini(const char *filename) -{ - ValaPanelAppletEngineModule *module = NULL; - g_autoptr(GKeyFile) rc = g_key_file_new(); - g_autoptr(GError) err = NULL; - g_key_file_load_from_file(rc, filename, G_KEY_FILE_KEEP_COMMENTS, &err); - if (G_UNLIKELY(rc == NULL)) - { - g_critical("Unable to read plugin engine from desktop file \"%s\"", filename); - return NULL; - } - - if (!g_key_file_has_group(rc, MODULE_GROUP_NAME)) - { - g_critical( - "Desktop file \"%s\" has no " - "\"" MODULE_GROUP_NAME "\" group", - filename); - return NULL; - } - - /* read module location from the desktop file */ - g_autofree char *module_name = - g_key_file_get_string(rc, MODULE_GROUP_NAME, MODULE_NAME_STRING, NULL); - if (G_LIKELY(module_name != NULL)) - { - g_autofree char *path = g_module_build_path(CONFIG_PLUGINS_DIRECTORY, module_name); - bool found = g_file_test(path, G_FILE_TEST_EXISTS); - - if (G_LIKELY(found)) - { - /* create new module */ - module = g_object_new(vala_panel_applet_engine_module_get_type(), NULL); - module->filename = path; - } - else - g_critical("There was no module found at \"%s\"", path); - } - if (G_LIKELY(module != NULL)) - g_type_module_set_name(G_TYPE_MODULE(module), module_name); - - return module; -} - -ValaPanelAppletEngine *vala_panel_applet_engine_module_get_engine(ValaPanelAppletEngineModule *self) -{ - if (g_type_module_use(G_TYPE_MODULE(self))) - { - if (self->plugin_type != G_TYPE_NONE && !self->engine) - { - /* plugin is build as an object, to use its gtype */ - self->engine = g_object_new(self->plugin_type, NULL); - } - } - else - g_type_module_unuse(G_TYPE_MODULE(self)); - - return self->engine; -} - -void vala_panel_applet_engine_module_free_engine(ValaPanelAppletEngineModule *self) -{ - g_object_unref(self->engine); - self->engine = NULL; - g_type_module_unuse(G_TYPE_MODULE(self)); -} - -static void vala_panel_applet_engine_module_unload(GTypeModule *type_module) -{ - ValaPanelAppletEngineModule *module = VALA_PANEL_APPLET_ENGINE_MODULE(type_module); - vala_panel_applet_engine_module_free_engine(module); - g_module_close(module->library); - - /* reset plugin state */ - module->library = NULL; - module->plugin_type = G_TYPE_NONE; -} - -static bool vala_panel_applet_engine_module_load(GTypeModule *type_module) -{ - ValaPanelAppletEngineModule *module = VALA_PANEL_APPLET_ENGINE_MODULE(type_module); - ValaPanelAppletEngineInitFunc init_func; - bool make_resident = true; - - /* open the module */ - module->library = g_module_open(module->filename, G_MODULE_BIND_LOCAL); - if (G_UNLIKELY(module->library == NULL)) - { - g_critical("Failed to load module \"%s\": %s.", module->filename, g_module_error()); - return FALSE; - } - - /* try to link the contruct function */ - if (g_module_symbol(module->library, "vala_panel_module_init", (void **)&init_func)) - { - /* initialize the plugin */ - module->plugin_type = init_func(type_module, &make_resident); - - /* whether to make this plugin resident or not */ - if (make_resident) - g_module_make_resident(module->library); - } - else - { - g_critical("Module \"%s\" lacks a plugin register function.", module->filename); - - vala_panel_applet_engine_module_unload(type_module); - - return FALSE; - } - - return TRUE; -} -static void vala_panel_applet_engine_module_dispose(GObject *object) -{ - /* Do nothing to avoid problems with dispose in GTypeModule when - * types are registered. - * - * For us this is not a problem since the modules are released when - * everything is destroyed. So we really want that last unref before - * closing the application. */ -} -static void vala_panel_applet_engine_module_finalize(GTypeModule *type_module) -{ - ValaPanelAppletEngineModule *module = VALA_PANEL_APPLET_ENGINE_MODULE(type_module); - - g_free(module->filename); - - (*G_OBJECT_CLASS(vala_panel_applet_engine_module_parent_class)->finalize)(type_module); -} -static void vala_panel_applet_engine_module_init(ValaPanelAppletEngineModule *self) -{ - self->filename = NULL; - self->engine = NULL; - self->library = NULL; - self->plugin_type = G_TYPE_NONE; -} -static void vala_panel_applet_engine_module_class_init(ValaPanelAppletEngineModuleClass *klass) -{ - GObjectClass *gobject_class; - GTypeModuleClass *gtype_module_class; - - gobject_class = G_OBJECT_CLASS(klass); - gobject_class->dispose = vala_panel_applet_engine_module_dispose; - gobject_class->finalize = vala_panel_applet_engine_module_finalize; - - gtype_module_class = G_TYPE_MODULE_CLASS(klass); - gtype_module_class->load = vala_panel_applet_engine_module_load; - gtype_module_class->unload = vala_panel_applet_engine_module_unload; -} diff --git a/lib/c-lib/applet-engine-module.h b/lib/c-lib/applet-engine-module.h deleted file mode 100644 index 29bb6e32..00000000 --- a/lib/c-lib/applet-engine-module.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef APPLETENGINEMODULE_H -#define APPLETENGINEMODULE_H - -#include "lib/applets-new/applet-api.h" -#include "lib/config.h" -#include "lib/definitions.h" -#include -#include - -G_BEGIN_DECLS - -#define MODULE_GROUP_NAME "Vala Panel Engine" -#define MODULE_NAME_STRING "ModuleName" - -VALA_PANEL_DECLARE_MODULE_TYPE(ValaPanelAppletEngineModule, vala_panel_applet_engine_module, - VALA_PANEL, APPLET_ENGINE_MODULE, GTypeModule) - -ValaPanelAppletEngineModule *vala_panel_applet_engine_module_new_from_ini(const char *filename); -ValaPanelAppletEngine *vala_panel_applet_engine_module_get_engine( - ValaPanelAppletEngineModule *self); -void vala_panel_applet_engine_module_free_engine(ValaPanelAppletEngineModule *self); - -typedef GType (*ValaPanelAppletEngineInitFunc)(GTypeModule *module, bool *make_resident); - -G_END_DECLS - -#endif // APPLETENGINEMODULE_H diff --git a/lib/c-lib/applet-manager.c b/lib/c-lib/applet-manager.c deleted file mode 100644 index 2df78ebb..00000000 --- a/lib/c-lib/applet-manager.c +++ /dev/null @@ -1,112 +0,0 @@ -#include "applet-manager.h" -#include "applet-engine-module.h" -#include "lib/applets-new/applet-api.h" -#include "lib/definitions.h" -#include "private.h" - -#define PLUGIN_SETTINGS_SCHEMA_BASE "org.valapanel.toplevel.%s" - -struct _ValaPanelAppletManager -{ - ValaPanelPlatform *mgr; - char *profile; - GHashTable *available_engines; -}; - -G_DEFINE_TYPE(ValaPanelAppletManager, vala_panel_applet_manager, G_TYPE_OBJECT) - -void vala_panel_applet_manager_init(ValaPanelAppletManager *self) -{ - g_autoptr(GError) err = NULL; - g_autoptr(GDir) dir = g_dir_open(CONFIG_PLUGINS_DATA, 0, &err); - for (const char *file = g_dir_read_name(dir); file != NULL; file = g_dir_read_name(dir)) - { - ValaPanelAppletEngineModule *module = - vala_panel_applet_engine_module_new_from_ini(file); - g_hash_table_add(self->available_engines, module); - } -} - -void vala_panel_applet_manager_finalize(GObject *obj) -{ - ValaPanelAppletManager *module = VALA_PANEL_APPLET_MANAGER(obj); - - g_free(module->profile); - - (*G_OBJECT_CLASS(vala_panel_applet_manager_parent_class)->finalize)(obj); -} - -void vala_panel_applet_manager_class_init(ValaPanelAppletManagerClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - gobject_class->finalize = vala_panel_applet_manager_finalize; -} - -GSList *vala_panel_applet_manager_get_available_types(ValaPanelAppletManager *self) -{ - GSList *available_types = NULL; - GHashTableIter iter; - gpointer key, value; - g_hash_table_iter_init(&iter, self->available_engines); - while (g_hash_table_iter_next(&iter, &key, &value)) - { - GSList *engine_types = - vala_panel_applet_engine_get_available_types((ValaPanelAppletEngine *)key); - available_types = g_slist_concat(available_types, engine_types); - } - return available_types; -} - -ValaPanelAppletInfo *vala_panel_applet_manager_get_applet_info_for_type( - ValaPanelAppletManager *self, const char *applet_type) -{ - GHashTableIter iter; - gpointer key, value; - g_hash_table_iter_init(&iter, self->available_engines); - while (g_hash_table_iter_next(&iter, &key, &value)) - { - ValaPanelAppletInfo *info = - vala_panel_applet_engine_get_applet_info_for_type((ValaPanelAppletEngine *)key, - applet_type); - if (info) - return info; - } - return NULL; -} - -ValaPanelAppletWidget *vala_panel_applet_manager_get_applet_widget_for_type( - ValaPanelAppletManager *self, const char *path, const char *applet_type, const char *uuid) -{ - GHashTableIter iter; - gpointer key, value; - g_hash_table_iter_init(&iter, self->available_engines); - while (g_hash_table_iter_next(&iter, &key, &value)) - { - g_autofree char *scheme = g_strdup_printf(PLUGIN_SETTINGS_SCHEMA_BASE, applet_type); - g_autofree char *cpath = g_strconcat(path, uuid, "/", NULL); - GSettings *settings = - vala_panel_platform_get_settings_for_scheme(self->mgr, scheme, cpath); - ValaPanelAppletWidget *widget = - vala_panel_applet_engine_get_applet_widget_for_type((ValaPanelAppletEngine *) - key, - applet_type, - settings, - uuid); - if (widget) - return widget; - } - return NULL; -} - -ValaPanelAppletManager *vala_panel_applet_manager_new(ValaPanelPlatform *mgr) -{ - ValaPanelAppletManager *ret = - VALA_PANEL_APPLET_MANAGER(g_object_new(vala_panel_applet_manager_get_type(), NULL)); - ret->mgr = mgr; - return ret; -} - -ValaPanelPlatform *vala_panel_applet_manager_get_manager(ValaPanelAppletManager *self) -{ - return self->mgr; -} diff --git a/lib/c-lib/applet-manager.h b/lib/c-lib/applet-manager.h deleted file mode 100644 index 46ac024a..00000000 --- a/lib/c-lib/applet-manager.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef APPLETMANAGER_C -#define APPLETMANAGER_C - -#include "lib/config.h" - -#include "applet-engine-module.h" -#include "lib/applets-new/applet-api.h" -#include "lib/panel-platform.h" -#include - -G_BEGIN_DECLS - -G_DECLARE_FINAL_TYPE(ValaPanelAppletManager, vala_panel_applet_manager, VALA_PANEL, APPLET_MANAGER, - GObject) - -ValaPanelAppletManager *vala_panel_applet_manager_new(ValaPanelPlatform *mgr); -GSList *vala_panel_applet_manager_get_available_types(ValaPanelAppletManager *self); -ValaPanelAppletInfo *vala_panel_applet_manager_get_applet_info_for_type( - ValaPanelAppletManager *self, const char *applet_type); -ValaPanelAppletWidget *vala_panel_applet_manager_get_applet_widget_for_type( - ValaPanelAppletManager *self, const char *path, const char *applet_type, const char *uuid); -ValaPanelPlatform *vala_panel_applet_manager_get_manager(ValaPanelAppletManager *self); - -G_END_DECLS - -#endif // APPLETMANAGER_C diff --git a/lib/c-lib/panel-layout.c b/lib/c-lib/panel-layout.c deleted file mode 100644 index 4a41b439..00000000 --- a/lib/c-lib/panel-layout.c +++ /dev/null @@ -1,158 +0,0 @@ -#include "panel-layout.h" -#include "lib/applets-new/applet-api.h" -#include "lib/settings-manager.h" - -struct _ValaPanelAppletLayout -{ - GtkBox __parent__; - GtkWidget *center; - int width; - int height; - bool is_dynamic_height; - bool is_dynamic_width; -}; - -G_DEFINE_TYPE(ValaPanelAppletLayout, vala_panel_applet_layout, GTK_TYPE_BOX) - -#define vala_panel_applet_layout_place_applet_widget(self, applet, pack, pos) \ - { \ - if (pack == PACK_START) \ - { \ - gtk_box_pack_start(GTK_BOX(self), applet, false, true, 0); \ - gtk_box_reorder_child(GTK_BOX(self), applet, pos); \ - } \ - else if (pack == PACK_END) \ - { \ - gtk_box_pack_end(GTK_BOX(self), applet, false, true, 0); \ - gtk_box_reorder_child(GTK_BOX(self), applet, pos); \ - } \ - else if (pack == PACK_CENTER) \ - { \ - gtk_box_pack_start(GTK_BOX(self->center), applet, false, true, 0); \ - gtk_box_reorder_child(GTK_BOX(self->center), applet, pos); \ - } \ - } - -static void vala_panel_applet_layout_get_preferred_height(GtkWidget *widget, gint *minimum_height, - gint *natural_height) -{ - ValaPanelAppletLayout *self = VALA_PANEL_APPLET_LAYOUT(widget); - GtkOrientation orient = gtk_orientable_get_orientation(GTK_ORIENTABLE(self)); - if (self->is_dynamic_height) - GTK_WIDGET_CLASS(vala_panel_applet_layout_parent_class) - ->get_preferred_height(widget, minimum_height, natural_height); - else - *minimum_height = *natural_height = - (orient == GTK_ORIENTATION_VERTICAL) ? self->width : self->height; -} - -static void vala_panel_applet_layout_get_preferred_width(GtkWidget *widget, gint *minimum_height, - gint *natural_height) -{ - ValaPanelAppletLayout *self = VALA_PANEL_APPLET_LAYOUT(widget); - GtkOrientation orient = gtk_orientable_get_orientation(GTK_ORIENTABLE(self)); - if (self->is_dynamic_width) - GTK_WIDGET_CLASS(vala_panel_applet_layout_parent_class) - ->get_preferred_width(widget, minimum_height, natural_height); - else - *minimum_height = *natural_height = - (orient == GTK_ORIENTATION_HORIZONTAL) ? self->width : self->height; -} - -static void vala_panel_applet_layout_init(ValaPanelAppletLayout *self) -{ - self->center = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); - g_object_bind_property(self, "orientation", self->center, "orientation", (GBindingFlags)0); - gtk_box_set_center_widget(GTK_BOX(self), self->center); -} - -static void vala_panel_applet_layout_class_init(ValaPanelAppletLayoutClass *klass) -{ - GTK_WIDGET_CLASS(klass)->get_preferred_height = - vala_panel_applet_layout_get_preferred_height; - GTK_WIDGET_CLASS(klass)->get_preferred_width = vala_panel_applet_layout_get_preferred_width; -} - -static void update_applet_positions(ValaPanelAppletLayout *self) -{ - g_autoptr(GList) c_c = gtk_container_get_children(GTK_CONTAINER(self)); - for (GList *l = c_c; l != NULL; l = g_list_next(l)) - { - int idx = vala_panel_applet_get_position_metadata(G_OBJECT(l->data)); - gtk_box_reorder_child(GTK_BOX(self), GTK_WIDGET(l->data), idx); - } -} - -void vala_panel_applet_layout_update_views(ValaPanelAppletLayout *self) -{ - g_autoptr(GList) ch = gtk_container_get_children(GTK_CONTAINER(self->center)); - if (g_list_length(ch) <= 0) - gtk_widget_hide(GTK_WIDGET(self->center)); - else - gtk_widget_show(GTK_WIDGET(self->center)); -} - -void vala_panel_applet_layout_place_applet(ValaPanelAppletLayout *self, ValaPanelPlatform *gmgr, - GSettings *toplevel_settings, - ValaPanelAppletManager *mgr, const char *applet_type, - PanelAppletPackType pack, int pos) -{ - g_autofree char *uid = vala_panel_generate_new_hash(); - g_autofree char *path = NULL; - g_object_get(toplevel_settings, "path", &path, NULL); - g_autofree char *cpath = g_strconcat(path, uid, "/", NULL); - GtkWidget *applet = GTK_WIDGET( - vala_panel_applet_manager_get_applet_widget_for_type(mgr, path, applet_type, uid)); - GSettings *csettings = - vala_panel_platform_get_settings_for_scheme(gmgr, DEFAULT_PLUGIN_SETTINGS_ID, cpath); - g_settings_set_int(csettings, VALA_PANEL_KEY_POSITION, pos); - g_settings_set_string(csettings, VALA_PANEL_KEY_NAME, applet_type); - g_settings_set_enum(csettings, VALA_PANEL_KEY_PACK, pack); - vala_panel_applet_set_position_metadata(applet, pos); - vala_panel_applet_layout_place_applet_widget(self, applet, pack, pos); - vala_panel_applet_layout_update_views(self); -} - -void vala_panel_applet_layout_load_applets(ValaPanelAppletLayout *self, ValaPanelAppletManager *mgr, - GSettings *settings) -{ - g_auto(GStrv) children = g_settings_list_children(settings); - for (int i = 0; children[i] != NULL; i++) - { - g_autoptr(GSettings) csettings = g_settings_get_child(settings, children[i]); - g_autofree char *applet_type = - g_settings_get_string(csettings, VALA_PANEL_KEY_NAME); - g_autofree char *path = NULL; - g_object_get(settings, "path", &path, NULL); - GtkWidget *applet = - GTK_WIDGET(vala_panel_applet_manager_get_applet_widget_for_type(mgr, - path, - applet_type, - children[i])); - PanelAppletPackType pack = - (PanelAppletPackType)g_settings_get_enum(csettings, VALA_PANEL_KEY_PACK); - int pos = g_settings_get_int(csettings, VALA_PANEL_KEY_POSITION); - vala_panel_applet_set_position_metadata(applet, pos); - vala_panel_applet_layout_place_applet_widget(self, applet, pack, pos); - } - update_applet_positions(self); - vala_panel_applet_layout_update_views(self); -} - -ValaPanelAppletLayout *vala_panel_applet_layout_new(GtkOrientation orient, int spacing) -{ - return VALA_PANEL_APPLET_LAYOUT(g_object_new(vala_panel_applet_layout_get_type(), - "orientation", - orient, - "spacing", - spacing, - "baseline-position", - GTK_BASELINE_POSITION_CENTER, - "border-width", - 0, - "hexpand", - true, - "vexpand", - true, - NULL)); -} diff --git a/lib/c-lib/panel-layout.h b/lib/c-lib/panel-layout.h deleted file mode 100644 index 1c5b42d6..00000000 --- a/lib/c-lib/panel-layout.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef PANELLAYOUT_H -#define PANELLAYOUT_H - -#include -#include -#include - -#include "applet-manager.h" -#include "lib/misc.h" - -G_BEGIN_DECLS - -typedef enum { - PACK_START = 0, - PACK_CENTER = 2, - PACK_END = 1, -} PanelAppletPackType; - -#define vala_panel_applet_set_position_metadata(applet, pos) \ - g_object_set_qdata(G_OBJECT(applet), \ - g_quark_from_static_string("position"), \ - GINT_TO_POINTER(pos)); - -#define vala_panel_applet_get_position_metadata(applet) \ - GPOINTER_TO_INT( \ - g_object_get_qdata(G_OBJECT(applet), g_quark_from_static_string("position"))); - -G_DECLARE_FINAL_TYPE(ValaPanelAppletLayout, vala_panel_applet_layout, VALA_PANEL, APPLET_LAYOUT, - GtkBox) - -ValaPanelAppletLayout *vala_panel_applet_layout_new(GtkOrientation orient, int spacing); -void vala_panel_applet_layout_update_views(ValaPanelAppletLayout *self); -void vala_panel_applet_layout_place_applet(ValaPanelAppletLayout *self, ValaPanelPlatform *gmgr, - GSettings *toplevel_settings, - ValaPanelAppletManager *mgr, const char *applet_type, - PanelAppletPackType pack, int pos); -void vala_panel_applet_layout_load_applets(ValaPanelAppletLayout *self, ValaPanelAppletManager *mgr, - GSettings *settings); - -G_END_DECLS - -#endif // PANELLAYOUT_H diff --git a/lib/c-lib/private.h b/lib/c-lib/private.h deleted file mode 100644 index ca49e00c..00000000 --- a/lib/c-lib/private.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef APPLETSPRIVATE_H -#define APPLETSPRIVATE_H -#include "lib/applets-new/applet-api.h" - -GSList *vala_panel_applet_engine_get_available_types(ValaPanelAppletEngine *self); -ValaPanelAppletInfo *vala_panel_applet_engine_get_applet_info_for_type(ValaPanelAppletEngine *self, - const char *applet_type); -ValaPanelAppletWidget *vala_panel_applet_engine_get_applet_widget_for_type( - ValaPanelAppletEngine *self, const char *applet_type, GSettings *settings, const char *uuid); -bool vala_panel_applet_engine_contains_applet(ValaPanelAppletEngine *self, const char *applet_type); - -#endif // APPLETSPRIVATE_H diff --git a/lib/c-lib/toplevel.c b/lib/c-lib/toplevel.c deleted file mode 100644 index f44c881b..00000000 --- a/lib/c-lib/toplevel.c +++ /dev/null @@ -1,640 +0,0 @@ -#include "toplevel.h" -#include "css.h" -#include "misc.h" -#include "panel-layout.h" -#include "panel-platform.h" - -static const int PERIOD = 200; - -static void activate_new_panel(GSimpleAction *act, GVariant *param, void *data); -static void activate_remove_panel(GSimpleAction *act, GVariant *param, void *data); -static void activate_panel_settings(GSimpleAction *act, GVariant *param, void *data); - -static const GActionEntry panel_entries[] = - { { "new-panel", activate_new_panel, NULL, NULL, NULL, { 0 } }, - { "remove-panel", activate_remove_panel, NULL, NULL, NULL, { 0 } }, - { "panel-settings", activate_panel_settings, "s", NULL, NULL, { 0 } } }; - -struct _ValaPanelToplevelUnit -{ - GtkApplicationWindow __parent__; - ValaPanelAppletManager *manager; - ValaPanelAppletLayout *layout; - GtkRevealer *ah_rev; - GtkSeparator *ah_sep; - PanelAutohideState ah_state; - GSettings *toplevel_settings; - GtkCssProvider *provider; - bool initialized; - bool dock; - bool autohide; - bool use_background_color; - bool use_foreground_color; - bool use_background_file; - bool use_font; - bool font_size_only; - uint round_corners_size; - GdkRGBA background_color; - GdkRGBA foreground_color; - char *background_file; - char *uid; - int mon; - GtkOrientation orientation; - GtkPositionType edge; - GtkDialog *pref_dialog; - char *font; -}; - -G_DEFINE_TYPE(ValaPanelToplevelUnit, vala_panel_toplevel_unit, GTK_TYPE_APPLICATION_WINDOW) - -static void stop_ui(ValaPanelToplevelUnit *self) -{ - if (self->pref_dialog != NULL) - gtk_dialog_response(self->pref_dialog, GTK_RESPONSE_CLOSE); - if (self->initialized) - { - gdk_flush(); - self->initialized = false; - } - if (gtk_bin_get_child(GTK_BIN(self))) - { - gtk_widget_hide(GTK_WIDGET(self->layout)); - } -} - -static void start_ui(ValaPanelToplevelUnit *self) -{ - // a.x = a.y = a.width = a.height = 0; - gtk_window_set_wmclass(GTK_WINDOW(self), "panel", "vala-panel"); - gtk_application_add_window(gtk_window_get_application(GTK_WINDOW(self)), GTK_WINDOW(self)); - gtk_widget_add_events(GTK_WIDGET(self), - GDK_BUTTON_PRESS_MASK | GDK_ENTER_NOTIFY_MASK | - GDK_LEAVE_NOTIFY_MASK); - gtk_widget_realize(GTK_WIDGET(self)); - gtk_window_set_type_hint(GTK_WINDOW(self), - (self->dock) ? GDK_WINDOW_TYPE_HINT_DOCK - : GDK_WINDOW_TYPE_HINT_NORMAL); - gtk_widget_show(GTK_WIDGET(self)); - gtk_window_stick(GTK_WINDOW(self)); - vala_panel_applet_layout_load_applets(self->layout, self->manager, self->toplevel_settings); - gtk_window_present(GTK_WINDOW(self)); - self->autohide = g_settings_get_boolean(self->toplevel_settings, VALA_PANEL_KEY_AUTOHIDE); - self->initialized = true; -} - -static void setup(ValaPanelToplevelUnit *self, bool use_internal_values) -{ - if (use_internal_values) - { - g_settings_set_int(self->toplevel_settings, VALA_PANEL_KEY_MONITOR, self->mon); - g_settings_set_enum(self->toplevel_settings, VALA_PANEL_KEY_EDGE, self->edge); - } - vala_panel_add_gsettings_as_action(G_ACTION_MAP(self), - self->toplevel_settings, - VALA_PANEL_KEY_EDGE); - vala_panel_add_gsettings_as_action(G_ACTION_MAP(self), - self->toplevel_settings, - VALA_PANEL_KEY_ALIGNMENT); - vala_panel_add_gsettings_as_action(G_ACTION_MAP(self), - self->toplevel_settings, - VALA_PANEL_KEY_HEIGHT); - vala_panel_add_gsettings_as_action(G_ACTION_MAP(self), - self->toplevel_settings, - VALA_PANEL_KEY_WIDTH); - vala_panel_add_gsettings_as_action(G_ACTION_MAP(self), - self->toplevel_settings, - VALA_PANEL_KEY_DYNAMIC); - vala_panel_add_gsettings_as_action(G_ACTION_MAP(self), - self->toplevel_settings, - VALA_PANEL_KEY_AUTOHIDE); - vala_panel_add_gsettings_as_action(G_ACTION_MAP(self), - self->toplevel_settings, - VALA_PANEL_KEY_STRUT); - vala_panel_add_gsettings_as_action(G_ACTION_MAP(self), - self->toplevel_settings, - VALA_PANEL_KEY_DOCK); - vala_panel_add_gsettings_as_action(G_ACTION_MAP(self), - self->toplevel_settings, - VALA_PANEL_KEY_MARGIN); - vala_panel_bind_gsettings(self, self->toplevel_settings, VALA_PANEL_KEY_MONITOR); - vala_panel_add_gsettings_as_action(G_ACTION_MAP(self), - self->toplevel_settings, - VALA_PANEL_KEY_SHOW_HIDDEN); - vala_panel_add_gsettings_as_action(G_ACTION_MAP(self), - self->toplevel_settings, - VALA_PANEL_KEY_ICON_SIZE); - vala_panel_add_gsettings_as_action(G_ACTION_MAP(self), - self->toplevel_settings, - VALA_PANEL_KEY_BACKGROUND_COLOR); - vala_panel_add_gsettings_as_action(G_ACTION_MAP(self), - self->toplevel_settings, - VALA_PANEL_KEY_FOREGROUND_COLOR); - vala_panel_add_gsettings_as_action(G_ACTION_MAP(self), - self->toplevel_settings, - VALA_PANEL_KEY_BACKGROUND_FILE); - vala_panel_add_gsettings_as_action(G_ACTION_MAP(self), - self->toplevel_settings, - VALA_PANEL_KEY_FONT); - vala_panel_add_gsettings_as_action(G_ACTION_MAP(self), - self->toplevel_settings, - VALA_PANEL_KEY_CORNERS_SIZE); - vala_panel_add_gsettings_as_action(G_ACTION_MAP(self), - self->toplevel_settings, - VALA_PANEL_KEY_FONT_SIZE_ONLY); - vala_panel_add_gsettings_as_action(G_ACTION_MAP(self), - self->toplevel_settings, - VALA_PANEL_KEY_USE_BACKGROUND_COLOR); - vala_panel_add_gsettings_as_action(G_ACTION_MAP(self), - self->toplevel_settings, - VALA_PANEL_KEY_USE_FOREGROUND_COLOR); - vala_panel_add_gsettings_as_action(G_ACTION_MAP(self), - self->toplevel_settings, - VALA_PANEL_KEY_USE_FONT); - vala_panel_add_gsettings_as_action(G_ACTION_MAP(self), - self->toplevel_settings, - VALA_PANEL_KEY_USE_BACKGROUND_FILE); - if (self->mon < gdk_screen_get_n_monitors(gtk_widget_get_screen(GTK_WIDGET(self)))) - start_ui(self); -} - -G_GNUC_INTERNAL bool panel_edge_available(ValaPanelToplevelUnit *self, uint edge, int monitor, - bool include_this) -{ - g_autoptr(GtkApplication) app; - g_object_get(self, "application", &app, NULL); - for (g_autoptr(GList) w = gtk_application_get_windows(app); w != NULL; w = w->next) - if (VALA_PANEL_IS_TOPLEVEL_UNIT(w)) - { - ValaPanelToplevelUnit *pl = VALA_PANEL_TOPLEVEL_UNIT(w->data); - if (((pl != self) || include_this) && (self->edge == edge) && - ((monitor == self->mon) || self->mon < 0)) - return false; - } - return true; -} - -static void activate_new_panel(GSimpleAction *act, GVariant *param, void *data) -{ - ValaPanelToplevelUnit *self = VALA_PANEL_TOPLEVEL_UNIT(data); - int new_mon = -2; - GtkPositionType new_edge = GTK_POS_TOP; - bool found = false; - /* Allocate the edge. */ - g_assert(gtk_widget_get_screen(GTK_WIDGET(self)) != NULL); - int monitors = gdk_screen_get_n_monitors(gtk_widget_get_screen(GTK_WIDGET(self))); - /* try to allocate edge on current monitor first */ - int m = self->mon; - if (m < 0) - { - /* panel is spanned over the screen, guess from pointer now */ - int x, y; - GdkScreen *scr; - GdkDevice *dev; -#if GTK_CHECK_VERSION(3, 20, 0) - GdkSeat *seat = gdk_display_get_default_seat( - gdk_screen_get_display(gtk_widget_get_screen(GTK_WIDGET(self)))); - dev = gdk_seat_get_pointer(seat); -#else - GdkDeviceManager *manager = gdk_display_get_device_manager( - gdk_screen_get_display(gtk_widget_get_screen(GTK_WIDGET(self)))); - dev = gdk_device_manager_get_client_pointer(manager); -#endif - gdk_device_get_position(dev, &scr, &x, &y); - m = gdk_screen_get_monitor_at_point(scr, x, y); - } - for (int e = GTK_POS_BOTTOM; e >= GTK_POS_LEFT; e--) - { - if (panel_edge_available(self, (GtkPositionType)e, m, true)) - { - new_edge = (GtkPositionType)e; - new_mon = m; - found = true; - } - } - /* try all monitors */ - if (!found) - for (m = 0; m < monitors; ++m) - { - /* try each of the four edges */ - for (int e = GTK_POS_BOTTOM; e >= GTK_POS_LEFT; e--) - { - if (panel_edge_available(self, (GtkPositionType)e, m, true)) - { - new_edge = (GtkPositionType)e; - new_mon = m; - found = true; - } - } - } - if (!found) - { - g_warning( - "Error adding panel: There is no room for another panel. All the edges are " - "taken."); - g_autoptr(GtkWidget) msg = gtk_message_dialog_new( - GTK_WINDOW(self), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - N_("There is no room for another panel. All the edges are taken.")); - vala_panel_apply_window_icon(GTK_WINDOW(msg)); - gtk_window_set_title(GTK_WINDOW(msg), _("Error")); - gtk_dialog_run(GTK_DIALOG(msg)); - gtk_widget_destroy(GTK_WIDGET(msg)); - return; - } - g_autofree char *new_name = vala_panel_generate_new_hash(); - // FIXME: Translate after adding constructors - // ValaPanelToplevelUnit* new_toplevel = - // Toplevel.create(application,new_name,new_mon,new_edge); - // new_toplevel.configure("position"); - // new_toplevel.show_all(); - // new_toplevel.queue_draw(); -} -static void activate_remove_panel(GSimpleAction *act, GVariant *param, void *data) -{ - ValaPanelToplevelUnit *self = VALA_PANEL_TOPLEVEL_UNIT(data); - g_autoptr(GtkMessageDialog) dlg = GTK_MESSAGE_DIALOG( - gtk_message_dialog_new_with_markup(GTK_WINDOW(self), - GTK_DIALOG_MODAL, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_OK_CANCEL, - N_("Really delete this panel?\nWarning:" - "This can not be recovered."))); - vala_panel_apply_window_icon(GTK_WINDOW(dlg)); - gtk_window_set_title(GTK_WINDOW(dlg), _("Confirm")); - bool ok = (gtk_dialog_run(GTK_DIALOG(dlg)) == GTK_RESPONSE_OK); - gtk_widget_destroy(GTK_WIDGET(dlg)); - if (ok) - { - g_autofree char *uid = g_strdup(self->uid); - g_autofree char *path = NULL; - g_object_get(self->toplevel_settings, "path", &path, NULL); - ValaPanelPlatform *mgr = vala_panel_applet_manager_get_manager(self->manager); - stop_ui(self); - gtk_widget_destroy(GTK_WIDGET(self)); - /* delete the config file of this panel */ - vala_panel_platform_remove_settings_path(mgr, path, uid); - } -} -static void activate_panel_settings(GSimpleAction *act, GVariant *param, void *data) -{ - // this.configure(param.get_string()); -} - -G_GNUC_INTERNAL void update_appearance(ValaPanelToplevelUnit *self) -{ - if (self->provider) - gtk_style_context_remove_provider(gtk_widget_get_style_context(GTK_WIDGET(self)), - GTK_STYLE_PROVIDER(self->provider)); - if (!self->font) - return; - g_autoptr(GString) str = g_string_new(""); - g_autofree char *background_color = gdk_rgba_to_string(&self->background_color); - g_string_append_printf(str, ".-vala-panel-background {\n"); - if (self->use_background_color) - g_string_append_printf(str, " background-color: %s;\n", background_color); - else - g_string_append_printf(str, " background-color: transparent;\n"); - if (self->use_background_file) - { - g_string_append_printf(str, - " background-image: url('%s');\n", - self->background_file); - /* Feature proposed: Background repeat */ - //~ if (false) - //~ g_string_append_printf(str," background-repeat: - // no-repeat;\n"); - } - else - g_string_append_printf(str, " background-image: none;\n"); - g_string_append_printf(str, "}\n"); - /* Feature proposed: Panel Layout and Shadow */ - //~ g_string_append_printf(str,".-vala-panel-shadow {\n"); - //~ g_string_append_printf(str," box-shadow: 0 0 0 3px alpha(0.3, - //%s);\n",foreground_color); - //~ g_string_append_printf(str," border-style: none;\n margin: 3px;\n"); - //~ g_string_append_printf(str,"}\n"); - g_string_append_printf(str, ".-vala-panel-round-corners {\n"); - g_string_append_printf(str, " border-radius: %upx;\n", self->round_corners_size); - g_string_append_printf(str, "}\n"); - PangoFontDescription *desc = pango_font_description_from_string(self->font); - g_string_append_printf(str, ".-vala-panel-font-size {\n"); - g_string_append_printf(str, - " font-size: %dpx;\n", - pango_font_description_get_size(desc) / PANGO_SCALE); - g_string_append_printf(str, "}\n"); - g_string_append_printf(str, ".-vala-panel-font {\n"); - const char *family = pango_font_description_get_family(desc); - PangoWeight weight = pango_font_description_get_weight(desc); - PangoStyle style = pango_font_description_get_style(desc); - PangoVariant variant = pango_font_description_get_variant(desc); - g_string_append_printf(str, - " font-style: %s;\n", - (style == PANGO_STYLE_ITALIC) - ? "italic" - : ((style == PANGO_STYLE_OBLIQUE) ? "oblique" : "normal")); - g_string_append_printf(str, - " font-variant: %s;\n", - (variant == PANGO_VARIANT_SMALL_CAPS) ? "small-caps" : "normal"); - g_string_append_printf(str, - " font-weight: %s;\n", - (weight <= PANGO_WEIGHT_SEMILIGHT) - ? "light" - : (weight >= PANGO_WEIGHT_SEMIBOLD ? "bold" : "normal")); - g_string_append_printf(str, " font-family: %s;\n", family); - g_string_append_printf(str, "}\n"); - g_string_append_printf(str, ".-vala-panel-foreground-color {\n"); - g_autofree char *foreground_color = gdk_rgba_to_string(&self->foreground_color); - g_string_append_printf(str, " color: %s;\n", foreground_color); - g_string_append_printf(str, "}\n"); - g_autofree char *css = str->str; - self->provider = css_add_css_to_widget(GTK_WIDGET(self), css); - css_toggle_class(GTK_WIDGET(self), - "-vala-panel-background", - self->use_background_color || self->use_background_file); - css_toggle_class(GTK_WIDGET(self), "-vala-panel-shadow", false); - css_toggle_class(GTK_WIDGET(self), - "-vala-panel-round-corners", - self->round_corners_size > 0); - css_toggle_class(GTK_WIDGET(self), "-vala-panel-font-size", self->use_font); - css_toggle_class(GTK_WIDGET(self), - "-vala-panel-font", - self->use_font && !self->font_size_only); - css_toggle_class(GTK_WIDGET(self), - "-vala-panel-foreground-color", - self->use_foreground_color); -} - -ValaPanelToplevelUnit *vala_panel_toplevel_unit_new_from_position(GtkApplication *app, - const char *uid, int mon, - GtkPositionType edge) -{ - ValaPanelToplevelUnit *ret = - VALA_PANEL_TOPLEVEL_UNIT(g_object_new(vala_panel_toplevel_unit_get_type(), - "border-width", - 0, - "decorated", - false, - "name", - "ValaPanel", - "resizable", - false, - "title", - "ValaPanel", - "type-hint", - GDK_WINDOW_TYPE_HINT_DOCK, - "window-position", - GTK_WIN_POS_NONE, - "skip-taskbar-hint", - true, - "skip-pager-hint", - true, - "accept-focus", - false, - "application", - app, - "uuid", - uid)); - ret->mon = mon; - ret->edge = edge; - setup(ret, true); - return ret; -} -ValaPanelToplevelUnit *vala_panel_toplevel_unit_new_from_uid(GtkApplication *app, char *uid) -{ - ValaPanelToplevelUnit *ret = - VALA_PANEL_TOPLEVEL_UNIT(g_object_new(vala_panel_toplevel_unit_get_type(), - "border-width", - 0, - "decorated", - false, - "name", - "ValaPanel", - "resizable", - false, - "title", - "ValaPanel", - "type-hint", - GDK_WINDOW_TYPE_HINT_DOCK, - "window-position", - GTK_WIN_POS_NONE, - "skip-taskbar-hint", - true, - "skip-pager-hint", - true, - "accept-focus", - false, - "application", - app, - "uuid", - uid)); - setup(ret, false); - return ret; -} - -// static void size_allocate(GtkWidget *base, GtkAllocation *alloc) -//{ -// int x, y, w; -// GTK_WIDGET_CLASS(vala_panel_toplevel_unit_parent_class)->size_allocate(base, alloc); -// ValaPanelToplevelUnit *self = VALA_PANEL_TOPLEVEL_UNIT(base); -// if (self->is_dynamic && self->layout != NULL) -// { -// if (self->orientation == GTK_ORIENTATION_HORIZONTAL) -// gtk_widget_get_preferred_width(GTK_WIDGET(self->layout), NULL, &w); -// else -// gtk_widget_get_preferred_height(GTK_WIDGET(self->layout), NULL, &w); -// if (w != self->width) -// g_settings_set_int(self->toplevel_settings, VALA_PANEL_KEY_WIDTH, w); -// } -// if (!gtk_widget_get_realized(GTK_WIDGET(self))) -// return; -// gdk_window_get_origin(gtk_widget_get_window(GTK_WIDGET(self)), &x, &y); -// // _calculate_position (&alloc); -// // this.a.x = alloc.x; -// // this.a.y = alloc.y; -// // if (alloc.width != this.a.width || alloc.height != this.a.height || this.a.x != x || -// // this.a.y != y) -// // { -// // this.a.width = alloc.width; -// // this.a.height = alloc.height; -// // this.set_size_request(this.a.width, this.a.height); -// // this.move(this.a.x, this.a.y); -// // this.update_strut(); -// // } -// if (gtk_widget_get_mapped(GTK_WIDGET(self))) -// establish_autohide(self); -//} - -// void _calculate_position(ref Gtk.Allocation alloc) -//{ -// unowned Gdk.Screen screen = this.get_screen(); -// Gdk.Rectangle marea = Gdk.Rectangle(); -// if (monitor < 0) -// { -// marea.x = 0; -// marea.y = 0; -// marea.width = screen.get_width(); -// marea.height = screen.get_height(); -// } -// else if (monitor < screen.get_n_monitors()) -// { -// screen.get_monitor_geometry(monitor,&marea); -////~ marea = screen.get_monitor_workarea(monitor); -////~ var hmod = (autohide && show_hidden) ? 1 : height; -////~ switch (edge) -////~ { -////~ case PositionType.TOP: -////~ marea.x -= hmod; -////~ marea.height += hmod; -////~ break; -////~ case PositionType.BOTTOM: -////~ marea.height += hmod; -////~ break; -////~ case PositionType.LEFT: -////~ marea.y -= hmod; -////~ marea.width += hmod; -////~ break; -////~ case PositionType.RIGHT: -////~ marea.width += hmod; -////~ break; -////~ } -// } -// if (orientation == GTK_ORIENTATION_HORIZONTAL) -// { -// alloc.width = width; -// alloc.x = marea.x; -// calculate_width(marea.width,is_dynamic,alignment,panel_margin,ref alloc.width, ref -// alloc.x); -// alloc.height = (!autohide || ah_visible) ? height : -// show_hidden ? 1 : 0; -// alloc.y = marea.y + ((edge == Gtk.PositionType.TOP) ? 0 : (marea.height - alloc.height)); -// } -// else -// { -// alloc.height = width; -// alloc.y = marea.y; -// calculate_width(marea.height,is_dynamic,alignment,panel_margin,ref alloc.height, ref -// alloc.y); -// alloc.width = (!autohide || ah_visible) ? height : -// show_hidden ? 1 : 0; -// alloc.x = marea.x + ((edge == Gtk.PositionType.LEFT) ? 0 : (marea.width - alloc.width)); -// } -//} - -// static void calculate_width(int scrw, bool dyn, AlignmentType align, -// int margin, ref int panw, ref int x) -//{ -// if (!dyn) -// { -// panw = (panw >= 100) ? 100 : (panw <= 1) ? 1 : panw; -// panw = (int)(((double)scrw * (double) panw)/100.0); -// } -// margin = (align != AlignmentType.CENTER && margin > scrw) ? 0 : margin; -// panw = int.min(scrw - margin, panw); -// if (align == AlignmentType.START) -// x+=margin; -// else if (align == AlignmentType.END) -// { -// x += scrw - panw - margin; -// x = (x < 0) ? 0 : x; -// } -// else if (align == AlignmentType.CENTER) -// x += (scrw - panw)/2; -//} - -// static void get_preferred_width(&int min, &int nat) -//{ -// base.get_preferred_width_internal(&min, &nat); -// Gtk.Requisition req = Gtk.Requisition(); -// this.get_panel_preferred_size(ref req); -// min = nat = req.width; -//} -// static void get_preferred_height(&int min, &int nat) -//{ -// base.get_preferred_height_internal(&min, &nat); -// Gtk.Requisition req = Gtk.Requisition(); -// this.get_panel_preferred_size(ref req); -// min = nat = req.height; -//} -// static void get_panel_preferred_size (ref Gtk.Requisition min) -//{ -// if (!ah_visible && box != NULL) -// box.get_preferred_size(&min, NULL); -// var rect = Gtk.Allocation(); -// rect.width = min.width; -// rect.height = min.height; -// _calculate_position(ref rect); -// min.width = rect.width; -// min.height = rect.height; -//} - -/**************************************************** - * autohide : new version * - ****************************************************/ -static bool timeout_func(ValaPanelToplevelUnit *self) -{ - if (self->autohide && self->ah_state == AH_WAITING) - { - css_toggle_class(GTK_WIDGET(self), "-panel-transparent", true); - gtk_revealer_set_reveal_child(self->ah_rev, false); - self->ah_state = AH_HIDDEN; - } - return false; -} - -static void ah_show(ValaPanelToplevelUnit *self) -{ - css_toggle_class(GTK_WIDGET(self), "-panel-transparent", false); - gtk_revealer_set_reveal_child(self->ah_rev, true); - self->ah_state = AH_VISIBLE; -} - -static void ah_hide(ValaPanelToplevelUnit *self) -{ - self->ah_state = AH_WAITING; - g_timeout_add(PERIOD, (GSourceFunc)timeout_func, self); -} - -static bool enter_notify_event(ValaPanelToplevelUnit *self, GdkEventCrossing *event, gpointer data) -{ - ah_show(self); - return false; -} - -static bool leave_notify_event(ValaPanelToplevelUnit *self, GdkEventCrossing *event, gpointer data) -{ - if (self->autohide && - (event->detail != GDK_NOTIFY_INFERIOR && event->detail != GDK_NOTIFY_VIRTUAL)) - ah_hide(self); - return false; -} - -static void grab_notify(ValaPanelToplevelUnit *self, bool was_grabbed, gpointer data) -{ - if (!was_grabbed) - self->ah_state = AH_GRAB; - else if (self->autohide) - ah_hide(self); -} - -void vala_panel_toplevel_unit_init(ValaPanelToplevelUnit *self) -{ - // Move this to init, lay&must not be reinit in start/stop UI - self->layout = vala_panel_applet_layout_new(self->orientation, 0); - self->ah_rev = GTK_REVEALER(gtk_revealer_new()); - self->ah_sep = GTK_SEPARATOR(gtk_separator_new(GTK_ORIENTATION_HORIZONTAL)); - gtk_revealer_set_reveal_child(self->ah_rev, true); - GtkBox *box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0)); - gtk_container_add(GTK_CONTAINER(self), GTK_WIDGET(box)); - gtk_container_add(GTK_CONTAINER(box), GTK_WIDGET(self->ah_rev)); - gtk_container_add(GTK_CONTAINER(box), GTK_WIDGET(self->ah_sep)); - gtk_container_add(GTK_CONTAINER(self->ah_rev), GTK_WIDGET(self->layout)); - g_object_bind_property(self, "orientation", self->layout, "orentation", (GBindingFlags)0); - g_object_bind_property(self, "orientation", box, "orentation", (GBindingFlags)0); - g_object_bind_property(self, "orientation", self->ah_sep, "orentation", (GBindingFlags)0); -} - -void vala_panel_toplevel_unit_class_init(ValaPanelToplevelUnitClass *parent) -{ -} diff --git a/lib/c-lib/toplevel.h b/lib/c-lib/toplevel.h deleted file mode 100644 index aa5f3752..00000000 --- a/lib/c-lib/toplevel.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef TOPLEVEL_H -#define TOPLEVEL_H - -#include -#include -#include - -G_BEGIN_DECLS - -#define VALA_PANEL_SETTINGS_SCHEMA "org.valapanel.toplevel" -#define VALA_PANEL_SETTINGS_PATH "/org/vala-panel/toplevel/" -#define VALA_PANEL_TOPLEVEL_PATH_BASE "/org/vala-panel/objects/%s/%s/" - -#define VALA_PANEL_KEY_EDGE "edge" -#define VALA_PANEL_KEY_ALIGNMENT "alignment" -#define VALA_PANEL_KEY_HEIGHT "height" -#define VALA_PANEL_KEY_WIDTH "width" -#define VALA_PANEL_KEY_DYNAMIC "is-dynamic" -#define VALA_PANEL_KEY_AUTOHIDE "autohide" -#define VALA_PANEL_KEY_SHOW_HIDDEN "show-hidden" -#define VALA_PANEL_KEY_STRUT "strut" -#define VALA_PANEL_KEY_DOCK "dock" -#define VALA_PANEL_KEY_MONITOR "monitor" -#define VALA_PANEL_KEY_MARGIN "panel-margin" -#define VALA_PANEL_KEY_ICON_SIZE "icon-size" -#define VALA_PANEL_KEY_BACKGROUND_COLOR "background-color" -#define VALA_PANEL_KEY_FOREGROUND_COLOR "foreground-color" -#define VALA_PANEL_KEY_BACKGROUND_FILE "background-file" -#define VALA_PANEL_KEY_FONT "font" -#define VALA_PANEL_KEY_CORNERS_SIZE "round-corners-size" -#define VALA_PANEL_KEY_USE_BACKGROUND_COLOR "use-background-color" -#define VALA_PANEL_KEY_USE_FOREGROUND_COLOR "use-foreground-color" -#define VALA_PANEL_KEY_USE_FONT "use-font" -#define VALA_PANEL_KEY_FONT_SIZE_ONLY "font-size-only" -#define VALA_PANEL_KEY_USE_BACKGROUND_FILE "use-background-file" - -#define GAP 2 - -G_DECLARE_FINAL_TYPE(ValaPanelToplevelUnit, vala_panel_toplevel_unit, VALA_PANEL, TOPLEVEL_UNIT, - GtkApplicationWindow) - -ValaPanelToplevelUnit *vala_panel_toplevel_unit_new_from_position(GtkApplication *app, - const char *uid, int mon, - GtkPositionType edge); -ValaPanelToplevelUnit *vala_panel_toplevel_unit_new_from_uid(GtkApplication *app, char *uid); - -G_END_DECLS - -#endif // TOPLEVEL_H diff --git a/lib/generic-config-dialog.c b/lib/generic-config-dialog.c index c882ff9b..17c0eed3 100644 --- a/lib/generic-config-dialog.c +++ b/lib/generic-config-dialog.c @@ -20,7 +20,6 @@ #include #include "generic-config-dialog.h" -#include "lib/applets-new/applet-api.h" #include "lib/misc.h" typedef struct diff --git a/lib/settings-manager.h b/lib/settings-manager.h index 5ee9adca..55817ace 100644 --- a/lib/settings-manager.h +++ b/lib/settings-manager.h @@ -34,6 +34,50 @@ #define VALA_PANEL_KEY_POSITION "position" #define VALA_PANEL_KEY_APPLETS "applets" +typedef enum { + PACK_START = 0, + PACK_CENTER = 2, + PACK_END = 1, +} PanelAppletPackType; + +#define vala_panel_applet_set_position_metadata(applet, pos) \ + g_object_set_qdata(G_OBJECT(applet), \ + g_quark_from_static_string("position"), \ + GINT_TO_POINTER(pos)); + +#define vala_panel_applet_get_position_metadata(applet) \ + GPOINTER_TO_INT( \ + g_object_get_qdata(G_OBJECT(applet), g_quark_from_static_string("position"))); + +#define VALA_PANEL_SETTINGS_SCHEMA "org.valapanel.toplevel" +#define VALA_PANEL_SETTINGS_PATH "/org/vala-panel/toplevel/" +#define VALA_PANEL_TOPLEVEL_PATH_BASE "/org/vala-panel/objects/%s/%s/" + +#define VALA_PANEL_KEY_EDGE "edge" +#define VALA_PANEL_KEY_ALIGNMENT "alignment" +#define VALA_PANEL_KEY_HEIGHT "height" +#define VALA_PANEL_KEY_WIDTH "width" +#define VALA_PANEL_KEY_DYNAMIC "is-dynamic" +#define VALA_PANEL_KEY_AUTOHIDE "autohide" +#define VALA_PANEL_KEY_SHOW_HIDDEN "show-hidden" +#define VALA_PANEL_KEY_STRUT "strut" +#define VALA_PANEL_KEY_DOCK "dock" +#define VALA_PANEL_KEY_MONITOR "monitor" +#define VALA_PANEL_KEY_MARGIN "panel-margin" +#define VALA_PANEL_KEY_ICON_SIZE "icon-size" +#define VALA_PANEL_KEY_BACKGROUND_COLOR "background-color" +#define VALA_PANEL_KEY_FOREGROUND_COLOR "foreground-color" +#define VALA_PANEL_KEY_BACKGROUND_FILE "background-file" +#define VALA_PANEL_KEY_FONT "font" +#define VALA_PANEL_KEY_CORNERS_SIZE "round-corners-size" +#define VALA_PANEL_KEY_USE_BACKGROUND_COLOR "use-background-color" +#define VALA_PANEL_KEY_USE_FOREGROUND_COLOR "use-foreground-color" +#define VALA_PANEL_KEY_USE_FONT "use-font" +#define VALA_PANEL_KEY_FONT_SIZE_ONLY "font-size-only" +#define VALA_PANEL_KEY_USE_BACKGROUND_FILE "use-background-file" + +#define GAP 2 + G_BEGIN_DECLS typedef struct diff --git a/vapi/cvalapanel.vapi b/vapi/cvalapanel.vapi index 7a266d83..d66ee57e 100644 --- a/vapi/cvalapanel.vapi +++ b/vapi/cvalapanel.vapi @@ -36,27 +36,22 @@ namespace PanelCSS } namespace ValaPanel { - [CCode(cname="PanelAppletPackType", cprefix="PACK_", cheader_filename = "lib/c-lib/panel-layout.h")] + [CCode(cname="PanelAppletPackType", cprefix="PACK_", cheader_filename = "lib/settings-manager.h")] public enum AppletPackType { START, CENTER, END } - [CCode (cheader_filename="lib/c-lib/panel-layout.h")] + [CCode (cheader_filename="lib/settings-manager.h")] public void applet_set_position_metadata(Gtk.Widget applet, int metadata); - [CCode (cheader_filename="lib/c-lib/panel-layout.h")] + [CCode (cheader_filename="lib/settings-manager.h")] public int applet_get_position_metadata(Gtk.Widget applet); - [CCode (cheader_filename="lib/c-lib/panel-layout.h")] - public class AppletLayout : Gtk.Box - { - public AppletLayout(Gtk.Orientation orient, int spacing); - } [CCode(cheader_filename="lib/settings-manager.h")] public const string PLUGIN_SCHEMA; - [CCode(cheader_filename="lib/c-lib/toplevel.h")] + [CCode(cheader_filename="lib/settings-manager.h")] public const string SETTINGS_SCHEMA; - [CCode(cheader_filename="lib/c-lib/toplevel.h")] + [CCode(cheader_filename="lib/settings-manager.h")] public const string SETTINGS_PATH; [CCode(cname="GenericConfigType", has_type_id = false, cprefix="CONF_", cheader_filename = "lib/generic-config-dialog.h")] public enum GenericConfigType @@ -79,14 +74,14 @@ namespace ValaPanel GRAB, WAITING } - [CCode(cname="PanelAlignmentType", cprefix="ALIGN_", cheader_filename = "lib/c-lib/toplevel.h,lib/c-lib/vala-panel-enums.h")] + [CCode(cname="PanelAlignmentType", cprefix="ALIGN_", cheader_filename = "lib/panel-platform.h,lib/vala-panel-enums.h")] public enum AlignmentType { START, CENTER, END } - [CCode(cname="PanelIconSizeHints", cprefix="", cheader_filename = "lib/c-lib/toplevel.h,lib/c-lib/vala-panel-enums.h")] + [CCode(cname="PanelIconSizeHints", cprefix="", cheader_filename = "lib/panel-platform.h,lib/vala-panel-enums.h")] internal enum IconSizeHints { XXS, @@ -183,7 +178,7 @@ namespace ValaPanel.Application public const string SETTINGS; } -[CCode (cheader_filename = "lib/c-lib/toplevel.h,lib/c-lib/panel-layout.h,lib/settings-manager.h", cprefix = "VALA_PANEL_KEY_",lower_case_cprefix="VALA_PANEL_KEY_")] +[CCode (cheader_filename = "lib/settings-manager.h", cprefix = "VALA_PANEL_KEY_",lower_case_cprefix="VALA_PANEL_KEY_")] namespace ValaPanel.Key { public const string EDGE;