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 \
|
||||
build-essential pkg-config meson ninja-build cmake \
|
||||
gettext \
|
||||
libcanberra-dev libdbus-glib-1-dev libglib2.0-dev \
|
||||
libcanberra-dev libglib2.0-dev \
|
||||
libarchive-dev \
|
||||
libgtk-3-dev \
|
||||
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 \
|
||||
gtk3 \
|
||||
openssl \
|
||||
dbus-glib \
|
||||
libcanberra \
|
||||
libayatana-appindicator \
|
||||
luajit \
|
||||
|
||||
@@ -22,7 +22,7 @@ if get_option('gtk-frontend')
|
||||
endif
|
||||
|
||||
desktop_conf = configuration_data()
|
||||
if dbus_glib_dep.found()
|
||||
if dbus_dep.found()
|
||||
desktop_conf.set('exec_command', 'zoitechat --existing %U')
|
||||
else
|
||||
desktop_conf.set('exec_command', 'zoitechat %U')
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
}
|
||||
},
|
||||
"modules": [
|
||||
"shared-modules/dbus-glib/dbus-glib.json",
|
||||
"shared-modules/lua5.4/lua-5.4.json",
|
||||
"shared-modules/libcanberra/libcanberra.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',
|
||||
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 = []
|
||||
if cc.get_id() == 'msvc'
|
||||
@@ -39,7 +39,7 @@ config_h.set10('ENABLE_NLS', true)
|
||||
# Optional features
|
||||
config_h.set('USE_OPENSSL', libssl_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_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',
|
||||
'TLS (openssl)': libssl_dep.found(),
|
||||
'Plugin Support': get_option('plugin'),
|
||||
'DBus Support': dbus_glib_dep.found(),
|
||||
'DBus Support': dbus_dep.found(),
|
||||
'libcanberra': libcanberra_dep.found(),
|
||||
}, section: 'Features')
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ arch=('x86_64')
|
||||
url='https://github.com/zoitechat/zoitechat'
|
||||
license=('GPL-2.0-or-later')
|
||||
depends=(
|
||||
'dbus-glib'
|
||||
'glib2'
|
||||
'gtk3'
|
||||
'iso-codes'
|
||||
|
||||
@@ -82,10 +82,6 @@ has_theme_argument (void)
|
||||
|
||||
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;
|
||||
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.
|
||||
* Copyright (C) 2006 Claessens Xavier
|
||||
*
|
||||
* 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 <gio/gio.h>
|
||||
#include <glib.h>
|
||||
#include <stdlib.h>
|
||||
#include "../marshal.c"
|
||||
|
||||
#define DBUS_SERVICE "org.zoitechat.service"
|
||||
#define DBUS_REMOTE "/org/zoitechat/Remote"
|
||||
#define DBUS_REMOTE_CONNECTION_INTERFACE "org.zoitechat.connection"
|
||||
#define DBUS_REMOTE_PLUGIN_INTERFACE "org.zoitechat.plugin"
|
||||
#define DBUS_CONNECTION_PATH "/org/zoitechat"
|
||||
#define DBUS_CONNECTION_INTERFACE "org.zoitechat.connection"
|
||||
#define DBUS_PLUGIN_INTERFACE "org.zoitechat.plugin"
|
||||
|
||||
guint command_id;
|
||||
guint server_id;
|
||||
|
||||
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)
|
||||
static gboolean
|
||||
call_sync (GDBusProxy *proxy, const char *method, GVariant *params, GVariant **out)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GVariant *result;
|
||||
|
||||
if (hook_id == command_id) {
|
||||
if (!dbus_g_proxy_call (proxy, "Unhook",
|
||||
&error,
|
||||
G_TYPE_UINT, hook_id,
|
||||
G_TYPE_INVALID, G_TYPE_INVALID)) {
|
||||
write_error ("Failed to complete unhook", &error);
|
||||
}
|
||||
/* 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
|
||||
unload_cb (void)
|
||||
result = g_dbus_proxy_call_sync (proxy,
|
||||
method,
|
||||
params,
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
-1,
|
||||
NULL,
|
||||
&error);
|
||||
if (!result)
|
||||
{
|
||||
g_print ("Good bye !\n");
|
||||
exit (EXIT_SUCCESS);
|
||||
g_printerr ("%s failed: %s\n", method, error->message);
|
||||
g_clear_error (&error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (out)
|
||||
*out = result;
|
||||
else
|
||||
g_variant_unref (result);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
DBusGConnection *connection;
|
||||
DBusGProxy *remote_object;
|
||||
GMainLoop *mainloop;
|
||||
gchar *path;
|
||||
GDBusConnection *connection;
|
||||
GDBusProxy *connection_proxy;
|
||||
GDBusProxy *plugin_proxy;
|
||||
GVariant *connect_result = NULL;
|
||||
gchar *remote_path = NULL;
|
||||
gchar *command = NULL;
|
||||
const char *path_tmp;
|
||||
int status = EXIT_FAILURE;
|
||||
GError *error = NULL;
|
||||
|
||||
#if ! GLIB_CHECK_VERSION (2, 36, 0)
|
||||
g_type_init ();
|
||||
#endif
|
||||
|
||||
connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
|
||||
if (connection == NULL) {
|
||||
write_error ("Couldn't connect to session bus", &error);
|
||||
connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
|
||||
if (!connection)
|
||||
{
|
||||
g_printerr ("Bus connection failed: %s\n", error->message);
|
||||
g_clear_error (&error);
|
||||
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_REMOTE,
|
||||
DBUS_REMOTE_CONNECTION_INTERFACE);
|
||||
if (!dbus_g_proxy_call (remote_object, "Connect",
|
||||
&error,
|
||||
G_TYPE_STRING, argv[0],
|
||||
G_TYPE_STRING, "example",
|
||||
G_TYPE_STRING, "Example of a D-Bus client",
|
||||
G_TYPE_STRING, "1.0",
|
||||
G_TYPE_INVALID,
|
||||
G_TYPE_STRING, &path, G_TYPE_INVALID)) {
|
||||
write_error ("Failed to complete Connect", &error);
|
||||
DBUS_CONNECTION_PATH,
|
||||
DBUS_CONNECTION_INTERFACE,
|
||||
NULL,
|
||||
&error);
|
||||
if (!connection_proxy)
|
||||
{
|
||||
g_printerr ("Connection proxy failed: %s\n", error->message);
|
||||
g_clear_error (&error);
|
||||
g_object_unref (connection);
|
||||
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,
|
||||
path,
|
||||
DBUS_REMOTE_PLUGIN_INTERFACE);
|
||||
g_free (path);
|
||||
|
||||
if (!dbus_g_proxy_call (remote_object, "HookCommand",
|
||||
&error,
|
||||
G_TYPE_STRING, "test",
|
||||
G_TYPE_INT, 0,
|
||||
G_TYPE_STRING, "Simple D-BUS example",
|
||||
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;
|
||||
remote_path,
|
||||
DBUS_PLUGIN_INTERFACE,
|
||||
NULL,
|
||||
&error);
|
||||
if (!plugin_proxy)
|
||||
{
|
||||
g_printerr ("Plugin proxy failed: %s\n", error->message);
|
||||
g_clear_error (&error);
|
||||
goto cleanup;
|
||||
}
|
||||
g_print ("Command hook id=%d\n", command_id);
|
||||
|
||||
if (!dbus_g_proxy_call (remote_object, "HookServer",
|
||||
&error,
|
||||
G_TYPE_STRING, "RAW LINE",
|
||||
G_TYPE_INT, 0,
|
||||
G_TYPE_INT, 0, G_TYPE_INVALID,
|
||||
G_TYPE_UINT, &server_id, G_TYPE_INVALID)) {
|
||||
write_error ("Failed to complete HookServer", &error);
|
||||
return EXIT_FAILURE;
|
||||
if (argc > 1)
|
||||
command = g_strjoinv (" ", &argv[1]);
|
||||
else
|
||||
command = g_strdup ("gui focus");
|
||||
|
||||
if (!call_sync (plugin_proxy, "Command", g_variant_new ("(s)", command), NULL))
|
||||
{
|
||||
g_object_unref (plugin_proxy);
|
||||
goto cleanup;
|
||||
}
|
||||
g_print ("Server hook id=%d\n", server_id);
|
||||
|
||||
dbus_g_object_register_marshaller (
|
||||
_zoitechat_marshal_VOID__POINTER_POINTER_UINT_UINT,
|
||||
G_TYPE_NONE,
|
||||
G_TYPE_STRV, G_TYPE_STRV, G_TYPE_UINT, G_TYPE_UINT,
|
||||
G_TYPE_INVALID);
|
||||
call_sync (connection_proxy, "Disconnect", g_variant_new ("()"), NULL);
|
||||
status = EXIT_SUCCESS;
|
||||
g_object_unref (plugin_proxy);
|
||||
|
||||
dbus_g_object_register_marshaller (
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE,
|
||||
G_TYPE_INVALID);
|
||||
|
||||
dbus_g_proxy_add_signal (remote_object, "CommandSignal",
|
||||
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;
|
||||
cleanup:
|
||||
g_free (command);
|
||||
g_free (remote_path);
|
||||
g_object_unref (connection_proxy);
|
||||
g_object_unref (connection);
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
dbus_deps = [
|
||||
dbus_glib_dep
|
||||
]
|
||||
dbus_deps = []
|
||||
|
||||
dbus_sources = [
|
||||
'dbus-plugin.c',
|
||||
@@ -35,16 +33,8 @@ configure_file(
|
||||
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',
|
||||
sources: [dbus_remote_object, marshal] + dbus_sources,
|
||||
sources: marshal + dbus_sources,
|
||||
c_args: dbus_cargs,
|
||||
dependencies: common_deps + dbus_deps,
|
||||
include_directories: dbus_includes,
|
||||
|
||||
@@ -115,7 +115,7 @@ if libssl_dep.found()
|
||||
common_deps += libssl_dep
|
||||
endif
|
||||
|
||||
if dbus_glib_dep.found()
|
||||
if dbus_dep.found()
|
||||
subdir('dbus')
|
||||
common_deps += zoitechat_dbus_dep
|
||||
common_includes += include_directories('dbus')
|
||||
|
||||
@@ -61,28 +61,19 @@ static tab_scroll_animation *tab_right_animation;
|
||||
*/
|
||||
|
||||
static inline gint
|
||||
cv_tabs_get_viewport_size (GdkWindow *parent_win, gboolean vertical)
|
||||
cv_tabs_get_viewport_size (GtkAdjustment *adj)
|
||||
{
|
||||
gint viewport_size = 0;
|
||||
|
||||
if (vertical)
|
||||
viewport_size = gdk_window_get_height (parent_win);
|
||||
else
|
||||
viewport_size = gdk_window_get_width (parent_win);
|
||||
|
||||
return viewport_size;
|
||||
return (gint) gtk_adjustment_get_page_size (adj);
|
||||
}
|
||||
|
||||
static void
|
||||
cv_tabs_sizealloc (GtkWidget *widget, GtkAllocation *allocation, chanview *cv)
|
||||
{
|
||||
GdkWindow *parent_win;
|
||||
GtkAdjustment *adj;
|
||||
GtkWidget *inner;
|
||||
gint viewport_size;
|
||||
|
||||
inner = ((tabview *)cv)->inner;
|
||||
parent_win = gtk_widget_get_window (gtk_widget_get_parent (inner));
|
||||
|
||||
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)));
|
||||
}
|
||||
|
||||
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 (((tabview *)cv)->b1)
|
||||
gtk_widget_hide (((tabview *)cv)->b1);
|
||||
if (((tabview *)cv)->b2)
|
||||
gtk_widget_hide (((tabview *)cv)->b2);
|
||||
} else
|
||||
{
|
||||
if (((tabview *)cv)->b1)
|
||||
gtk_widget_show (((tabview *)cv)->b1);
|
||||
if (((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;
|
||||
gfloat new_value;
|
||||
GtkWidget *inner;
|
||||
GdkWindow *parent_win;
|
||||
|
||||
inner = ((tabview *)cv)->inner;
|
||||
parent_win = gtk_widget_get_window (gtk_widget_get_parent (inner));
|
||||
|
||||
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)));
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -279,10 +272,8 @@ tab_scroll_right_down_clicked (GtkWidget *widget, chanview *cv)
|
||||
gint viewport_size;
|
||||
gfloat new_value;
|
||||
GtkWidget *inner;
|
||||
GdkWindow *parent_win;
|
||||
|
||||
inner = ((tabview *)cv)->inner;
|
||||
parent_win = gtk_widget_get_window (gtk_widget_get_parent (inner));
|
||||
|
||||
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)));
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -332,48 +323,10 @@ tab_scroll_cb (GtkWidget *widget, GdkEventScroll *event, gpointer cv)
|
||||
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
|
||||
cv_tabs_init (chanview *cv)
|
||||
{
|
||||
GtkWidget *box, *hbox = NULL;
|
||||
GtkWidget *box;
|
||||
GtkWidget *viewport;
|
||||
GtkWidget *outer;
|
||||
|
||||
@@ -390,12 +343,19 @@ cv_tabs_init (chanview *cv)
|
||||
G_CALLBACK (cv_tabs_sizealloc), cv);
|
||||
gtk_widget_show (outer);
|
||||
|
||||
viewport = gtk_viewport_new (0, 0);
|
||||
gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_NONE);
|
||||
viewport = gtk_scrolled_window_new (0, 0);
|
||||
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)
|
||||
gtk_widget_set_size_request (viewport, -1, 1);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (viewport),
|
||||
GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
|
||||
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_CALLBACK (tab_scroll_cb), cv);
|
||||
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_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);
|
||||
}
|
||||
|
||||
|
||||
@@ -82,6 +82,36 @@ theme_token_to_rgb16 (ThemeSemanticToken token, guint16 *red, guint16 *green, gu
|
||||
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
|
||||
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)
|
||||
return FALSE;
|
||||
|
||||
gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &out_map->text_foreground);
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &out_map->text_background);
|
||||
gtk_style_context_get_color (context, GTK_STATE_FLAG_SELECTED, &out_map->selection_foreground);
|
||||
gtk_style_context_get_background_color (context, GTK_STATE_FLAG_SELECTED, &out_map->selection_background);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
gtk_style_context_get_color (context, GTK_STATE_FLAG_LINK, &accent);
|
||||
theme_access_context_get_color (context, GTK_STATE_FLAG_NORMAL, &out_map->text_foreground);
|
||||
theme_access_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);
|
||||
theme_access_context_get_background_color (context, GTK_STATE_FLAG_SELECTED, &out_map->selection_background);
|
||||
theme_access_context_get_color (context, GTK_STATE_FLAG_LINK, &accent);
|
||||
if (accent.alpha <= 0.0)
|
||||
accent = out_map->selection_background;
|
||||
out_map->accent = accent;
|
||||
|
||||
Reference in New Issue
Block a user