Commit 9de50740 authored by Victor Ananjevsky's avatar Victor Ananjevsky

add optional standalone build

parent d25476ef
......@@ -37,3 +37,16 @@ Additionally, you can build yad with the following libraries:
* Webkit - for supporting HTML dialog (http://webkitgtk.org)
* GtkSourceView - for enabling syntax highlighting in text-info dialog (https://wiki.gnome.org/Projects/GtkSourceView)
* GSpell - for support spell checking in text fields (https://wiki.gnome.org/Projects/gspell)
In standalone build (configure option --enable-standalone) some defaults can be redefined with the following defines
BORDERS - set the default border width around dialog. Default is 5
REMAIN - if defined, timeout indicator will show the remaining time
COMBO_EDIT - if defined, combo-box in entry dialog will be always editable
TERM_CMD - string with terminal command. Default is "xterm -e '%s'"
OPEN_CMD - string with open command. Default is "xdg-open '%s'"
DATE_FMT - string with date output format. Default is "%x". See strftime(3) for details
URI_COLOR - color for URIs in text-info dialog. Default is blue
MAX_TABS - set the number of tabs for tabbed dialog. Default is 100
Defines can be added througs CFLAGS environment variable
......@@ -89,6 +89,16 @@ if test x$have_sourceview = xyes; then
AC_DEFINE([HAVE_SOURCEVIEW], [1], [Define this if you need GtkSourceView support])
fi
dnl icon browser
AC_ARG_ENABLE([standalone],
[AS_HELP_STRING([--enable-standalone],
[Build standalone YAD binary (wihtout gsettings)])],
[build_sa=$enableval], [build_sa=no])
AM_CONDITIONAL([STANDALONE], [test x$build_sa = xyes])
if test x$build_sa = xyes; then
AC_DEFINE([STANDALONE], [1], [Define this if you need standalone YAD binary])
fi
dnl pfd
AC_ARG_ENABLE([pfd],
[AS_HELP_STRING([--enable-pfd],
......@@ -154,6 +164,7 @@ echo " HTML widget - $have_html"
echo " GtkSourceView - $have_sourceview"
echo " Spell checking - $have_spell"
echo " Path to rgb.txt - $with_rgb"
echo " Standalone build - $build_sa"
echo " pfd - $build_pfd"
echo " Icon browser - $build_ib"
echo
......@@ -35,6 +35,10 @@ if HTML
yad_SOURCES += html.c
endif
if STANDALONE
yad_SOURCES += defaults.h
endif
yad_CFLAGS = $(GTK_CFLAGS) $(HTML_CFLAGS) $(SPELL_CFLAGS) $(SOURCEVIEW_CFLAGS)
yad_LDADD = $(GTK_LIBS) $(HTML_LIBS) $(SPELL_LIBS) $(SOURCEVIEW_LIBS)
......
#ifndef __YAD_DEFS_H__
#define __YAD_DEFS_H__
#ifndef BORDERS
#define BORDERS 5
#endif
#ifndef REMAIN
#define SHOW_REMAIN FALSE
#else
#define SHOW_REMAIN TRUE
#endif
#ifndef COMBO_EDIT
#define COMBO_ALWAYS_EDIT FALSE
#else
#define COMBO_ALWAYS_EDIT TRUE
#endif
#ifndef TERM_CMD
#define TERM_CMD "xterm -e '%s'"
#endif
#ifndef OPEN_CMD
#define OPEN_CMD "xdg-open '%s'"
#endif
#ifndef DATE_FMT
#define DATE_FMT "%x"
#endif
#ifndef URI_COLOR
#define URI_COLOR "blue"
#endif
#ifndef MAX_TABS
#define MAX_TABS 100
#endif
#endif /* __YAD_DEFS_H__ */
......@@ -188,7 +188,13 @@ entry_create_widget (GtkWidget * dlg)
{
gint active, i;
if (options.common_data.editable || g_settings_get_boolean (settings, "combo-always-editable"))
if (options.common_data.editable ||
#ifndef STANDALONE
g_settings_get_boolean (settings, "combo-always-editable")
#else
COMBO_ALWAYS_EDIT
#endif
)
{
c = gtk_combo_box_text_new_with_entry ();
gtk_widget_set_name (c, "yad-entry-edit-combo");
......
......@@ -346,7 +346,11 @@ parse_desktop_file (gchar * filename)
gchar *url = g_key_file_get_string (kf, "Desktop Entry", "URL", NULL);
if (url)
{
#ifndef STANDALONE
ent->command = g_strdup_printf (g_settings_get_string (settings, "open-command"), url);
#else
ent->command = g_strdup_printf (OPEN_CMD, url);
#endif
g_free (url);
}
}
......
......@@ -34,9 +34,12 @@
#include "yad.h"
YadOptions options;
GSettings *settings;
GtkIconTheme *yad_icon_theme;
#ifndef STANDALONE
GSettings *settings;
#endif
GdkPixbuf *big_fallback_image = NULL;
GdkPixbuf *small_fallback_image = NULL;
......@@ -120,7 +123,11 @@ timeout_cb (gpointer data)
{
gdouble percent = ((gdouble) options.data.timeout - count) / (gdouble) options.data.timeout;
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (w), percent);
#ifndef STANDALONE
if (g_settings_get_boolean (settings, "show-remain"))
#else
if (SHOW_REMAIN)
#endif
{
gchar *lbl = g_strdup_printf (_("%d sec"), options.data.timeout - count);
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (w), lbl);
......@@ -394,7 +401,11 @@ create_dialog (void)
gtk_box_pack_end (GTK_BOX (cbox), topb, FALSE, FALSE, 2);
}
#ifndef STANDALONE
if (g_settings_get_boolean (settings, "show-remain"))
#else
if (SHOW_REMAIN)
#endif
{
gchar *lbl = g_strdup_printf (_("%d sec"), options.data.timeout);
gtk_progress_bar_set_show_text (GTK_PROGRESS_BAR (topb), TRUE);
......@@ -667,7 +678,9 @@ main (gint argc, gchar ** argv)
gtk_init (&argc, &argv);
g_set_application_name ("YAD");
#ifndef STANDALONE
settings = g_settings_new ("yad.settings");
#endif
yad_icon_theme = gtk_icon_theme_get_default ();
......
......@@ -1443,8 +1443,12 @@ yad_options_init (void)
/* Initialize general data */
options.data.dialog_title = NULL;
options.data.window_icon = "yad";
#ifndef STANDALONE
options.data.width = g_settings_get_int (settings, "width");
options.data.height = g_settings_get_int (settings, "height");
#else
options.data.width = options.data.height = -1;
#endif
options.data.use_posx = FALSE;
options.data.posx = 0;
options.data.use_posy = FALSE;
......@@ -1460,7 +1464,11 @@ yad_options_init (void)
options.data.buttons = NULL;
options.data.no_buttons = FALSE;
options.data.buttons_layout = GTK_BUTTONBOX_END;
options.data.borders = g_settings_get_int (settings, "border");;
#ifndef STANDALONE
options.data.borders = g_settings_get_int (settings, "border");
#else
options.data.borders = BORDERS;
#endif
options.data.no_markup = FALSE;
options.data.no_escape = FALSE;
options.data.escape_ok = FALSE;
......@@ -1492,7 +1500,11 @@ yad_options_init (void)
options.common_data.editable = FALSE;
options.common_data.tail = FALSE;
options.common_data.command = NULL;
#ifndef STANDALONE
options.common_data.date_format = g_settings_get_string (settings, "date-format");
#else
options.common_data.date_format = DATE_FMT;
#endif
options.common_data.float_precision = 3;
options.common_data.vertical = FALSE;
options.common_data.align = 0.0;
......@@ -1589,7 +1601,11 @@ yad_options_init (void)
options.icons_data.compact = FALSE;
options.icons_data.generic = FALSE;
options.icons_data.width = -1;
#ifndef STANDALONE
options.icons_data.term = g_settings_get_string (settings, "terminal");
#else
options.icons_data.term = TERM_CMD;
#endif
options.icons_data.sort_by_name = FALSE;
options.icons_data.descend = FALSE;
options.icons_data.single_click = FALSE;
......@@ -1685,7 +1701,11 @@ yad_options_init (void)
options.text_data.justify = GTK_JUSTIFY_LEFT;
options.text_data.margins = 0;
options.text_data.hide_cursor = TRUE;
#ifndef STANDALONE
options.text_data.uri_color = g_settings_get_string (settings, "uri-color");
#else
options.text_data.uri_color = URI_COLOR;
#endif
options.text_data.formatted = FALSE;
#ifdef HAVE_SOURCEVIEW
......@@ -1860,7 +1880,11 @@ yad_create_context (void)
g_option_context_add_group (tmp_ctx, a_group);
g_option_context_set_help_enabled (tmp_ctx, TRUE);
#ifndef STANDALONE
g_option_context_set_ignore_unknown_options (tmp_ctx, g_settings_get_boolean (settings, "ignore-unknown-options"));
#else
g_option_context_set_ignore_unknown_options (tmp_ctx, TRUE);
#endif
return tmp_ctx;
}
......@@ -171,7 +171,11 @@ tag_event_cb (GtkTextTag * tag, GObject * obj, GdkEvent * ev, GtkTextIter * iter
gtk_text_iter_forward_to_tag_toggle (&end, tag);
url = gtk_text_iter_get_text (&start, &end);
#ifndef STANDALONE
cmdline = g_strdup_printf (g_settings_get_string (settings, "open-command"), url);
#else
cmdline = g_strdup_printf (OPEN_CMD, url);
#endif
g_free (url);
g_spawn_command_line_async (cmdline, NULL);
......
......@@ -240,7 +240,11 @@ get_tabs (key_t key, gboolean create)
int shmid, i, max_tab;
/* get shared memory */
#ifndef STANDALONE
max_tab = g_settings_get_int (settings, "max-tab") + 1;
#else
max_tab = MAX_TABS + 1;
#endif
if (create)
{
if ((shmid = shmget (key, max_tab * sizeof (YadNTabs), IPC_CREAT | IPC_EXCL | 0644)) == -1)
......
......@@ -46,6 +46,10 @@
#include <gtksourceview/gtksource.h>
#endif
#ifdef STANDALONE
#include "defaults.h"
#endif
G_BEGIN_DECLS
#define YAD_RESPONSE_OK 0
......@@ -529,9 +533,12 @@ typedef struct {
} YadOptions;
extern YadOptions options;
extern GSettings *settings;
extern GtkIconTheme *yad_icon_theme;
#ifndef STANDALONE
extern GSettings *settings;
#endif
extern GdkPixbuf *big_fallback_image;
extern GdkPixbuf *small_fallback_image;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment