mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-05-16 13:40:18 +00:00
Compare commits
7 Commits
aa52236c01
...
bd9adeb795
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd9adeb795 | ||
|
|
5fd3c7c9d9 | ||
| 937184429f | |||
| e31ccff3f8 | |||
| edaafba7eb | |||
| 87018fa7fe | |||
| 8fcec519d0 |
2
.github/workflows/appimage-build.yml
vendored
2
.github/workflows/appimage-build.yml
vendored
@@ -28,7 +28,7 @@ jobs:
|
|||||||
sudo apt-get install -y --no-install-recommends \
|
sudo apt-get install -y --no-install-recommends \
|
||||||
build-essential pkg-config meson ninja-build cmake \
|
build-essential pkg-config meson ninja-build cmake \
|
||||||
gettext \
|
gettext \
|
||||||
libcanberra-dev libdbus-glib-1-dev libglib2.0-dev \
|
libcanberra-dev libglib2.0-dev \
|
||||||
libarchive-dev \
|
libarchive-dev \
|
||||||
libgtk-3-dev \
|
libgtk-3-dev \
|
||||||
libwayland-client0 libwayland-cursor0 libwayland-egl1 \
|
libwayland-client0 libwayland-cursor0 libwayland-egl1 \
|
||||||
|
|||||||
1
.github/workflows/manjaro-package-build.yml
vendored
1
.github/workflows/manjaro-package-build.yml
vendored
@@ -32,7 +32,6 @@ jobs:
|
|||||||
glib2-devel \
|
glib2-devel \
|
||||||
gtk3 \
|
gtk3 \
|
||||||
openssl \
|
openssl \
|
||||||
dbus-glib \
|
|
||||||
libcanberra \
|
libcanberra \
|
||||||
libayatana-appindicator \
|
libayatana-appindicator \
|
||||||
luajit \
|
luajit \
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ if get_option('gtk-frontend')
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
desktop_conf = configuration_data()
|
desktop_conf = configuration_data()
|
||||||
if dbus_glib_dep.found()
|
if dbus_dep.found()
|
||||||
desktop_conf.set('exec_command', 'zoitechat --existing %U')
|
desktop_conf.set('exec_command', 'zoitechat --existing %U')
|
||||||
else
|
else
|
||||||
desktop_conf.set('exec_command', 'zoitechat %U')
|
desktop_conf.set('exec_command', 'zoitechat %U')
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"modules": [
|
"modules": [
|
||||||
"shared-modules/dbus-glib/dbus-glib.json",
|
|
||||||
"shared-modules/lua5.4/lua-5.4.json",
|
"shared-modules/lua5.4/lua-5.4.json",
|
||||||
"shared-modules/libcanberra/libcanberra.json",
|
"shared-modules/libcanberra/libcanberra.json",
|
||||||
"shared-modules/libayatana-appindicator/libayatana-appindicator-gtk3.json",
|
"shared-modules/libayatana-appindicator/libayatana-appindicator-gtk3.json",
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ libgmodule_dep = dependency('gmodule-2.0')
|
|||||||
|
|
||||||
libcanberra_dep = dependency('libcanberra', version: '>= 0.22',
|
libcanberra_dep = dependency('libcanberra', version: '>= 0.22',
|
||||||
required: get_option('libcanberra'))
|
required: get_option('libcanberra'))
|
||||||
dbus_glib_dep = dependency('dbus-glib-1', required: get_option('dbus'))
|
dbus_dep = dependency('gio-2.0', required: get_option('dbus'))
|
||||||
|
|
||||||
global_deps = []
|
global_deps = []
|
||||||
if cc.get_id() == 'msvc'
|
if cc.get_id() == 'msvc'
|
||||||
@@ -39,7 +39,7 @@ config_h.set10('ENABLE_NLS', true)
|
|||||||
# Optional features
|
# Optional features
|
||||||
config_h.set('USE_OPENSSL', libssl_dep.found())
|
config_h.set('USE_OPENSSL', libssl_dep.found())
|
||||||
config_h.set('USE_LIBCANBERRA', libcanberra_dep.found())
|
config_h.set('USE_LIBCANBERRA', libcanberra_dep.found())
|
||||||
config_h.set('USE_DBUS', dbus_glib_dep.found())
|
config_h.set('USE_DBUS', dbus_dep.found())
|
||||||
config_h.set('USE_PLUGIN', get_option('plugin'))
|
config_h.set('USE_PLUGIN', get_option('plugin'))
|
||||||
config_h.set('USE_GTK_FRONTEND', get_option('gtk-frontend'))
|
config_h.set('USE_GTK_FRONTEND', get_option('gtk-frontend'))
|
||||||
|
|
||||||
@@ -181,7 +181,7 @@ if meson.version().version_compare('>= 0.55.0')
|
|||||||
'GTK Frontend': get_option('gtk-frontend') ? 'enabled (GTK+ 3.22+)' : 'disabled',
|
'GTK Frontend': get_option('gtk-frontend') ? 'enabled (GTK+ 3.22+)' : 'disabled',
|
||||||
'TLS (openssl)': libssl_dep.found(),
|
'TLS (openssl)': libssl_dep.found(),
|
||||||
'Plugin Support': get_option('plugin'),
|
'Plugin Support': get_option('plugin'),
|
||||||
'DBus Support': dbus_glib_dep.found(),
|
'DBus Support': dbus_dep.found(),
|
||||||
'libcanberra': libcanberra_dep.found(),
|
'libcanberra': libcanberra_dep.found(),
|
||||||
}, section: 'Features')
|
}, section: 'Features')
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ arch=('x86_64')
|
|||||||
url='https://github.com/zoitechat/zoitechat'
|
url='https://github.com/zoitechat/zoitechat'
|
||||||
license=('GPL-2.0-or-later')
|
license=('GPL-2.0-or-later')
|
||||||
depends=(
|
depends=(
|
||||||
'dbus-glib'
|
|
||||||
'glib2'
|
'glib2'
|
||||||
'gtk3'
|
'gtk3'
|
||||||
'iso-codes'
|
'iso-codes'
|
||||||
|
|||||||
@@ -82,10 +82,6 @@ has_theme_argument (void)
|
|||||||
|
|
||||||
void
|
void
|
||||||
zoitechat_remote (void)
|
zoitechat_remote (void)
|
||||||
/* TODO: dbus_g_connection_unref (connection) are commented because it makes
|
|
||||||
* dbus to crash. Fixed in dbus >=0.70 ?!?
|
|
||||||
* https://launchpad.net/distros/ubuntu/+source/dbus/+bug/54375
|
|
||||||
*/
|
|
||||||
{
|
{
|
||||||
GDBusConnection *connection;
|
GDBusConnection *connection;
|
||||||
GDBusProxy *dbus = NULL;
|
GDBusProxy *dbus = NULL;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,203 +1,122 @@
|
|||||||
/* example.c - program to demonstrate some D-BUS stuffs.
|
#include <gio/gio.h>
|
||||||
* Copyright (C) 2006 Claessens Xavier
|
#include <glib.h>
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 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 General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
||||||
*
|
|
||||||
* Claessens Xavier
|
|
||||||
* xclaesse@gmail.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
#include <dbus/dbus-glib.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "../marshal.c"
|
|
||||||
|
|
||||||
#define DBUS_SERVICE "org.zoitechat.service"
|
#define DBUS_SERVICE "org.zoitechat.service"
|
||||||
#define DBUS_REMOTE "/org/zoitechat/Remote"
|
#define DBUS_CONNECTION_PATH "/org/zoitechat"
|
||||||
#define DBUS_REMOTE_CONNECTION_INTERFACE "org.zoitechat.connection"
|
#define DBUS_CONNECTION_INTERFACE "org.zoitechat.connection"
|
||||||
#define DBUS_REMOTE_PLUGIN_INTERFACE "org.zoitechat.plugin"
|
#define DBUS_PLUGIN_INTERFACE "org.zoitechat.plugin"
|
||||||
|
|
||||||
guint command_id;
|
static gboolean
|
||||||
guint server_id;
|
call_sync (GDBusProxy *proxy, const char *method, GVariant *params, GVariant **out)
|
||||||
|
|
||||||
static void
|
|
||||||
write_error (const char *message,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
if (error == NULL || *error == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
g_printerr ("%s: %s\n", message, (*error)->message);
|
|
||||||
g_clear_error (error);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
test_server_cb (DBusGProxy *proxy,
|
|
||||||
char *word[],
|
|
||||||
char *word_eol[],
|
|
||||||
guint hook_id,
|
|
||||||
guint context_id,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
if (hook_id == server_id) {
|
|
||||||
g_print ("message: %s\n", word_eol[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
test_command_cb (DBusGProxy *proxy,
|
|
||||||
char *word[],
|
|
||||||
char *word_eol[],
|
|
||||||
guint hook_id,
|
|
||||||
guint context_id,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
GVariant *result;
|
||||||
|
|
||||||
if (hook_id == command_id) {
|
result = g_dbus_proxy_call_sync (proxy,
|
||||||
if (!dbus_g_proxy_call (proxy, "Unhook",
|
method,
|
||||||
&error,
|
params,
|
||||||
G_TYPE_UINT, hook_id,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
G_TYPE_INVALID, G_TYPE_INVALID)) {
|
-1,
|
||||||
write_error ("Failed to complete unhook", &error);
|
NULL,
|
||||||
|
&error);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
g_printerr ("%s failed: %s\n", method, error->message);
|
||||||
|
g_clear_error (&error);
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
/* Now if you write "/test blah" again in the ZoiteChat window
|
|
||||||
* you'll get a "Unknown command" error message */
|
|
||||||
g_print ("test command received: %s\n", word_eol[1]);
|
|
||||||
if (!dbus_g_proxy_call (proxy, "Print",
|
|
||||||
&error,
|
|
||||||
G_TYPE_STRING, "test command succeed",
|
|
||||||
G_TYPE_INVALID,
|
|
||||||
G_TYPE_INVALID)) {
|
|
||||||
write_error ("Failed to complete Print", &error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
if (out)
|
||||||
unload_cb (void)
|
*out = result;
|
||||||
{
|
else
|
||||||
g_print ("Good bye !\n");
|
g_variant_unref (result);
|
||||||
exit (EXIT_SUCCESS);
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
DBusGConnection *connection;
|
GDBusConnection *connection;
|
||||||
DBusGProxy *remote_object;
|
GDBusProxy *connection_proxy;
|
||||||
GMainLoop *mainloop;
|
GDBusProxy *plugin_proxy;
|
||||||
gchar *path;
|
GVariant *connect_result = NULL;
|
||||||
|
gchar *remote_path = NULL;
|
||||||
|
gchar *command = NULL;
|
||||||
|
const char *path_tmp;
|
||||||
|
int status = EXIT_FAILURE;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
#if ! GLIB_CHECK_VERSION (2, 36, 0)
|
connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
|
||||||
g_type_init ();
|
if (!connection)
|
||||||
#endif
|
{
|
||||||
|
g_printerr ("Bus connection failed: %s\n", error->message);
|
||||||
connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
|
g_clear_error (&error);
|
||||||
if (connection == NULL) {
|
|
||||||
write_error ("Couldn't connect to session bus", &error);
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
remote_object = dbus_g_proxy_new_for_name (connection,
|
connection_proxy = g_dbus_proxy_new_sync (connection,
|
||||||
|
G_DBUS_PROXY_FLAGS_NONE,
|
||||||
|
NULL,
|
||||||
DBUS_SERVICE,
|
DBUS_SERVICE,
|
||||||
DBUS_REMOTE,
|
DBUS_CONNECTION_PATH,
|
||||||
DBUS_REMOTE_CONNECTION_INTERFACE);
|
DBUS_CONNECTION_INTERFACE,
|
||||||
if (!dbus_g_proxy_call (remote_object, "Connect",
|
NULL,
|
||||||
&error,
|
&error);
|
||||||
G_TYPE_STRING, argv[0],
|
if (!connection_proxy)
|
||||||
G_TYPE_STRING, "example",
|
{
|
||||||
G_TYPE_STRING, "Example of a D-Bus client",
|
g_printerr ("Connection proxy failed: %s\n", error->message);
|
||||||
G_TYPE_STRING, "1.0",
|
g_clear_error (&error);
|
||||||
G_TYPE_INVALID,
|
g_object_unref (connection);
|
||||||
G_TYPE_STRING, &path, G_TYPE_INVALID)) {
|
|
||||||
write_error ("Failed to complete Connect", &error);
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
g_object_unref (remote_object);
|
|
||||||
|
|
||||||
remote_object = dbus_g_proxy_new_for_name (connection,
|
if (!call_sync (connection_proxy,
|
||||||
|
"Connect",
|
||||||
|
g_variant_new ("(ssss)", "example", "example", "GDBus example", "1.0"),
|
||||||
|
&connect_result))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
g_variant_get (connect_result, "(&s)", &path_tmp);
|
||||||
|
remote_path = g_strdup (path_tmp);
|
||||||
|
g_variant_unref (connect_result);
|
||||||
|
connect_result = NULL;
|
||||||
|
|
||||||
|
plugin_proxy = g_dbus_proxy_new_sync (connection,
|
||||||
|
G_DBUS_PROXY_FLAGS_NONE,
|
||||||
|
NULL,
|
||||||
DBUS_SERVICE,
|
DBUS_SERVICE,
|
||||||
path,
|
remote_path,
|
||||||
DBUS_REMOTE_PLUGIN_INTERFACE);
|
DBUS_PLUGIN_INTERFACE,
|
||||||
g_free (path);
|
NULL,
|
||||||
|
&error);
|
||||||
if (!dbus_g_proxy_call (remote_object, "HookCommand",
|
if (!plugin_proxy)
|
||||||
&error,
|
{
|
||||||
G_TYPE_STRING, "test",
|
g_printerr ("Plugin proxy failed: %s\n", error->message);
|
||||||
G_TYPE_INT, 0,
|
g_clear_error (&error);
|
||||||
G_TYPE_STRING, "Simple D-BUS example",
|
goto cleanup;
|
||||||
G_TYPE_INT, 1, G_TYPE_INVALID,
|
|
||||||
G_TYPE_UINT, &command_id, G_TYPE_INVALID)) {
|
|
||||||
write_error ("Failed to complete HookCommand", &error);
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
}
|
||||||
g_print ("Command hook id=%d\n", command_id);
|
|
||||||
|
|
||||||
if (!dbus_g_proxy_call (remote_object, "HookServer",
|
if (argc > 1)
|
||||||
&error,
|
command = g_strjoinv (" ", &argv[1]);
|
||||||
G_TYPE_STRING, "RAW LINE",
|
else
|
||||||
G_TYPE_INT, 0,
|
command = g_strdup ("gui focus");
|
||||||
G_TYPE_INT, 0, G_TYPE_INVALID,
|
|
||||||
G_TYPE_UINT, &server_id, G_TYPE_INVALID)) {
|
if (!call_sync (plugin_proxy, "Command", g_variant_new ("(s)", command), NULL))
|
||||||
write_error ("Failed to complete HookServer", &error);
|
{
|
||||||
return EXIT_FAILURE;
|
g_object_unref (plugin_proxy);
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
g_print ("Server hook id=%d\n", server_id);
|
|
||||||
|
|
||||||
dbus_g_object_register_marshaller (
|
call_sync (connection_proxy, "Disconnect", g_variant_new ("()"), NULL);
|
||||||
_zoitechat_marshal_VOID__POINTER_POINTER_UINT_UINT,
|
status = EXIT_SUCCESS;
|
||||||
G_TYPE_NONE,
|
g_object_unref (plugin_proxy);
|
||||||
G_TYPE_STRV, G_TYPE_STRV, G_TYPE_UINT, G_TYPE_UINT,
|
|
||||||
G_TYPE_INVALID);
|
|
||||||
|
|
||||||
dbus_g_object_register_marshaller (
|
cleanup:
|
||||||
g_cclosure_marshal_VOID__VOID,
|
g_free (command);
|
||||||
G_TYPE_NONE,
|
g_free (remote_path);
|
||||||
G_TYPE_INVALID);
|
g_object_unref (connection_proxy);
|
||||||
|
g_object_unref (connection);
|
||||||
dbus_g_proxy_add_signal (remote_object, "CommandSignal",
|
return status;
|
||||||
G_TYPE_STRV,
|
|
||||||
G_TYPE_STRV,
|
|
||||||
G_TYPE_UINT,
|
|
||||||
G_TYPE_UINT,
|
|
||||||
G_TYPE_INVALID);
|
|
||||||
dbus_g_proxy_connect_signal (remote_object, "CommandSignal",
|
|
||||||
G_CALLBACK (test_command_cb),
|
|
||||||
NULL, NULL);
|
|
||||||
|
|
||||||
dbus_g_proxy_add_signal (remote_object, "ServerSignal",
|
|
||||||
G_TYPE_STRV,
|
|
||||||
G_TYPE_STRV,
|
|
||||||
G_TYPE_UINT,
|
|
||||||
G_TYPE_UINT,
|
|
||||||
G_TYPE_INVALID);
|
|
||||||
dbus_g_proxy_connect_signal (remote_object, "ServerSignal",
|
|
||||||
G_CALLBACK (test_server_cb),
|
|
||||||
NULL, NULL);
|
|
||||||
|
|
||||||
dbus_g_proxy_add_signal (remote_object, "UnloadSignal",
|
|
||||||
G_TYPE_INVALID);
|
|
||||||
dbus_g_proxy_connect_signal (remote_object, "UnloadSignal",
|
|
||||||
G_CALLBACK (unload_cb),
|
|
||||||
NULL, NULL);
|
|
||||||
|
|
||||||
/* Now you can write on the ZoiteChat windows: "/test arg1 arg2 ..." */
|
|
||||||
mainloop = g_main_loop_new (NULL, FALSE);
|
|
||||||
g_main_loop_run (mainloop);
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
dbus_deps = [
|
dbus_deps = []
|
||||||
dbus_glib_dep
|
|
||||||
]
|
|
||||||
|
|
||||||
dbus_sources = [
|
dbus_sources = [
|
||||||
'dbus-plugin.c',
|
'dbus-plugin.c',
|
||||||
@@ -35,16 +33,8 @@ configure_file(
|
|||||||
install_dir: dbus_service_dir
|
install_dir: dbus_service_dir
|
||||||
)
|
)
|
||||||
|
|
||||||
dbus_binding_tool = find_program('dbus-binding-tool')
|
|
||||||
dbus_remote_object = custom_target('remote-object-glue',
|
|
||||||
input: 'remote-object.xml',
|
|
||||||
output: 'remote-object-glue.h',
|
|
||||||
command: [dbus_binding_tool, '--prefix=remote_object', '--mode=glib-server',
|
|
||||||
'--output=@OUTPUT@', '@INPUT@']
|
|
||||||
)
|
|
||||||
|
|
||||||
zoitechat_dbus = static_library('zoitechatdbus',
|
zoitechat_dbus = static_library('zoitechatdbus',
|
||||||
sources: [dbus_remote_object, marshal] + dbus_sources,
|
sources: marshal + dbus_sources,
|
||||||
c_args: dbus_cargs,
|
c_args: dbus_cargs,
|
||||||
dependencies: common_deps + dbus_deps,
|
dependencies: common_deps + dbus_deps,
|
||||||
include_directories: dbus_includes,
|
include_directories: dbus_includes,
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ if libssl_dep.found()
|
|||||||
common_deps += libssl_dep
|
common_deps += libssl_dep
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if dbus_glib_dep.found()
|
if dbus_dep.found()
|
||||||
subdir('dbus')
|
subdir('dbus')
|
||||||
common_deps += zoitechat_dbus_dep
|
common_deps += zoitechat_dbus_dep
|
||||||
common_includes += include_directories('dbus')
|
common_includes += include_directories('dbus')
|
||||||
|
|||||||
@@ -61,28 +61,19 @@ static tab_scroll_animation *tab_right_animation;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static inline gint
|
static inline gint
|
||||||
cv_tabs_get_viewport_size (GdkWindow *parent_win, gboolean vertical)
|
cv_tabs_get_viewport_size (GtkAdjustment *adj)
|
||||||
{
|
{
|
||||||
gint viewport_size = 0;
|
return (gint) gtk_adjustment_get_page_size (adj);
|
||||||
|
|
||||||
if (vertical)
|
|
||||||
viewport_size = gdk_window_get_height (parent_win);
|
|
||||||
else
|
|
||||||
viewport_size = gdk_window_get_width (parent_win);
|
|
||||||
|
|
||||||
return viewport_size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cv_tabs_sizealloc (GtkWidget *widget, GtkAllocation *allocation, chanview *cv)
|
cv_tabs_sizealloc (GtkWidget *widget, GtkAllocation *allocation, chanview *cv)
|
||||||
{
|
{
|
||||||
GdkWindow *parent_win;
|
|
||||||
GtkAdjustment *adj;
|
GtkAdjustment *adj;
|
||||||
GtkWidget *inner;
|
GtkWidget *inner;
|
||||||
gint viewport_size;
|
gint viewport_size;
|
||||||
|
|
||||||
inner = ((tabview *)cv)->inner;
|
inner = ((tabview *)cv)->inner;
|
||||||
parent_win = gtk_widget_get_window (gtk_widget_get_parent (inner));
|
|
||||||
|
|
||||||
if (cv->vertical)
|
if (cv->vertical)
|
||||||
{
|
{
|
||||||
@@ -92,15 +83,19 @@ cv_tabs_sizealloc (GtkWidget *widget, GtkAllocation *allocation, chanview *cv)
|
|||||||
adj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (gtk_widget_get_parent (inner)));
|
adj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (gtk_widget_get_parent (inner)));
|
||||||
}
|
}
|
||||||
|
|
||||||
viewport_size = cv_tabs_get_viewport_size (parent_win, cv->vertical);
|
viewport_size = cv_tabs_get_viewport_size (adj);
|
||||||
|
|
||||||
if (gtk_adjustment_get_upper (adj) <= viewport_size)
|
if (gtk_adjustment_get_upper (adj) <= viewport_size)
|
||||||
{
|
{
|
||||||
|
if (((tabview *)cv)->b1)
|
||||||
gtk_widget_hide (((tabview *)cv)->b1);
|
gtk_widget_hide (((tabview *)cv)->b1);
|
||||||
|
if (((tabview *)cv)->b2)
|
||||||
gtk_widget_hide (((tabview *)cv)->b2);
|
gtk_widget_hide (((tabview *)cv)->b2);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
|
if (((tabview *)cv)->b1)
|
||||||
gtk_widget_show (((tabview *)cv)->b1);
|
gtk_widget_show (((tabview *)cv)->b1);
|
||||||
|
if (((tabview *)cv)->b2)
|
||||||
gtk_widget_show (((tabview *)cv)->b2);
|
gtk_widget_show (((tabview *)cv)->b2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -241,10 +236,8 @@ tab_scroll_left_up_clicked (GtkWidget *widget, chanview *cv)
|
|||||||
gint viewport_size;
|
gint viewport_size;
|
||||||
gfloat new_value;
|
gfloat new_value;
|
||||||
GtkWidget *inner;
|
GtkWidget *inner;
|
||||||
GdkWindow *parent_win;
|
|
||||||
|
|
||||||
inner = ((tabview *)cv)->inner;
|
inner = ((tabview *)cv)->inner;
|
||||||
parent_win = gtk_widget_get_window (gtk_widget_get_parent (inner));
|
|
||||||
|
|
||||||
if (cv->vertical)
|
if (cv->vertical)
|
||||||
{
|
{
|
||||||
@@ -254,7 +247,7 @@ tab_scroll_left_up_clicked (GtkWidget *widget, chanview *cv)
|
|||||||
adj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (gtk_widget_get_parent(inner)));
|
adj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (gtk_widget_get_parent(inner)));
|
||||||
}
|
}
|
||||||
|
|
||||||
viewport_size = cv_tabs_get_viewport_size (parent_win, cv->vertical);
|
viewport_size = cv_tabs_get_viewport_size (adj);
|
||||||
|
|
||||||
new_value = tab_search_offset (inner, gtk_adjustment_get_value (adj), 0, cv->vertical);
|
new_value = tab_search_offset (inner, gtk_adjustment_get_value (adj), 0, cv->vertical);
|
||||||
|
|
||||||
@@ -279,10 +272,8 @@ tab_scroll_right_down_clicked (GtkWidget *widget, chanview *cv)
|
|||||||
gint viewport_size;
|
gint viewport_size;
|
||||||
gfloat new_value;
|
gfloat new_value;
|
||||||
GtkWidget *inner;
|
GtkWidget *inner;
|
||||||
GdkWindow *parent_win;
|
|
||||||
|
|
||||||
inner = ((tabview *)cv)->inner;
|
inner = ((tabview *)cv)->inner;
|
||||||
parent_win = gtk_widget_get_window (gtk_widget_get_parent (inner));
|
|
||||||
|
|
||||||
if (cv->vertical)
|
if (cv->vertical)
|
||||||
{
|
{
|
||||||
@@ -292,7 +283,7 @@ tab_scroll_right_down_clicked (GtkWidget *widget, chanview *cv)
|
|||||||
adj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (gtk_widget_get_parent(inner)));
|
adj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (gtk_widget_get_parent(inner)));
|
||||||
}
|
}
|
||||||
|
|
||||||
viewport_size = cv_tabs_get_viewport_size (parent_win, cv->vertical);
|
viewport_size = cv_tabs_get_viewport_size (adj);
|
||||||
|
|
||||||
new_value = tab_search_offset (inner, gtk_adjustment_get_value (adj), 1, cv->vertical);
|
new_value = tab_search_offset (inner, gtk_adjustment_get_value (adj), 1, cv->vertical);
|
||||||
|
|
||||||
@@ -332,48 +323,10 @@ tab_scroll_cb (GtkWidget *widget, GdkEventScroll *event, gpointer cv)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make a Scroll (arrow) button */
|
|
||||||
|
|
||||||
static GtkWidget *
|
|
||||||
make_sbutton (GtkArrowType type, void *click_cb, void *userdata)
|
|
||||||
{
|
|
||||||
GtkWidget *button, *arrow;
|
|
||||||
const char *icon_name = "pan-end-symbolic";
|
|
||||||
|
|
||||||
button = gtk_button_new ();
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case GTK_ARROW_UP:
|
|
||||||
icon_name = "pan-up-symbolic";
|
|
||||||
break;
|
|
||||||
case GTK_ARROW_DOWN:
|
|
||||||
icon_name = "pan-down-symbolic";
|
|
||||||
break;
|
|
||||||
case GTK_ARROW_LEFT:
|
|
||||||
icon_name = "pan-start-symbolic";
|
|
||||||
break;
|
|
||||||
case GTK_ARROW_RIGHT:
|
|
||||||
default:
|
|
||||||
icon_name = "pan-end-symbolic";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
arrow = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON);
|
|
||||||
gtk_container_add (GTK_CONTAINER (button), arrow);
|
|
||||||
gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
|
|
||||||
g_signal_connect (G_OBJECT (button), "clicked",
|
|
||||||
G_CALLBACK (click_cb), userdata);
|
|
||||||
g_signal_connect (G_OBJECT (button), "scroll-event",
|
|
||||||
G_CALLBACK (tab_scroll_cb), userdata);
|
|
||||||
gtk_widget_show (arrow);
|
|
||||||
|
|
||||||
return button;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cv_tabs_init (chanview *cv)
|
cv_tabs_init (chanview *cv)
|
||||||
{
|
{
|
||||||
GtkWidget *box, *hbox = NULL;
|
GtkWidget *box;
|
||||||
GtkWidget *viewport;
|
GtkWidget *viewport;
|
||||||
GtkWidget *outer;
|
GtkWidget *outer;
|
||||||
|
|
||||||
@@ -390,12 +343,19 @@ cv_tabs_init (chanview *cv)
|
|||||||
G_CALLBACK (cv_tabs_sizealloc), cv);
|
G_CALLBACK (cv_tabs_sizealloc), cv);
|
||||||
gtk_widget_show (outer);
|
gtk_widget_show (outer);
|
||||||
|
|
||||||
viewport = gtk_viewport_new (0, 0);
|
viewport = gtk_scrolled_window_new (0, 0);
|
||||||
gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_NONE);
|
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (viewport), GTK_SHADOW_NONE);
|
||||||
|
gtk_scrolled_window_set_overlay_scrolling (GTK_SCROLLED_WINDOW (viewport), FALSE);
|
||||||
if (cv->vertical)
|
if (cv->vertical)
|
||||||
gtk_widget_set_size_request (viewport, -1, 1);
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (viewport),
|
||||||
|
GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
|
||||||
else
|
else
|
||||||
gtk_widget_set_size_request (viewport, 1, -1);
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (viewport),
|
||||||
|
GTK_POLICY_ALWAYS, GTK_POLICY_NEVER);
|
||||||
|
gtk_scrolled_window_set_min_content_width (GTK_SCROLLED_WINDOW (viewport), 1);
|
||||||
|
gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (viewport), 1);
|
||||||
|
gtk_widget_set_hexpand (viewport, TRUE);
|
||||||
|
gtk_widget_set_vexpand (viewport, TRUE);
|
||||||
g_signal_connect (G_OBJECT (viewport), "scroll-event",
|
g_signal_connect (G_OBJECT (viewport), "scroll-event",
|
||||||
G_CALLBACK (tab_scroll_cb), cv);
|
G_CALLBACK (tab_scroll_cb), cv);
|
||||||
gtk_box_pack_start (GTK_BOX (outer), viewport, 1, 1, 0);
|
gtk_box_pack_start (GTK_BOX (outer), viewport, 1, 1, 0);
|
||||||
@@ -413,35 +373,6 @@ cv_tabs_init (chanview *cv)
|
|||||||
gtk_container_add (GTK_CONTAINER (viewport), box);
|
gtk_container_add (GTK_CONTAINER (viewport), box);
|
||||||
gtk_widget_show (box);
|
gtk_widget_show (box);
|
||||||
|
|
||||||
/* if vertical, the buttons can be side by side */
|
|
||||||
if (cv->vertical)
|
|
||||||
{
|
|
||||||
hbox = gtkutil_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0);
|
|
||||||
gtk_box_pack_start (GTK_BOX (outer), hbox, 0, 0, 0);
|
|
||||||
gtk_widget_show (hbox);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* make the Scroll buttons */
|
|
||||||
((tabview *)cv)->b2 = make_sbutton (cv->vertical ?
|
|
||||||
GTK_ARROW_UP : GTK_ARROW_LEFT,
|
|
||||||
tab_scroll_left_up_clicked,
|
|
||||||
cv);
|
|
||||||
|
|
||||||
((tabview *)cv)->b1 = make_sbutton (cv->vertical ?
|
|
||||||
GTK_ARROW_DOWN : GTK_ARROW_RIGHT,
|
|
||||||
tab_scroll_right_down_clicked,
|
|
||||||
cv);
|
|
||||||
|
|
||||||
if (hbox)
|
|
||||||
{
|
|
||||||
gtk_container_add (GTK_CONTAINER (hbox), ((tabview *)cv)->b2);
|
|
||||||
gtk_container_add (GTK_CONTAINER (hbox), ((tabview *)cv)->b1);
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
gtk_box_pack_start (GTK_BOX (outer), ((tabview *)cv)->b2, 0, 0, 0);
|
|
||||||
gtk_box_pack_start (GTK_BOX (outer), ((tabview *)cv)->b1, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_container_add (GTK_CONTAINER (cv->box), outer);
|
gtk_container_add (GTK_CONTAINER (cv->box), outer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,36 @@ theme_token_to_rgb16 (ThemeSemanticToken token, guint16 *red, guint16 *green, gu
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GtkStateFlags
|
||||||
|
theme_access_state_with_base (GtkStyleContext *context, GtkStateFlags state)
|
||||||
|
{
|
||||||
|
GtkStateFlags base_state;
|
||||||
|
|
||||||
|
base_state = gtk_style_context_get_state (context);
|
||||||
|
base_state &= (GTK_STATE_FLAG_DIR_LTR | GTK_STATE_FLAG_DIR_RTL | GTK_STATE_FLAG_BACKDROP | GTK_STATE_FLAG_FOCUSED);
|
||||||
|
return base_state | state;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
theme_access_context_get_color (GtkStyleContext *context, GtkStateFlags state, GdkRGBA *out_color)
|
||||||
|
{
|
||||||
|
gtk_style_context_save (context);
|
||||||
|
gtk_style_context_set_state (context, theme_access_state_with_base (context, state));
|
||||||
|
gtk_style_context_get_color (context, gtk_style_context_get_state (context), out_color);
|
||||||
|
gtk_style_context_restore (context);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
theme_access_context_get_background_color (GtkStyleContext *context, GtkStateFlags state, GdkRGBA *out_color)
|
||||||
|
{
|
||||||
|
gtk_style_context_save (context);
|
||||||
|
gtk_style_context_set_state (context, theme_access_state_with_base (context, state));
|
||||||
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||||
|
gtk_style_context_get_background_color (context, gtk_style_context_get_state (context), out_color);
|
||||||
|
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||||
|
gtk_style_context_restore (context);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
theme_access_get_gtk_palette_map (GtkWidget *widget, ThemeGtkPaletteMap *out_map)
|
theme_access_get_gtk_palette_map (GtkWidget *widget, ThemeGtkPaletteMap *out_map)
|
||||||
{
|
{
|
||||||
@@ -96,13 +126,11 @@ theme_access_get_gtk_palette_map (GtkWidget *widget, ThemeGtkPaletteMap *out_map
|
|||||||
if (context == NULL)
|
if (context == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &out_map->text_foreground);
|
theme_access_context_get_color (context, GTK_STATE_FLAG_NORMAL, &out_map->text_foreground);
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
theme_access_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &out_map->text_background);
|
||||||
gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &out_map->text_background);
|
theme_access_context_get_color (context, GTK_STATE_FLAG_SELECTED, &out_map->selection_foreground);
|
||||||
gtk_style_context_get_color (context, GTK_STATE_FLAG_SELECTED, &out_map->selection_foreground);
|
theme_access_context_get_background_color (context, GTK_STATE_FLAG_SELECTED, &out_map->selection_background);
|
||||||
gtk_style_context_get_background_color (context, GTK_STATE_FLAG_SELECTED, &out_map->selection_background);
|
theme_access_context_get_color (context, GTK_STATE_FLAG_LINK, &accent);
|
||||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
|
||||||
gtk_style_context_get_color (context, GTK_STATE_FLAG_LINK, &accent);
|
|
||||||
if (accent.alpha <= 0.0)
|
if (accent.alpha <= 0.0)
|
||||||
accent = out_map->selection_background;
|
accent = out_map->selection_background;
|
||||||
out_map->accent = accent;
|
out_map->accent = accent;
|
||||||
|
|||||||
Reference in New Issue
Block a user