GitLab repository storage has been migrated to hashed layout. Please contact Infrastructure team if you notice any issues with repositories or hooks.

Commit efc36f40 authored by Kalev Lember's avatar Kalev Lember
parent 7ec6ab5c
......@@ -2,7 +2,7 @@
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
DISTCHECK_CONFIGURE_FLAGS = --disable-scrollkeeper --disable-schemas-install
DISTCHECK_CONFIGURE_FLAGS = --disable-scrollkeeper
SUBDIRS = data po help src icons
......
......@@ -28,6 +28,8 @@ AC_CHECK_FUNCS([pow strstr strtoul])
AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
GLIB_GSETTINGS
LIBGTKHEX_RELEASE=3.0
AC_SUBST(LIBGTKHEX_RELEASE)
LIBGTKHEX_RELEASE_STRING=gtkhex-${LIBGTKHEX_RELEASE}
......@@ -41,9 +43,8 @@ AC_SUBST(LIBGTKHEX_LIBS)
AC_SUBST(LIBGTKHEX_CFLAGS)
PKG_CHECK_MODULES(GHEX,
gio-2.0 \
gtk+-3.0 >= 3.0 \
gconf-2.0)
gio-2.0 >= 2.26 \
gtk+-3.0 >= 3.0)
AC_SUBST(GHEX_CFLAGS)
AC_SUBST(GHEX_LIBS)
......@@ -71,15 +72,6 @@ GNOME_COMPILE_WARNINGS([maximum])
AC_ARG_ENABLE(debug,
[ --enable-debug Enables extra debugging output], AC_DEFINE(ENABLE_DEBUG, 1, [Should verbose debugging output be enabled.]))
dnl Checking for gconftool-2
AC_PATH_PROG(GCONFTOOL, gconftool-2, no)
if test "x$GCONFTOOL" = xno; then
AC_MSG_ERROR([gconftool-2 executable not found in your path - should be installed with GConf])
fi
AM_GCONF_SOURCE_2
GNOME_DOC_INIT([0.9.0],,
[AC_MSG_WARN([[gnome-doc-utils not found: documentation will not be built.]])])
......
schemadir = $(GCONF_SCHEMA_FILE_DIR)
schema_DATA = ghex2.schemas
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = gtkhex-3.pc
@GSETTINGS_RULES@
gsettings_SCHEMAS = org.gnome.GHex.gschema.xml
convertdir = $(datadir)/GConf/gsettings
convert_DATA = ghex.convert
EXTRA_DIST = \
ghex.desktop.in \
$(schema_DATA)
$(gsettings_SCHEMAS) \
$(convert_DATA)
desktopdir = $(datadir)/applications
desktop_in_files = ghex.desktop.in
......@@ -14,13 +18,5 @@ desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
@INTLTOOL_DESKTOP_RULE@
#Install the ghex2 schema file
if GCONF_SCHEMAS_INSTALL
install-data-local:
GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(srcdir)/$(schema_DATA)
else
install-data-local:
endif
CLEANFILES = \
$(desktop_DATA)
[org.gnome.GHex]
font = /apps/ghex2/font
group-data-by = /apps/ghex2/group
max-undo-depth = /apps/ghex2/maxundodepth
offset-format = /apps/ghex2/offsetformat
print-font-data = /apps/ghex2/datafont
print-font-header = /apps/ghex2/headerfont
print-shaded-rows = /apps/ghex2/boxsize
show-offsets = /apps/ghex2/offsetscolumn
<gconfschemafile>
<!--
Note: all double hyphens in this comment have a space in the middle
because double hyphen isn't allowed in comments. So, remove the space
before use.
To install this file type:
gconftool - -install-schema-file basic-gconf-app.schemas
You probably want your "make install" to do this for real applications.
Also, you probably want a configure option so people can retarget where the
schema file gets installed. The option should be called - -gconf-config-source=blah
To change the gconftool target use the - -config-source=blah option to gconftool.
-->
<schemalist>
<schema>
<key>/schemas/apps/ghex2/default-mdi-mode</key>
<applyto>/apps/ghex2/mdi-mode</applyto>
<owner>ghex2</owner>
<type>int</type>
<locale name="C">
<default>2</default>
<short>Default MDI Mode</short>
<long>Default MDI Mode</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/ghex2/default-font</key>
<applyto>/apps/ghex2/font</applyto>
<owner>ghex2</owner>
<type>string</type>
<locale name="C">
<default>Monospace 12</default>
<short>Default Font</short>
<long>Default Font</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/ghex2/default-group</key>
<applyto>/apps/ghex2/group</applyto>
<owner>ghex2</owner>
<type>int</type>
<locale name="C">
<default>1</default>
<short>Default Group</short>
<long>Default Group</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/ghex2/default-max-undo-depth</key>
<applyto>/apps/ghex2/maxundodepth</applyto>
<owner>ghex2</owner>
<type>int</type>
<locale name="C">
<default>100</default>
<short>Default Max Undo Depth</short>
<long>Default Max Undo Depth</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/ghex2/default-offset-format</key>
<applyto>/apps/ghex2/offsetformat</applyto>
<owner>ghex2</owner>
<type>string</type>
<locale name="C">
<default>%X</default>
<short>Default Offset Format</short>
<long>Default Offset Format</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/ghex2/default-show-offsets</key>
<applyto>/apps/ghex2/offsetscolumn</applyto>
<owner>ghex2</owner>
<type>bool</type>
<locale name="C">
<default>1</default>
<short>Default Show Offsets</short>
<long>Default Show Offsets</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/ghex2/default-paper</key>
<applyto>/apps/ghex2/paper</applyto>
<owner>ghex2</owner>
<type>string</type>
<locale name="C">
<default>a4</default>
<short>Default Paper</short>
<long>Default Paper</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/ghex2/default-box-size</key>
<applyto>/apps/ghex2/boxsize</applyto>
<owner>ghex2</owner>
<type>int</type>
<locale name="C">
<default>0</default>
<short>Default Box Size</short>
<long>Default Box Size</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/ghex2/default-data-font</key>
<applyto>/apps/ghex2/datafont</applyto>
<owner>ghex2</owner>
<type>string</type>
<locale name="C">
<default>Courier 10</default>
<short>Default Data Font</short>
<long>Default Data Font</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/ghex2/default-header-font</key>
<applyto>/apps/ghex2/headerfont</applyto>
<owner>ghex2</owner>
<type>string</type>
<locale name="C">
<default>Helvetica 12</default>
<short>Default Header Font</short>
<long>Default Header Font</long>
</locale>
</schema>
</schemalist>
</gconfschemafile>
<schemalist>
<schema id="org.gnome.GHex" path="/org/gnome/ghex/">
<key name="font" type="s">
<default>'Monospace 12'</default>
</key>
<key name="group-data-by" type="i">
<default>1</default>
</key>
<key name="max-undo-depth" type="i">
<default>100</default>
</key>
<key name="offset-format" type="s">
<default>'%X'</default>
</key>
<key name="print-font-data" type="s">
<default>'Courier 10'</default>
</key>
<key name="print-font-header" type="s">
<default>'Helvetica 12'</default>
</key>
<key name="print-shaded-rows" type="i">
<default>0</default>
</key>
<key name="show-offsets" type="b">
<default>true</default>
</key>
</schema>
</schemalist>
......@@ -27,16 +27,13 @@
#include <string.h>
#include <gconf/gconf-client.h>
#include <gconf/gconf-value.h>
#include "configuration.h"
#include "gtkhex.h"
#include "ghex-window.h"
#define DEFAULT_FONT "Monospace 12"
GConfClient *gconf_client = NULL;
GSettings *settings = NULL;
gint def_group_type = GROUP_BYTE;
guint max_undo_depth;
......@@ -51,9 +48,7 @@ void ghex_load_configuration () {
PangoFontMetrics *new_metrics;
/* Get the default font metrics */
font_name = gconf_client_get_string (gconf_client,
GHEX_BASE_KEY GHEX_PREF_FONT,
NULL);
font_name = g_settings_get_string (settings, GHEX_PREF_FONT);
if (NULL == font_name)
font_name = g_strdup (DEFAULT_FONT);
......@@ -80,18 +75,14 @@ void ghex_load_configuration () {
g_free (font_name);
/* Get the default group type -- SnM */
def_group_type = gconf_client_get_int (gconf_client,
GHEX_BASE_KEY GHEX_PREF_GROUP,
NULL);
def_group_type = g_settings_get_int (settings, GHEX_PREF_GROUP);
/* Sanity check for group type */
if (def_group_type <= 0 )
def_group_type = GROUP_BYTE;
/* Get the max undo depth -- SnM */
max_undo_depth = gconf_client_get_int (gconf_client,
GHEX_BASE_KEY GHEX_PREF_MAX_UNDO_DEPTH,
NULL);
max_undo_depth = g_settings_get_int (settings, GHEX_PREF_MAX_UNDO_DEPTH);
/* Get the offset format -- SnM */
......@@ -99,9 +90,7 @@ void ghex_load_configuration () {
if (offset_fmt)
g_free (offset_fmt);
offset_fmt = gconf_client_get_string (gconf_client,
GHEX_BASE_KEY GHEX_PREF_OFFSET_FORMAT,
NULL);
offset_fmt = g_settings_get_string (settings, GHEX_PREF_OFFSET_FORMAT);
/* Check if offset_fmt is NULL. Shouldnt happen if we get the default
* value from the gconf client -- SnM
......@@ -112,19 +101,13 @@ void ghex_load_configuration () {
}
/* Get the show offsets column value -- SnM */
show_offsets_column = gconf_client_get_bool (gconf_client,
GHEX_BASE_KEY GHEX_PREF_OFFSETS_COLUMN,
NULL);
show_offsets_column = g_settings_get_boolean (settings, GHEX_PREF_OFFSETS_COLUMN);
/* Get the shaded box size -- SnM */
shaded_box_size = gconf_client_get_int (gconf_client,
GHEX_BASE_KEY GHEX_PREF_BOX_SIZE,
NULL);
shaded_box_size = g_settings_get_int (settings, GHEX_PREF_BOX_SIZE);
/* Get the data font name -- SnM */
data_font_name = gconf_client_get_string (gconf_client,
GHEX_BASE_KEY GHEX_PREF_DATA_FONT,
NULL);
data_font_name = g_settings_get_string (settings, GHEX_PREF_DATA_FONT);
/* Check if data_font_name is NULL. Should not happen if we get the
* default value from the gconf client -- SnM
......@@ -134,9 +117,7 @@ void ghex_load_configuration () {
}
/* Get the header font name -- SnM */
header_font_name = gconf_client_get_string (gconf_client,
GHEX_BASE_KEY GHEX_PREF_HEADER_FONT,
NULL);
header_font_name = g_settings_get_string (settings, GHEX_PREF_HEADER_FONT);
/* Check if the header_font_name is NULL. Should not happen if we get
* the default value from the gconf client -- SnM
......@@ -147,15 +128,15 @@ void ghex_load_configuration () {
}
}
static void ghex_prefs_notify_cb (GConfClient *gconf_client,
guint cnxn_id,
GConfEntry *entry,
gpointer user_data)
static void
ghex_prefs_changed_cb (GSettings *settings,
const gchar *key,
gpointer user_data)
{
const GList *winn, *docn;
if(!strcmp(entry->key, GHEX_BASE_KEY GHEX_PREF_OFFSETS_COLUMN)) {
gboolean show_off = gconf_value_get_bool(entry->value);
if (!strcmp (key, GHEX_PREF_OFFSETS_COLUMN)) {
gboolean show_off = g_settings_get_boolean (settings, key);
show_offsets_column = show_off;
winn = ghex_window_get_list();
while(winn) {
......@@ -164,11 +145,11 @@ static void ghex_prefs_notify_cb (GConfClient *gconf_client,
winn = g_list_next(winn);
}
}
else if(!strcmp(entry->key, GHEX_BASE_KEY GHEX_PREF_GROUP)) {
def_group_type = gconf_value_get_int(entry->value);
else if (!strcmp (key, GHEX_PREF_GROUP)) {
def_group_type = g_settings_get_int (settings, key);
}
else if(!strcmp(entry->key, GHEX_BASE_KEY GHEX_PREF_MAX_UNDO_DEPTH)) {
gint new_undo_max = gconf_value_get_int(entry->value);
else if (!strcmp (key, GHEX_PREF_MAX_UNDO_DEPTH)) {
gint new_undo_max = g_settings_get_int (settings, key);
max_undo_depth = new_undo_max;
docn = hex_document_get_list();
while(docn) {
......@@ -176,16 +157,16 @@ static void ghex_prefs_notify_cb (GConfClient *gconf_client,
docn = g_list_next(docn);
}
}
else if(!strcmp(entry->key, GHEX_BASE_KEY GHEX_PREF_BOX_SIZE)) {
shaded_box_size = gconf_value_get_int(entry->value);
else if (!strcmp (key, GHEX_PREF_BOX_SIZE)) {
shaded_box_size = g_settings_get_int (settings, key);
}
else if(!strcmp(entry->key, GHEX_BASE_KEY GHEX_PREF_OFFSET_FORMAT) &&
strcmp(gconf_value_get_string(entry->value), offset_fmt)) {
else if (!strcmp (key, GHEX_PREF_OFFSET_FORMAT) &&
strcmp (g_settings_get_string (settings, key), offset_fmt)) {
gchar *old_offset_fmt = offset_fmt;
gint len, i;
gboolean expect_spec;
offset_fmt = g_strdup(gconf_value_get_string(entry->value));
offset_fmt = g_strdup (g_settings_get_string (settings, key));
/* check for a valid format string */
len = strlen(offset_fmt);
......@@ -202,17 +183,16 @@ static void ghex_prefs_notify_cb (GConfClient *gconf_client,
offset_fmt[i] != 'P' && offset_fmt[i] != 'p') {
g_free(offset_fmt);
offset_fmt = old_offset_fmt;
gconf_client_set_string(gconf_client, GHEX_BASE_KEY GHEX_PREF_OFFSET_FORMAT,
"%X", NULL);
g_settings_set_string (settings, GHEX_PREF_OFFSET_FORMAT, "%X");
}
}
}
if(offset_fmt != old_offset_fmt)
g_free(old_offset_fmt);
}
else if(!strcmp(entry->key, GHEX_BASE_KEY GHEX_PREF_FONT)) {
if(gconf_value_get_string(entry->value) != NULL) {
const gchar *font_name = gconf_value_get_string(entry->value);
else if (!strcmp (key, GHEX_PREF_FONT)) {
if (g_settings_get_string (settings, key) != NULL) {
const gchar *font_name = g_settings_get_string (settings, key);
PangoFontMetrics *new_metrics;
PangoFontDescription *new_desc;
......@@ -240,31 +220,25 @@ static void ghex_prefs_notify_cb (GConfClient *gconf_client,
}
}
}
else if(!strcmp(entry->key, GHEX_BASE_KEY GHEX_PREF_DATA_FONT)) {
else if (!strcmp (key, GHEX_PREF_DATA_FONT)) {
if(data_font_name)
g_free(data_font_name);
data_font_name = g_strdup (gconf_value_get_string(entry->value));
data_font_name = g_strdup (g_settings_get_string (settings, key));
}
else if(!strcmp(entry->key, GHEX_BASE_KEY GHEX_PREF_HEADER_FONT)) {
else if (!strcmp (key, GHEX_PREF_HEADER_FONT)) {
if(header_font_name)
g_free(header_font_name);
header_font_name = g_strdup (gconf_value_get_string(entry->value));
header_font_name = g_strdup (g_settings_get_string (settings, key));
}
}
void ghex_init_configuration ()
{
gconf_client = gconf_client_get_default ();
g_return_if_fail (gconf_client != NULL);
settings = g_settings_new ("org.gnome.GHex");
gconf_client_add_dir (gconf_client,
GHEX_BASE_KEY,
GCONF_CLIENT_PRELOAD_RECURSIVE,
NULL);
g_return_if_fail (settings != NULL);
gconf_client_notify_add (gconf_client,
GHEX_BASE_KEY,
ghex_prefs_notify_cb,
NULL, NULL, NULL);
g_signal_connect (settings, "changed",
G_CALLBACK (ghex_prefs_changed_cb),
NULL);
}
......@@ -24,8 +24,6 @@
#ifndef __GHEX_CONFIGURATION_H__
#define __GHEX_CONFIGURATION_H__
#include <gconf/gconf-client.h>
#include <gtk/gtk.h>
#include "preferences.h"
......@@ -33,17 +31,15 @@
G_BEGIN_DECLS
/* GConf keys */
#define GHEX_BASE_KEY "/apps/ghex2"
#define GHEX_PREF_FONT "/font"
#define GHEX_PREF_GROUP "/group"
#define GHEX_PREF_MAX_UNDO_DEPTH "/maxundodepth"
#define GHEX_PREF_OFFSET_FORMAT "/offsetformat"
#define GHEX_PREF_OFFSETS_COLUMN "/offsetscolumn"
#define GHEX_PREF_PAPER "/paper"
#define GHEX_PREF_BOX_SIZE "/boxsize"
#define GHEX_PREF_DATA_FONT "/datafont"
#define GHEX_PREF_HEADER_FONT "/headerfont"
/* GSettings keys */
#define GHEX_PREF_FONT "font"
#define GHEX_PREF_GROUP "group-data-by"
#define GHEX_PREF_MAX_UNDO_DEPTH "max-undo-depth"
#define GHEX_PREF_OFFSET_FORMAT "offset-format"
#define GHEX_PREF_DATA_FONT "print-font-data"
#define GHEX_PREF_HEADER_FONT "print-font-header"
#define GHEX_PREF_BOX_SIZE "print-shaded-rows"
#define GHEX_PREF_OFFSETS_COLUMN "show-offsets"
/* our preferred settings; as only one copy of them is required,
we'll make them global vars, although this is a bit ugly */
......@@ -60,9 +56,9 @@ extern gboolean show_offsets_column;
extern gint shaded_box_size;
extern gint def_group_type;
extern GConfClient *gconf_client;
extern GSettings *settings;
/* Initializes the gconf client */
/* Initializes the gsettings client */
void ghex_init_configuration (void);
/* config stuff */
......
......@@ -10,8 +10,6 @@
#ifndef __GHEX_WINDOW_H__
#define __GHEX_WINDOW_H__
#include <gconf/gconf-client.h>
#include <math.h>
#include <ctype.h>
......
......@@ -391,10 +391,9 @@ max_undo_changed_cb(GtkAdjustment *adj, PropertyUI *pui)
if((guint)gtk_adjustment_get_value(adj) != max_undo_depth) {
max_undo_depth = gtk_spin_button_get_value_as_int
(GTK_SPIN_BUTTON(pui->undo_spin));
gconf_client_set_int (gconf_client,
GHEX_BASE_KEY GHEX_PREF_MAX_UNDO_DEPTH,
max_undo_depth,
NULL);
g_settings_set_int (settings,
GHEX_PREF_MAX_UNDO_DEPTH,
max_undo_depth);
}
}
......@@ -404,10 +403,9 @@ box_size_changed_cb(GtkAdjustment *adj, PropertyUI *pui)
if((guint)gtk_adjustment_get_value(adj) != shaded_box_size) {
shaded_box_size = gtk_spin_button_get_value_as_int
(GTK_SPIN_BUTTON(pui->box_size_spin));
gconf_client_set_int (gconf_client,
GHEX_BASE_KEY GHEX_PREF_BOX_SIZE,
shaded_box_size,
NULL);
g_settings_set_int (settings,
GHEX_PREF_BOX_SIZE,
shaded_box_size);
}
}
......@@ -416,10 +414,9 @@ offsets_col_cb(GtkToggleButton *tb, PropertyUI *pui)
{
show_offsets_column = gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON(pui->offsets_col));
gconf_client_set_bool (gconf_client,
GHEX_BASE_KEY GHEX_PREF_OFFSETS_COLUMN,
show_offsets_column,
NULL);
g_settings_set_boolean (settings,
GHEX_PREF_OFFSETS_COLUMN,
show_offsets_column);
}
static void
......@@ -432,10 +429,9 @@ group_type_cb(GtkRadioButton *rd, PropertyUI *pui)
def_group_type = group_type[i];
break;
}
gconf_client_set_int (gconf_client,
GHEX_BASE_KEY GHEX_PREF_GROUP,
def_group_type,
NULL);
g_settings_set_int (settings,
GHEX_PREF_GROUP,
def_group_type);
}
static void
......@@ -496,10 +492,9 @@ select_display_font_cb(GtkWidget *w, PropertyUI *pui)
(gtk_font_button_get_font_name
(GTK_FONT_BUTTON(pui->font_button)));
def_font_desc = new_desc;
gconf_client_set_string (gconf_client,
GHEX_BASE_KEY GHEX_PREF_FONT,
def_font_name,
NULL);
g_settings_set_string (settings,
GHEX_PREF_FONT,
def_font_name);
}
else
display_error_dialog (ghex_window_get_active(),
......@@ -515,20 +510,18 @@ select_font_cb(GtkWidget *w, PropertyUI *pui)
g_free(data_font_name);
data_font_name = g_strdup(gtk_font_button_get_font_name
(GTK_FONT_BUTTON (pui->df_button)));
gconf_client_set_string (gconf_client,
GHEX_BASE_KEY GHEX_PREF_DATA_FONT,
data_font_name,
NULL);
g_settings_set_string (settings,
GHEX_PREF_DATA_FONT,
data_font_name);
}
else if(w == pui->hf_button) {
if(header_font_name)
g_free(header_font_name);
header_font_name = g_strdup(gtk_font_button_get_font_name
(GTK_FONT_BUTTON (pui->hf_button)));
gconf_client_set_string (gconf_client,
GHEX_BASE_KEY GHEX_PREF_HEADER_FONT,
header_font_name,
NULL);
g_settings_set_string (settings,
GHEX_PREF_HEADER_FONT,
header_font_name);
}
}
......@@ -577,10 +570,9 @@ update_offset_fmt_from_entry(GtkEntry *entry, PropertyUI *pui)
}
if(offset_fmt != old_offset_fmt)
g_free(old_offset_fmt);
gconf_client_set_string (gconf_client,
GHEX_BASE_KEY GHEX_PREF_OFFSET_FORMAT,
offset_fmt,
NULL);
g_settings_set_string (settings,
GHEX_PREF_OFFSET_FORMAT,
offset_fmt);
win_list = ghex_window_get_list();
while(NULL != win_list) {
ghex_window_update_status_message((GHexWindow *)win_list->data);
......
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