mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-11-10 18:13:46 +01:00
Finish renaming
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
parent
c64b4f545a
commit
8b701f609c
@ -2,7 +2,8 @@
|
||||
|
||||
" This is a sample plugin that can be used for synctex forward synchronization.
|
||||
" It currently uses latexsuite to obtain the file name of the document. If you
|
||||
" are not using latexsuite, it should be enough to adopt output accordingly.
|
||||
" are not using latexsuite, it should be enough to adopt the calculation of
|
||||
" 'output' accordingly.
|
||||
|
||||
" avoid re-execution
|
||||
if exists("b:did_zathura_synctex_plugin") || !exists("*Tex_GetMainFileName")
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* See LICENSE file for license and copyright information */
|
||||
|
||||
#include "synctex-dbus.h"
|
||||
#include "dbus-interface.h"
|
||||
#include "synctex.h"
|
||||
#include "macros.h"
|
||||
#include "zathura.h"
|
||||
@ -11,7 +11,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
G_DEFINE_TYPE(ZathuraSynctexDbus, zathura_synctex_dbus, G_TYPE_OBJECT)
|
||||
G_DEFINE_TYPE(ZathuraDbus, zathura_dbus, G_TYPE_OBJECT)
|
||||
|
||||
/* template for bus name */
|
||||
static const char DBUS_NAME_TEMPLATE[] = "org.pwmt.zathura.PID-%d";
|
||||
@ -29,7 +29,7 @@ typedef struct private_s {
|
||||
} private_t;
|
||||
|
||||
#define GET_PRIVATE(obj) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE((obj), ZATHURA_TYPE_SYNCTEX_DBUS, \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE((obj), ZATHURA_TYPE_DBUS, \
|
||||
private_t))
|
||||
|
||||
/* in dbus-interface-definitions.c */
|
||||
@ -40,8 +40,8 @@ static const GDBusInterfaceVTable interface_vtable;
|
||||
static void
|
||||
finalize(GObject* object)
|
||||
{
|
||||
ZathuraSynctexDbus* synctex_dbus = ZATHURA_SYNCTEX_DBUS(object);
|
||||
private_t* priv = GET_PRIVATE(synctex_dbus);
|
||||
ZathuraDbus* dbus = ZATHURA_DBUS(object);
|
||||
private_t* priv = GET_PRIVATE(dbus);
|
||||
|
||||
if (priv->connection != NULL && priv->registration_id > 0) {
|
||||
g_dbus_connection_unregister_object(priv->connection, priv->registration_id);
|
||||
@ -55,11 +55,11 @@ finalize(GObject* object)
|
||||
g_dbus_node_info_unref(priv->introspection_data);
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS(zathura_synctex_dbus_parent_class)->finalize(object);
|
||||
G_OBJECT_CLASS(zathura_dbus_parent_class)->finalize(object);
|
||||
}
|
||||
|
||||
static void
|
||||
zathura_synctex_dbus_class_init(ZathuraSynctexDbusClass* class)
|
||||
zathura_dbus_class_init(ZathuraDbusClass* class)
|
||||
{
|
||||
/* add private members */
|
||||
g_type_class_add_private(class, sizeof(private_t));
|
||||
@ -70,9 +70,9 @@ zathura_synctex_dbus_class_init(ZathuraSynctexDbusClass* class)
|
||||
}
|
||||
|
||||
static void
|
||||
zathura_synctex_dbus_init(ZathuraSynctexDbus* synctex_dbus)
|
||||
zathura_dbus_init(ZathuraDbus* dbus)
|
||||
{
|
||||
private_t* priv = GET_PRIVATE(synctex_dbus);
|
||||
private_t* priv = GET_PRIVATE(dbus);
|
||||
priv->zathura = NULL;
|
||||
priv->introspection_data = NULL;
|
||||
priv->connection = NULL;
|
||||
@ -85,8 +85,8 @@ bus_acquired(GDBusConnection* connection, const gchar* name, void* data)
|
||||
{
|
||||
girara_debug("Bus acquired at '%s'.", name);
|
||||
|
||||
ZathuraSynctexDbus* dbus = data;
|
||||
private_t* priv = GET_PRIVATE(dbus);
|
||||
ZathuraDbus* dbus = data;
|
||||
private_t* priv = GET_PRIVATE(dbus);
|
||||
|
||||
GError* error = NULL;
|
||||
priv->registration_id = g_dbus_connection_register_object(connection,
|
||||
@ -117,17 +117,17 @@ name_lost(GDBusConnection* UNUSED(connection), const gchar* name,
|
||||
name);
|
||||
}
|
||||
|
||||
ZathuraSynctexDbus*
|
||||
zathura_synctex_dbus_new(zathura_t* zathura)
|
||||
ZathuraDbus*
|
||||
zathura_dbus_new(zathura_t* zathura)
|
||||
{
|
||||
GObject* obj = g_object_new(ZATHURA_TYPE_SYNCTEX_DBUS, NULL);
|
||||
GObject* obj = g_object_new(ZATHURA_TYPE_DBUS, NULL);
|
||||
if (obj == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ZathuraSynctexDbus* synctex_dbus = ZATHURA_SYNCTEX_DBUS(obj);
|
||||
private_t* priv = GET_PRIVATE(synctex_dbus);
|
||||
priv->zathura = zathura;
|
||||
ZathuraDbus* dbus = ZATHURA_DBUS(obj);
|
||||
private_t* priv = GET_PRIVATE(dbus);
|
||||
priv->zathura = zathura;
|
||||
|
||||
GError* error = NULL;
|
||||
priv->introspection_data = g_dbus_node_info_new_for_xml(DBUS_INTERFACE_XML, &error);
|
||||
@ -141,10 +141,10 @@ zathura_synctex_dbus_new(zathura_t* zathura)
|
||||
char* well_known_name = g_strdup_printf(DBUS_NAME_TEMPLATE, getpid());
|
||||
priv->owner_id = g_bus_own_name(G_BUS_TYPE_SESSION,
|
||||
well_known_name, G_BUS_NAME_OWNER_FLAGS_NONE, bus_acquired,
|
||||
name_acquired, name_lost, synctex_dbus, NULL);
|
||||
name_acquired, name_lost, dbus, NULL);
|
||||
g_free(well_known_name);
|
||||
|
||||
return synctex_dbus;
|
||||
return dbus;
|
||||
}
|
||||
|
||||
/* D-Bus handler */
|
||||
@ -156,8 +156,8 @@ handle_method_call(GDBusConnection* UNUSED(connection),
|
||||
const gchar* method_name, GVariant* parameters,
|
||||
GDBusMethodInvocation* invocation, void* data)
|
||||
{
|
||||
ZathuraSynctexDbus* synctex_dbus = data;
|
||||
private_t* priv = GET_PRIVATE(synctex_dbus);
|
||||
ZathuraDbus* dbus = data;
|
||||
private_t* priv = GET_PRIVATE(dbus);
|
||||
|
||||
girara_debug("Handling call '%s.%s' on '%s'.", interface_name, method_name,
|
||||
object_path);
|
||||
@ -243,8 +243,8 @@ handle_get_property(GDBusConnection* UNUSED(connection),
|
||||
const gchar* UNUSED(interface_name), const gchar* property_name,
|
||||
GError** error, void* data)
|
||||
{
|
||||
ZathuraSynctexDbus* synctex_dbus = data;
|
||||
private_t* priv = GET_PRIVATE(synctex_dbus);
|
||||
ZathuraDbus* dbus = data;
|
||||
private_t* priv = GET_PRIVATE(dbus);
|
||||
|
||||
if (g_strcmp0(property_name, "filename") == 0) {
|
||||
if (priv->zathura->document == NULL) {
|
58
dbus-interface.h
Normal file
58
dbus-interface.h
Normal file
@ -0,0 +1,58 @@
|
||||
/* See LICENSE file for license and copyright information */
|
||||
|
||||
#ifndef DBUS_INTERFACE_H
|
||||
#define DBUS_INTERFACE_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <girara/types.h>
|
||||
#include <glib-object.h>
|
||||
#include "types.h"
|
||||
|
||||
typedef struct zathura_dbus_class_s ZathuraDbusClass;
|
||||
|
||||
struct zathura_dbus_s
|
||||
{
|
||||
GObject parent;
|
||||
};
|
||||
|
||||
struct zathura_dbus_class_s
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
#define ZATHURA_TYPE_DBUS \
|
||||
(zathura_dbus_get_type())
|
||||
#define ZATHURA_DBUS(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj), ZATHURA_TYPE_DBUS, \
|
||||
ZathuraDbus))
|
||||
#define ZATHURA_DBUS_CLASS(obj) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((obj), ZATHURA_TYPE_DBUS, \
|
||||
ZathuraDbus))
|
||||
#define ZATHURA_IS_DBUS(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj), ZATHURA_TYPE_DBUS))
|
||||
#define ZATHURA_IS_DBUS_CLASS(obj) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((obj), ZATHURA_TYPE_DBUS))
|
||||
#define ZATHURA_DBUS_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS((obj), ZATHURA_TYPE_DBUS, \
|
||||
ZathuraDbusClass))
|
||||
|
||||
GType zathura_dbus_get_type(void);
|
||||
|
||||
ZathuraDbus* zathura_dbus_new(zathura_t* zathura);
|
||||
|
||||
/**
|
||||
* Look for zathura instance having filename open and cause it to open give page
|
||||
* and highlight rectangles on the given page
|
||||
*
|
||||
* @param filename filename
|
||||
* @param page page number
|
||||
* @param rectangles list of rectangles to highlight
|
||||
* @returns true if a instance was found that has the given filename open, false
|
||||
* otherwise
|
||||
*/
|
||||
bool zathura_dbus_goto_page_and_highlight(const char* filename, int page,
|
||||
girara_list_t* rectangles);
|
||||
|
||||
bool zathura_dbus_synctex_position(const char* filename, const char* position);
|
||||
|
||||
#endif
|
2
main.c
2
main.c
@ -16,7 +16,7 @@
|
||||
|
||||
#include "zathura.h"
|
||||
#include "utils.h"
|
||||
#include "synctex-dbus.h"
|
||||
#include "dbus-interface.h"
|
||||
|
||||
/* main function */
|
||||
int
|
||||
|
@ -1,58 +0,0 @@
|
||||
/* See LICENSE file for license and copyright information */
|
||||
|
||||
#ifndef SYNCTEX_DBUS_H
|
||||
#define SYNCTEX_DBUS_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <girara/types.h>
|
||||
#include <glib-object.h>
|
||||
#include "types.h"
|
||||
|
||||
typedef struct zathura_synctex_dbus_class_s ZathuraSynctexDbusClass;
|
||||
|
||||
struct zathura_synctex_dbus_s
|
||||
{
|
||||
GObject parent;
|
||||
};
|
||||
|
||||
struct zathura_synctex_dbus_class_s
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
#define ZATHURA_TYPE_SYNCTEX_DBUS \
|
||||
(zathura_synctex_dbus_get_type())
|
||||
#define ZATHURA_SYNCTEX_DBUS(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj), ZATHURA_TYPE_SYNCTEX_DBUS, \
|
||||
ZathuraSynctexDbus))
|
||||
#define ZATHURA_SYNCTEX_DBUS_CLASS(obj) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((obj), ZATHURA_TYPE_SYNCTEX_DBUS, \
|
||||
ZathuraSynctexDbus))
|
||||
#define ZATHURA_IS_SYNCTEX_DBUS(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj), ZATHURA_TYPE_SYNCTEX_DBUS))
|
||||
#define ZATHURA_IS_SYNCTEX_DBUS_CLASS(obj) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((obj), ZATHURA_TYPE_SYNCTEX_DBUS))
|
||||
#define ZATHURA_SYNCTEX_DBUS_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS((obj), ZATHURA_TYPE_SYNCTEX_DBUS, \
|
||||
ZathuraSynctexDbusClass))
|
||||
|
||||
GType zathura_synctex_dbus_get_type(void);
|
||||
|
||||
ZathuraSynctexDbus* zathura_synctex_dbus_new(zathura_t* zathura);
|
||||
|
||||
/**
|
||||
* Look for zathura instance having filename open and cause it to open give page
|
||||
* and move to the given position on that page.
|
||||
*
|
||||
* @param filename filename
|
||||
* @param page page number
|
||||
* @param position_x x coordinate on the page
|
||||
* @param position_y y coordinate on the page
|
||||
* @returns true if a instance was found that has the given filename open, false
|
||||
* otherwise
|
||||
*/
|
||||
bool zathura_dbus_goto_page_and_highlight(const char* filename, int page, girara_list_t* rectangles);
|
||||
|
||||
bool zathura_dbus_synctex_position(const char* filename, const char* position);
|
||||
|
||||
#endif
|
4
types.h
4
types.h
@ -36,9 +36,9 @@ typedef struct zathura_plugin_manager_s zathura_plugin_manager_t;
|
||||
typedef struct zathura_renderer_s ZathuraRenderer;
|
||||
|
||||
/**
|
||||
* Synctex DBus manager
|
||||
* D-Bus manager
|
||||
*/
|
||||
typedef struct zathura_synctex_dbus_s ZathuraSynctexDbus;
|
||||
typedef struct zathura_dbus_s ZathuraDbus;
|
||||
|
||||
/**
|
||||
* Error types
|
||||
|
16
zathura.c
16
zathura.c
@ -34,7 +34,7 @@
|
||||
#include "page-widget.h"
|
||||
#include "plugin.h"
|
||||
#include "adjustment.h"
|
||||
#include "synctex-dbus.h"
|
||||
#include "dbus-interface.h"
|
||||
|
||||
typedef struct zathura_document_info_s {
|
||||
zathura_t* zathura;
|
||||
@ -229,10 +229,10 @@ zathura_init(zathura_t* zathura)
|
||||
zathura->jumplist.cur = NULL;
|
||||
|
||||
/* Start D-Bus service */
|
||||
bool synctex_dbus = true;
|
||||
girara_setting_get(zathura->ui.session, "dbus-service", &synctex_dbus);
|
||||
if (synctex_dbus == true) {
|
||||
zathura->synctex.dbus = zathura_synctex_dbus_new(zathura);
|
||||
bool dbus = true;
|
||||
girara_setting_get(zathura->ui.session, "dbus-service", &dbus);
|
||||
if (dbus == true) {
|
||||
zathura->dbus = zathura_dbus_new(zathura);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -260,9 +260,9 @@ zathura_free(zathura_t* zathura)
|
||||
document_close(zathura, false);
|
||||
|
||||
/* stop D-Bus */
|
||||
if (zathura->synctex.dbus != NULL) {
|
||||
g_object_unref(zathura->synctex.dbus);
|
||||
zathura->synctex.dbus = NULL;
|
||||
if (zathura->dbus != NULL) {
|
||||
g_object_unref(zathura->dbus);
|
||||
zathura->dbus = NULL;
|
||||
}
|
||||
|
||||
if (zathura->ui.session != NULL) {
|
||||
|
@ -133,7 +133,6 @@ struct zathura_s
|
||||
{
|
||||
bool enabled;
|
||||
gchar* editor;
|
||||
ZathuraSynctexDbus* dbus;
|
||||
} synctex;
|
||||
|
||||
struct
|
||||
@ -185,6 +184,7 @@ struct zathura_s
|
||||
zathura_document_t* document; /**< The current document */
|
||||
GtkWidget** pages; /**< The page widgets */
|
||||
zathura_database_t* database; /**< The database */
|
||||
ZathuraDbus* dbus; /**< D-Bus service */
|
||||
|
||||
/**
|
||||
* File monitor
|
||||
|
Loading…
Reference in New Issue
Block a user