refactor: define object properties names in header files
This commit is contained in:
@ -12,7 +12,7 @@ static void on_background_destroy(GtkWindow *window, GApplication *_data)
|
||||
void diya_session_shell_init_background(DiyaSessionShell * shell)
|
||||
{
|
||||
GtkApplication * app;
|
||||
g_object_get(shell, "application", &app, NULL);
|
||||
g_object_get(shell, DIYA_PROP_SHELL_APPLICATION, &app, NULL);
|
||||
assert(app);
|
||||
GtkWindow *gtk_window = GTK_WINDOW (gtk_application_window_new (app));
|
||||
assert(gtk_window);
|
||||
|
@ -93,7 +93,7 @@ static void diya_shell_object_class_init(DiyaShellObjectClass *class)
|
||||
gobject_class->dispose = diya_shell_object_dispose;
|
||||
gobject_class->set_property = diya_shell_object_set_property;
|
||||
gobject_class->get_property = diya_shell_object_get_property;
|
||||
g_so_prop[SO_SHELL] = g_param_spec_pointer("shell", NULL, "Reference to global shell", G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY); //
|
||||
g_so_prop[SO_SHELL] = g_param_spec_pointer(DIYA_PROP_SHELL, NULL, "Reference to global shell", G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY); //
|
||||
|
||||
g_object_class_install_properties (gobject_class, SO_N_PROPERTIES, g_so_prop);
|
||||
}
|
||||
|
@ -4,6 +4,8 @@
|
||||
#include <glib-object.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define DIYA_PROP_SHELL "shell"
|
||||
|
||||
/**
|
||||
* Base class object
|
||||
*
|
||||
|
@ -137,11 +137,11 @@ static void diya_foreign_window_class_init(DiyaForeignWindowClass *class)
|
||||
gobject_class->get_property = diya_foreign_window_get_property;
|
||||
base_class->to_string = diya_foreign_window_to_string;
|
||||
|
||||
win_properties[WIN_APP_ID] = g_param_spec_string("appid", NULL, "Window application id", "", G_PARAM_READWRITE);
|
||||
win_properties[WIN_TITLE] = g_param_spec_string("title", NULL, "Window title","", G_PARAM_READWRITE );
|
||||
win_properties[WIN_HANDLE] = g_param_spec_pointer("handle", NULL, "Foreign window handle", G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY );
|
||||
win_properties[WIN_STATE] = g_param_spec_uint("state", NULL, "Window state",0, UINT_MAX , DIYA_WIN_STATE_NONE,G_PARAM_READWRITE);
|
||||
win_properties[WIN_PARENT] = g_param_spec_pointer("parent", NULL, "Window parent", G_PARAM_READWRITE);
|
||||
win_properties[WIN_APP_ID] = g_param_spec_string(DIYA_PROP_FOREIGN_WINDOW_APPID, NULL, "Window application id", "", G_PARAM_READWRITE);
|
||||
win_properties[WIN_TITLE] = g_param_spec_string(DIYA_PROP_FOREIGN_WINDOW_TITLE, NULL, "Window title","", G_PARAM_READWRITE );
|
||||
win_properties[WIN_HANDLE] = g_param_spec_pointer(DIYA_PROP_FOREIGN_WINDOW_HANDLE, NULL, "Foreign window handle", G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY );
|
||||
win_properties[WIN_STATE] = g_param_spec_uint(DIYA_PROP_FOREIGN_WINDOW_STATE, NULL, "Window state",0, UINT_MAX , DIYA_WIN_STATE_NONE,G_PARAM_READWRITE);
|
||||
win_properties[WIN_PARENT] = g_param_spec_pointer(DIYA_PROP_FOREIGN_WINDOW_PARENT, NULL, "Window parent", G_PARAM_READWRITE);
|
||||
g_object_class_install_properties (gobject_class, N_PROPERTIES, win_properties);
|
||||
}
|
||||
|
||||
@ -320,7 +320,7 @@ DiyaShell* diya_foreign_window_get_shell(DiyaForeignWindow* self)
|
||||
assert(self);
|
||||
gpointer ptr;
|
||||
|
||||
g_object_get(self, "shell", &ptr, NULL);
|
||||
g_object_get(self, DIYA_PROP_SHELL, &ptr, NULL);
|
||||
DiyaShell* shell = DIYA_SHELL(ptr);
|
||||
assert(shell);
|
||||
return shell;
|
||||
|
@ -2,6 +2,12 @@
|
||||
#define DIYA_SHELL_FOREIGN_H
|
||||
#include "session-shell.h"
|
||||
|
||||
#define DIYA_PROP_FOREIGN_WINDOW_APPID "appid"
|
||||
#define DIYA_PROP_FOREIGN_WINDOW_TITLE "title"
|
||||
#define DIYA_PROP_FOREIGN_WINDOW_HANDLE "handle"
|
||||
#define DIYA_PROP_FOREIGN_WINDOW_STATE "state"
|
||||
#define DIYA_PROP_FOREIGN_WINDOW_PARENT "parent"
|
||||
|
||||
enum diya_win_state
|
||||
{
|
||||
DIYA_WIN_STATE_NONE = 0,
|
||||
|
@ -50,7 +50,7 @@ static void show_windows(GtkWidget *widget,gpointer data)
|
||||
DiyaSessionShell * shell = DIYA_SESSION_SHELL(data);
|
||||
assert(shell);
|
||||
GHashTable* windows = NULL;
|
||||
g_object_get(shell, "windows", &windows, NULL);
|
||||
g_object_get(shell, DIYA_PROP_SESSION_WINDOWS, &windows, NULL);
|
||||
assert(windows);
|
||||
GHashTableIter iter;
|
||||
gpointer handle;
|
||||
@ -138,8 +138,8 @@ static void diya_launcher_class_init(DiyaLauncherClass *class)
|
||||
gobject_class->get_property = diya_launcher_get_property;
|
||||
base_class->to_string = diya_launcher_to_string;
|
||||
|
||||
g_prop[PROP_DASHBOARD] = g_param_spec_pointer("dashboard", NULL, "Launcher dashboard", G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY);
|
||||
g_prop[PROP_TASKBAR] = g_param_spec_pointer("taskbar", NULL, "Launcher taskbar", G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY);
|
||||
g_prop[PROP_DASHBOARD] = g_param_spec_pointer(DIYA_PROP_LAUNCHER_DASHBOARD, NULL, "Launcher dashboard", G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY);
|
||||
g_prop[PROP_TASKBAR] = g_param_spec_pointer(DIYA_PROP_LAUNCHER_TASKBAR, NULL, "Launcher taskbar", G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY);
|
||||
g_object_class_install_properties (gobject_class, N_PROPERTIES, g_prop);
|
||||
}
|
||||
|
||||
@ -147,7 +147,7 @@ void diya_session_shell_launcher_init(DiyaSessionShell * shell)
|
||||
{
|
||||
assert(shell);
|
||||
GtkApplication * app;
|
||||
g_object_get(shell, "application", &app, NULL);
|
||||
g_object_get(shell, DIYA_PROP_SHELL_APPLICATION, &app, NULL);
|
||||
assert(app);
|
||||
|
||||
DiyaDashboardWidget* dashboard = DIYA_DASHBOARD_WIDGET(g_object_new (DIYA_TYPE_DASHBOARD_WIDGET, "application", app, "shell",shell, NULL));
|
||||
@ -158,7 +158,7 @@ void diya_session_shell_launcher_init(DiyaSessionShell * shell)
|
||||
//gtk_window_set_transient_for(GTK_WINDOW(dashboard), GTK_WINDOW(taskbar));
|
||||
DiyaLauncher* self = DIYA_LAUNCHER(g_object_new (DIYA_TYPE_LAUNCHER, "dashboard", dashboard, "taskbar",taskbar, NULL));
|
||||
assert(self);
|
||||
g_object_bind_property(taskbar, "show-dashboard", dashboard, "active", G_BINDING_BIDIRECTIONAL);
|
||||
g_object_bind_property(taskbar, DIYA_PROP_TASKBAR_SHOW_DASHBOARD, dashboard, DIYA_PROP_DASHBOARD_ACTIVE, G_BINDING_BIDIRECTIONAL);
|
||||
g_object_set(shell, "launchpad", self, NULL);
|
||||
//g_signal_connect (GTK_WINDOW(dashboard), "destroy", G_CALLBACK (on_launcher_destroy), NULL);
|
||||
|
||||
|
@ -3,6 +3,9 @@
|
||||
|
||||
#include "session-shell.h"
|
||||
|
||||
#define DIYA_PROP_LAUNCHER_DASHBOARD "dashboard"
|
||||
#define DIYA_PROP_LAUNCHER_TASKBAR "taskbar"
|
||||
|
||||
#define DIYA_TYPE_LAUNCHER (diya_launcher_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (DiyaLauncher, diya_launcher, DIYA, LAUNCHER, DiyaShellObject)
|
||||
|
||||
|
@ -14,7 +14,7 @@ void diya_session_shell_lock(DiyaSessionShell* shell)
|
||||
{
|
||||
assert(shell);
|
||||
GtkSessionLockInstance * lock;
|
||||
g_object_get(shell, "session-lock", &lock, NULL);
|
||||
g_object_get(shell, DIYA_PROP_SESSION_LOCK, &lock, NULL);
|
||||
assert(lock);
|
||||
if(gtk_session_lock_instance_is_locked(lock))
|
||||
{
|
||||
@ -27,7 +27,7 @@ void diya_session_shell_lock(DiyaSessionShell* shell)
|
||||
return;
|
||||
}
|
||||
GtkApplication * app;
|
||||
g_object_get(shell, "application", &app, NULL);
|
||||
g_object_get(shell, DIYA_PROP_SHELL_APPLICATION, &app, NULL);
|
||||
assert(app);
|
||||
|
||||
GdkDisplay *display = gdk_display_get_default();
|
||||
@ -64,7 +64,7 @@ void diya_session_shell_unlock(DiyaSessionShell* shell)
|
||||
{
|
||||
assert(shell);
|
||||
GtkSessionLockInstance * lock;
|
||||
g_object_get(shell, "session-lock", &lock, NULL);
|
||||
g_object_get(shell, DIYA_PROP_SESSION_LOCK, &lock, NULL);
|
||||
assert(lock);
|
||||
gtk_session_lock_instance_unlock(lock);
|
||||
g_debug("gtk_session_lock_instance_unlock: Shell unlocked");
|
||||
|
@ -122,10 +122,10 @@ static void diya_session_shell_class_init(DiyaSessionShellClass *class)
|
||||
gobject_class->set_property = diya_session_shell_set_property;
|
||||
gobject_class->get_property = diya_session_shell_get_property;
|
||||
|
||||
shell_properties[SHELL_BACKGROUND_WIDGET] = g_param_spec_pointer("background", NULL, "Shell background widget", G_PARAM_READWRITE );
|
||||
shell_properties[SHELL_LAUNCHPAD_WIDGET] = g_param_spec_pointer("launchpad", NULL, "Shell launchpad", G_PARAM_READWRITE );
|
||||
shell_properties[SHELL_LOCK_SESSION] = g_param_spec_pointer("session-lock", NULL, "Shell lock session", G_PARAM_READABLE );
|
||||
shell_properties[SHELL_WINDOWS] = g_param_spec_pointer("windows", NULL, "Shell foreign windows", G_PARAM_READABLE);
|
||||
shell_properties[SHELL_BACKGROUND_WIDGET] = g_param_spec_pointer(DIYA_PROP_SESSION_BACKGROUND, NULL, "Shell background widget", G_PARAM_READWRITE );
|
||||
shell_properties[SHELL_LAUNCHPAD_WIDGET] = g_param_spec_pointer(DIYA_PROP_SESSION_LAUNCHPAD, NULL, "Shell launchpad", G_PARAM_READWRITE );
|
||||
shell_properties[SHELL_LOCK_SESSION] = g_param_spec_pointer(DIYA_PROP_SESSION_LOCK, NULL, "Shell lock session", G_PARAM_READABLE );
|
||||
shell_properties[SHELL_WINDOWS] = g_param_spec_pointer(DIYA_PROP_SESSION_WINDOWS, NULL, "Shell foreign windows", G_PARAM_READABLE);
|
||||
|
||||
g_object_class_install_properties (gobject_class, N_PROPERTIES, shell_properties);
|
||||
|
||||
@ -210,7 +210,7 @@ DiyaForeignWindow* diya_session_shell_get_window(DiyaSessionShell * shell, gpoin
|
||||
gboolean diya_session_shell_add_window(DiyaSessionShell * shell, DiyaForeignWindow * win)
|
||||
{
|
||||
gpointer handle;
|
||||
g_object_get(win, "handle", &handle, NULL);
|
||||
g_object_get(win, DIYA_PROP_FOREIGN_WINDOW_HANDLE, &handle, NULL);
|
||||
assert(handle);
|
||||
return g_hash_table_insert(shell->windows,handle, win);
|
||||
}
|
||||
@ -218,7 +218,7 @@ gboolean diya_session_shell_add_window(DiyaSessionShell * shell, DiyaForeignWind
|
||||
gboolean diya_session_shell_remove_window(DiyaSessionShell * shell, DiyaForeignWindow * win)
|
||||
{
|
||||
gpointer handle;
|
||||
g_object_get(win, "handle", &handle, NULL);
|
||||
g_object_get(win, DIYA_PROP_FOREIGN_WINDOW_HANDLE, &handle, NULL);
|
||||
assert(handle);
|
||||
return g_hash_table_remove(shell->windows,handle);
|
||||
}
|
||||
|
@ -10,6 +10,11 @@
|
||||
#define DIYA_SIGNAL_SESSION_LOCKED "session-locked"
|
||||
#define DIYA_SIGNAL_SESSION_UNLOCKED "session-unlocked"
|
||||
|
||||
#define DIYA_PROP_SESSION_LAUNCHPAD "launchpad"
|
||||
#define DIYA_PROP_SESSION_BACKGROUND "background"
|
||||
#define DIYA_PROP_SESSION_LOCK "session-lock"
|
||||
#define DIYA_PROP_SESSION_WINDOWS "windows"
|
||||
|
||||
#define DIYA_TYPE_SESSION_SHELL (diya_session_shell_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (DiyaSessionShell, diya_session_shell, DIYA, SESSION_SHELL, DiyaShell)
|
||||
|
||||
|
@ -357,10 +357,10 @@ static void diya_shell_class_init(DiyaShellClass *class)
|
||||
class->active_handle = NULL;
|
||||
class->reload_handle = NULL;
|
||||
|
||||
shell_properties[PROP_SHELL_WAYLAND] = g_param_spec_pointer("wayland", NULL, "Shell wayland", G_PARAM_READABLE); //
|
||||
shell_properties[PROP_SHELL_NAME] = g_param_spec_string("name", NULL, "Shell name", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
shell_properties[PROP_SHELL_APP] = g_param_spec_pointer("application", NULL, "Shell application", G_PARAM_READABLE);
|
||||
shell_properties[PROP_SHELL_THEME] = g_param_spec_string("theme", NULL, "Shell theme", NULL, G_PARAM_READWRITE);
|
||||
shell_properties[PROP_SHELL_WAYLAND] = g_param_spec_pointer(DIYA_PROP_SHELL_WAYLAND, NULL, "Shell wayland", G_PARAM_READABLE); //
|
||||
shell_properties[PROP_SHELL_NAME] = g_param_spec_string(DIYA_PROP_SHELL_NAME, NULL, "Shell name", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
shell_properties[PROP_SHELL_APP] = g_param_spec_pointer(DIYA_PROP_SHELL_APPLICATION, NULL, "Shell application", G_PARAM_READABLE);
|
||||
shell_properties[PROP_SHELL_THEME] = g_param_spec_string(DIYA_PROP_SHELL_THEME, NULL, "Shell theme", NULL, G_PARAM_READWRITE);
|
||||
|
||||
g_object_class_install_properties(gobject_class, N_PROPERTIES, shell_properties);
|
||||
}
|
||||
|
@ -8,6 +8,11 @@
|
||||
#define DIYA_ENV_THEME "DIYA_DEFAULT_THEME"
|
||||
#define DIYA_ENV_VKB_KEYMAP "DIYA_VKB_KEYMAP"
|
||||
|
||||
#define DIYA_PROP_SHELL_WAYLAND "wayland"
|
||||
#define DIYA_PROP_SHELL_NAME "name"
|
||||
#define DIYA_PROP_SHELL_APPLICATION "application"
|
||||
#define DIYA_PROP_SHELL_THEME "theme"
|
||||
|
||||
#define DIYA_TYPE_SHELL (diya_shell_get_type())
|
||||
G_DECLARE_DERIVABLE_TYPE(DiyaShell, diya_shell, DIYA, SHELL, DiyaObject)
|
||||
|
||||
|
@ -63,7 +63,7 @@ static void handle_global(void *data, struct wl_registry *registry, uint32_t nam
|
||||
DiyaShell * shell = data;
|
||||
DiyaShellClass * class = DIYA_SHELL_GET_CLASS(shell);
|
||||
DiyaWayland * wayland;
|
||||
g_object_get(shell, "wayland", &wayland, NULL);
|
||||
g_object_get(shell, DIYA_PROP_SHELL_WAYLAND, &wayland, NULL);
|
||||
assert(DIYA_IS_WAYLAND(wayland));
|
||||
g_debug("WAYLAND GLOBAL: %s", interface);
|
||||
|
||||
|
@ -73,7 +73,7 @@ static void diya_shell_window_class_init(DiyaShellWindowClass *class)
|
||||
gobject_class->dispose = diya_shell_window_dispose;
|
||||
gobject_class->set_property = diya_shell_window_set_property;
|
||||
gobject_class->get_property = diya_shell_window_get_property;
|
||||
g_sw_prop[SW_SHELL] = g_param_spec_pointer("shell", NULL, "Reference to global shell", G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY); //
|
||||
g_sw_prop[SW_SHELL] = g_param_spec_pointer(DIYA_PROP_SHELL, NULL, "Reference to global shell", G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY); //
|
||||
|
||||
g_object_class_install_properties (gobject_class, SW_N_PROPERTIES, g_sw_prop);
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ static void diya_dashboard_widget_class_init(DiyaDashboardWidgetClass* class)
|
||||
//gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
|
||||
//gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), search_text_changed);
|
||||
|
||||
g_prop[PROP_ACTIVE] = g_param_spec_boolean("active", NULL, "Active the dashboard", false, G_PARAM_READWRITE); //
|
||||
g_prop[PROP_ACTIVE] = g_param_spec_boolean(DIYA_PROP_DASHBOARD_ACTIVE, NULL, "Active the dashboard", false, G_PARAM_READWRITE); //
|
||||
|
||||
g_object_class_install_properties (gobject_class, N_PROPERTIES, g_prop);
|
||||
}
|
@ -4,6 +4,8 @@
|
||||
#include "session-shell.h"
|
||||
#include "base-widgets.h"
|
||||
|
||||
#define DIYA_PROP_DASHBOARD_ACTIVE "active"
|
||||
|
||||
#define DIYA_TYPE_DASHBOARD_WIDGET (diya_dashboard_widget_get_type())
|
||||
G_DECLARE_FINAL_TYPE (DiyaDashboardWidget, diya_dashboard_widget, DIYA, DASHBOARD_WIDGET, DiyaShellWindow)
|
||||
|
||||
|
@ -56,7 +56,7 @@ static void diya_taskbar_widget_init(DiyaTaskbarWidget * self)
|
||||
// the top launcher shall be exclusive
|
||||
gtk_layer_auto_exclusive_zone_enable (GTK_WINDOW(self));
|
||||
|
||||
g_object_bind_property(self->btn_toggle, "active", self, "show-dashboard", G_BINDING_BIDIRECTIONAL);
|
||||
g_object_bind_property(self->btn_toggle, "active", self, DIYA_PROP_TASKBAR_SHOW_DASHBOARD, G_BINDING_BIDIRECTIONAL);
|
||||
}
|
||||
|
||||
|
||||
@ -122,7 +122,7 @@ static void diya_taskbar_widget_class_init(DiyaTaskbarWidgetClass* class)
|
||||
//gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
|
||||
//gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), search_text_changed);
|
||||
|
||||
g_prop[PROP_SHOW_DASHBOARD] = g_param_spec_boolean("show-dashboard", NULL, "Show/hide dashboard", false, G_PARAM_READWRITE); //
|
||||
g_prop[PROP_SHOW_DASHBOARD] = g_param_spec_boolean(DIYA_PROP_TASKBAR_SHOW_DASHBOARD, NULL, "Show/hide dashboard", false, G_PARAM_READWRITE); //
|
||||
|
||||
g_object_class_install_properties (gobject_class, N_PROPERTIES, g_prop);
|
||||
}
|
@ -4,6 +4,8 @@
|
||||
#include "session-shell.h"
|
||||
#include "base-widgets.h"
|
||||
|
||||
#define DIYA_PROP_TASKBAR_SHOW_DASHBOARD "show-dashboard"
|
||||
|
||||
#define DIYA_TYPE_TASKBAR_WIDGET (diya_taskbar_widget_get_type())
|
||||
G_DECLARE_FINAL_TYPE (DiyaTaskbarWidget, diya_taskbar_widget, DIYA, TASKBAR_WIDGET, DiyaShellWindow)
|
||||
|
||||
|
Reference in New Issue
Block a user