Commit 4f60f4de authored by Artem Vorotnikov's avatar Artem Vorotnikov Committed by Ben

Port to Gio::Settings

parent 14b1c2e3
......@@ -21,11 +21,9 @@
#include "disks.h"
static void
cb_solaris_mode_changed (GSettings *settings, const gchar *key, gpointer data)
cb_solaris_mode_changed (Gio::Settings& settings, Glib::ustring key, GsmApplication* app)
{
GsmApplication *app = static_cast<GsmApplication *>(data);
app->config.solaris_mode = g_settings_get_boolean(settings, key);
app->config.solaris_mode = settings.get_boolean(key);
app->cpu_graph->clear_background();
if (app->timeout) {
proctable_update (app);
......@@ -33,58 +31,49 @@ cb_solaris_mode_changed (GSettings *settings, const gchar *key, gpointer data)
}
static void
cb_draw_stacked_changed (GSettings *settings, const gchar *key, gpointer data)
cb_draw_stacked_changed (Gio::Settings& settings, Glib::ustring key, GsmApplication* app)
{
GsmApplication *app = static_cast<GsmApplication *>(data);
app->config.draw_stacked = g_settings_get_boolean(settings, key);
app->config.draw_stacked = settings.get_boolean(key);
app->cpu_graph->clear_background();
load_graph_reset(app->cpu_graph);
}
static void
cb_network_in_bits_changed (GSettings *settings, const gchar *key, gpointer data)
cb_network_in_bits_changed (Gio::Settings& settings, Glib::ustring key, GsmApplication* app)
{
GsmApplication *app = static_cast<GsmApplication *>(data);
app->config.network_in_bits = g_settings_get_boolean(settings, key);
app->config.network_in_bits = settings.get_boolean(key);
// force scale to be redrawn
app->net_graph->clear_background();
}
static void
cb_timeouts_changed (GSettings *settings, const gchar *key, gpointer data)
cb_timeouts_changed (Gio::Settings& settings, Glib::ustring key, GsmApplication* app)
{
GsmApplication *app = static_cast<GsmApplication *>(data);
if (strcmp (key, GSM_SETTING_PROCESS_UPDATE_INTERVAL) == 0) {
app->config.update_interval = g_settings_get_int (settings, key);
if (key == GSM_SETTING_PROCESS_UPDATE_INTERVAL) {
app->config.update_interval = settings.get_int (key);
app->smooth_refresh->reset();
if (app->timeout) {
proctable_reset_timeout (app);
}
} else if (strcmp (key, GSM_SETTING_GRAPH_UPDATE_INTERVAL) == 0) {
app->config.graph_update_interval = g_settings_get_int (settings, key);
} else if (key == GSM_SETTING_GRAPH_UPDATE_INTERVAL) {
app->config.graph_update_interval = settings.get_int (key);
load_graph_change_speed(app->cpu_graph,
app->config.graph_update_interval);
load_graph_change_speed(app->mem_graph,
app->config.graph_update_interval);
load_graph_change_speed(app->net_graph,
app->config.graph_update_interval);
} else if (strcmp (key, GSM_SETTING_DISKS_UPDATE_INTERVAL) == 0) {
app->config.disks_update_interval = g_settings_get_int (settings, key);
} else if (key == GSM_SETTING_DISKS_UPDATE_INTERVAL) {
app->config.disks_update_interval = settings.get_int (key);
disks_reset_timeout (app);
}
}
static void
apply_cpu_color_settings(GSettings *settings, gpointer data)
apply_cpu_color_settings(Gio::Settings& settings, GsmApplication* app)
{
GsmApplication *app = static_cast<GsmApplication *>(data);
GVariant *cpu_colors_var = g_settings_get_value (settings, GSM_SETTING_CPU_COLORS);
GVariant *cpu_colors_var = g_settings_get_value (settings.gobj (), GSM_SETTING_CPU_COLORS);
gsize n = g_variant_n_children(cpu_colors_var);
gchar *color;
......@@ -112,7 +101,7 @@ apply_cpu_color_settings(GSettings *settings, gpointer data)
full = g_variant_builder_end(&builder);
// if the user has more cores than colors stored in the gsettings, store the newly built gvariant in gsettings
if (n < static_cast<guint>(app->config.num_cpus)) {
g_settings_set_value(settings, GSM_SETTING_CPU_COLORS, full);
g_settings_set_value(settings.gobj (), GSM_SETTING_CPU_COLORS, full);
} else {
g_variant_unref(full);
}
......@@ -121,11 +110,9 @@ apply_cpu_color_settings(GSettings *settings, gpointer data)
}
static void
cb_color_changed (GSettings *settings, const gchar *key, gpointer data)
cb_color_changed (Gio::Settings& settings, Glib::ustring key, GsmApplication* app)
{
GsmApplication *app = static_cast<GsmApplication *>(data);
if (strcmp (key, GSM_SETTING_CPU_COLORS) == 0) {
if (key == GSM_SETTING_CPU_COLORS) {
apply_cpu_color_settings(settings, app);
for (int i = 0; i < app->config.num_cpus; i++) {
if(!gdk_rgba_equal(&app->cpu_graph->colors[i], &app->config.cpu_color[i])) {
......@@ -136,93 +123,75 @@ cb_color_changed (GSettings *settings, const gchar *key, gpointer data)
return;
}
gchar *color = g_settings_get_string (settings, key);
if (strcmp (key, GSM_SETTING_MEM_COLOR) == 0) {
gdk_rgba_parse (&app->config.mem_color, color);
auto color = settings.get_string (key);
if (key == GSM_SETTING_MEM_COLOR) {
gdk_rgba_parse (&app->config.mem_color, color.c_str ());
app->mem_graph->colors.at(0) = app->config.mem_color;
} else if (strcmp (key, GSM_SETTING_SWAP_COLOR) == 0) {
gdk_rgba_parse (&app->config.swap_color, color);
} else if (key == GSM_SETTING_SWAP_COLOR) {
gdk_rgba_parse (&app->config.swap_color, color.c_str ());
app->mem_graph->colors.at(1) = app->config.swap_color;
} else if (strcmp (key, GSM_SETTING_NET_IN_COLOR) == 0) {
gdk_rgba_parse (&app->config.net_in_color, color);
} else if (key == GSM_SETTING_NET_IN_COLOR) {
gdk_rgba_parse (&app->config.net_in_color, color.c_str ());
app->net_graph->colors.at(0) = app->config.net_in_color;
} else if (strcmp (key, GSM_SETTING_NET_OUT_COLOR) == 0) {
gdk_rgba_parse (&app->config.net_out_color, color);
} else if (key == GSM_SETTING_NET_OUT_COLOR) {
gdk_rgba_parse (&app->config.net_out_color, color.c_str ());
app->net_graph->colors.at(1) = app->config.net_out_color;
}
g_free (color);
}
void
GsmApplication::load_settings()
{
gchar *color;
glibtop_cpu cpu;
settings = g_settings_new (GSM_GSETTINGS_SCHEMA);
this->settings = Gio::Settings::create (GSM_GSETTINGS_SCHEMA);
config.solaris_mode = g_settings_get_boolean (settings, GSM_SETTING_SOLARIS_MODE);
g_signal_connect (settings, "changed::" GSM_SETTING_SOLARIS_MODE,
G_CALLBACK (cb_solaris_mode_changed), this);
config.solaris_mode = this->settings->get_boolean (GSM_SETTING_SOLARIS_MODE);
this->settings->signal_changed(GSM_SETTING_SOLARIS_MODE).connect ([this](const Glib::ustring& key) {
cb_solaris_mode_changed (*this->settings.operator->(), key, this);
});
config.draw_stacked = g_settings_get_boolean (settings, GSM_SETTING_DRAW_STACKED);
g_signal_connect (settings, "changed::" GSM_SETTING_DRAW_STACKED,
G_CALLBACK (cb_draw_stacked_changed), this);
config.draw_stacked = this->settings->get_boolean (GSM_SETTING_DRAW_STACKED);
this->settings->signal_changed(GSM_SETTING_DRAW_STACKED).connect ([this](const Glib::ustring& key) {
cb_draw_stacked_changed (*this->settings.operator->(), key, this);
});
config.network_in_bits = g_settings_get_boolean (settings, GSM_SETTING_NETWORK_IN_BITS);
g_signal_connect (settings, "changed::" GSM_SETTING_NETWORK_IN_BITS,
G_CALLBACK (cb_network_in_bits_changed), this);
config.network_in_bits = this->settings->get_boolean (GSM_SETTING_NETWORK_IN_BITS);
this->settings->signal_changed (GSM_SETTING_NETWORK_IN_BITS).connect ([this](const Glib::ustring& key) {
cb_network_in_bits_changed (*this->settings.operator->(), key, this);
});
config.update_interval = g_settings_get_int (settings, GSM_SETTING_PROCESS_UPDATE_INTERVAL);
g_signal_connect (settings, "changed::" GSM_SETTING_PROCESS_UPDATE_INTERVAL,
G_CALLBACK (cb_timeouts_changed), this);
config.graph_update_interval = g_settings_get_int (settings, GSM_SETTING_GRAPH_UPDATE_INTERVAL);
g_signal_connect (settings, "changed::" GSM_SETTING_GRAPH_UPDATE_INTERVAL,
G_CALLBACK (cb_timeouts_changed), this);
config.disks_update_interval = g_settings_get_int (settings, GSM_SETTING_DISKS_UPDATE_INTERVAL);
g_signal_connect (settings, "changed::" GSM_SETTING_DISKS_UPDATE_INTERVAL,
G_CALLBACK (cb_timeouts_changed), this);
auto cbtc = [this](const Glib::ustring& key) { cb_timeouts_changed(*this->settings.operator->(), key, this); };
config.update_interval = this->settings->get_int (GSM_SETTING_PROCESS_UPDATE_INTERVAL);
this->settings->signal_changed (GSM_SETTING_PROCESS_UPDATE_INTERVAL).connect (cbtc);
config.graph_update_interval = this->settings->get_int (GSM_SETTING_GRAPH_UPDATE_INTERVAL);
this->settings->signal_changed (GSM_SETTING_GRAPH_UPDATE_INTERVAL).connect (cbtc);
config.disks_update_interval = this->settings->get_int (GSM_SETTING_DISKS_UPDATE_INTERVAL);
this->settings->signal_changed (GSM_SETTING_DISKS_UPDATE_INTERVAL).connect (cbtc);
glibtop_get_cpu (&cpu);
frequency = cpu.frequency;
config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
apply_cpu_color_settings (settings, this);
g_signal_connect (settings, "changed::" GSM_SETTING_CPU_COLORS,
G_CALLBACK (cb_color_changed), this);
color = g_settings_get_string (settings, GSM_SETTING_MEM_COLOR);
if (!color)
color = g_strdup ("#000000ff0082");
g_signal_connect (settings, "changed::" GSM_SETTING_MEM_COLOR,
G_CALLBACK (cb_color_changed), this);
gdk_rgba_parse (&config.mem_color, color);
g_free (color);
color = g_settings_get_string (settings, GSM_SETTING_SWAP_COLOR);
if (!color)
color = g_strdup ("#00b6000000ff");
g_signal_connect (settings, "changed::" GSM_SETTING_SWAP_COLOR,
G_CALLBACK (cb_color_changed), this);
gdk_rgba_parse (&config.swap_color, color);
g_free (color);
color = g_settings_get_string (settings, GSM_SETTING_NET_IN_COLOR);
if (!color)
color = g_strdup ("#000000f200f2");
g_signal_connect (settings, "changed::" GSM_SETTING_NET_IN_COLOR,
G_CALLBACK (cb_color_changed), this);
gdk_rgba_parse (&config.net_in_color, color);
g_free (color);
color = g_settings_get_string (settings, GSM_SETTING_NET_OUT_COLOR);
if (!color)
color = g_strdup ("#00f2000000c1");
g_signal_connect (settings, "changed::" GSM_SETTING_NET_OUT_COLOR,
G_CALLBACK (cb_color_changed), this);
gdk_rgba_parse (&config.net_out_color, color);
g_free (color);
apply_cpu_color_settings (*this->settings.operator->(), this);
auto mem_color = this->settings->get_string (GSM_SETTING_MEM_COLOR);
gdk_rgba_parse (&config.mem_color, mem_color.empty () ? "#000000ff0082" : mem_color.c_str ());
auto swap_color = this->settings->get_string (GSM_SETTING_SWAP_COLOR);
gdk_rgba_parse (&config.swap_color, swap_color.empty () ? "#00b6000000ff" : swap_color.c_str ());
auto net_in_color = this->settings->get_string (GSM_SETTING_NET_IN_COLOR);
gdk_rgba_parse (&config.net_in_color, net_in_color.empty () ? "#000000f200f2" : net_in_color.c_str ());
auto net_out_color = this->settings->get_string (GSM_SETTING_NET_OUT_COLOR);
gdk_rgba_parse (&config.net_out_color, net_out_color.empty () ? "#00f2000000c1" : net_out_color.c_str ());
auto cbcc = [this](const Glib::ustring& key) { cb_color_changed(*this->settings.operator->(), key, this); };
for (auto k : {GSM_SETTING_CPU_COLORS, GSM_SETTING_MEM_COLOR, GSM_SETTING_SWAP_COLOR, GSM_SETTING_NET_IN_COLOR, GSM_SETTING_NET_OUT_COLOR}) {
this->settings->signal_changed (k).connect(cbcc);
}
}
......@@ -288,10 +257,10 @@ GsmApplication::save_config ()
maximized = gdk_window_get_state (gtk_widget_get_window (GTK_WIDGET (main_window))) & GDK_WINDOW_STATE_MAXIMIZED;
g_settings_set (settings, GSM_SETTING_WINDOW_STATE, "(iiii)",
g_settings_set (settings->gobj (), GSM_SETTING_WINDOW_STATE, "(iiii)",
width, height, xpos, ypos);
g_settings_set_boolean (settings, GSM_SETTING_MAXIMIZED, maximized);
settings->set_boolean (GSM_SETTING_MAXIMIZED, maximized);
}
int GsmApplication::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
......@@ -319,11 +288,11 @@ int GsmApplication::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLi
}
if (option_group.show_processes_tab)
g_settings_set_string (settings, GSM_SETTING_CURRENT_TAB, "processes");
this->settings->set_string (GSM_SETTING_CURRENT_TAB, "processes");
else if (option_group.show_resources_tab)
g_settings_set_string (settings, GSM_SETTING_CURRENT_TAB, "resources");
this->settings->set_string (GSM_SETTING_CURRENT_TAB, "resources");
else if (option_group.show_file_systems_tab)
g_settings_set_string (settings, GSM_SETTING_CURRENT_TAB, "disks");
this->settings->set_string (GSM_SETTING_CURRENT_TAB, "disks");
else if (option_group.print_version)
on_activate ();
......
......@@ -229,7 +229,7 @@ public:
PrettyTable *pretty_table;
GSettings *settings;
Glib::RefPtr<Gio::Settings> settings;
GtkApplicationWindow *main_window;
unsigned frequency;
......
......@@ -238,7 +238,7 @@ disks_update(GsmApplication *app)
gboolean show_all_fs;
list = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(app->disk_list)));
show_all_fs = g_settings_get_boolean (app->settings, GSM_SETTING_SHOW_ALL_FS);
show_all_fs = app->settings->get_boolean (GSM_SETTING_SHOW_ALL_FS);
entries = glibtop_get_mountlist (&mountlist, show_all_fs);
remove_old_disks(GTK_TREE_MODEL(list), entries, mountlist.number);
......@@ -336,15 +336,6 @@ cb_disk_list_destroying (GtkWidget *self, gpointer data)
data);
}
static void
cb_show_all_fs_changed (GSettings *settings, const gchar *key, gpointer data)
{
GsmApplication *app = (GsmApplication *) data;
disks_update (app);
disks_reset_timeout (app);
}
void
create_disk_view(GsmApplication *app, GtkBuilder *builder)
......@@ -367,8 +358,6 @@ create_disk_view(GsmApplication *app, GtkBuilder *builder)
N_("Used")
};
GSettings * settings = g_settings_get_child (app->settings, GSM_SETTINGS_CHILD_DISKS);
scrolled = GTK_SCROLLED_WINDOW (gtk_builder_get_object (builder, "disks_scrolled"));
model = gtk_list_store_new(DISK_N_COLUMNS, /* n columns */
......@@ -382,7 +371,7 @@ create_disk_view(GsmApplication *app, GtkBuilder *builder)
GDK_TYPE_PIXBUF, /* DISK_ICON */
G_TYPE_INT /* DISK_USED_PERCENTAGE */
);
disk_tree = gsm_tree_view_new (settings, TRUE);
disk_tree = gsm_tree_view_new (g_settings_get_child (app->settings->gobj(), GSM_SETTINGS_CHILD_DISKS), TRUE);
gtk_tree_view_set_model (GTK_TREE_VIEW (disk_tree), GTK_TREE_MODEL (model));
g_signal_connect(G_OBJECT(disk_tree), "row-activated", G_CALLBACK(open_dir), NULL);
......@@ -478,8 +467,7 @@ create_disk_view(GsmApplication *app, GtkBuilder *builder)
g_signal_connect (G_OBJECT (model), "sort-column-changed",
G_CALLBACK (cb_sort_changed), app);
g_signal_connect (app->settings, "changed::" GSM_SETTING_SHOW_ALL_FS,
G_CALLBACK (cb_show_all_fs_changed), app);
app->settings->signal_changed(GSM_SETTING_SHOW_ALL_FS).connect ([app](const Glib::ustring&) { disks_update (app); disks_reset_timeout (app); });
gtk_widget_show (GTK_WIDGET (disk_tree));
}
......@@ -98,10 +98,10 @@ void
cb_cpu_color_changed (GsmColorButton *cp, gpointer data)
{
guint cpu_i = GPOINTER_TO_UINT (data);
GSettings *settings = g_settings_new (GSM_GSETTINGS_SCHEMA);
auto settings = Gio::Settings::create (GSM_GSETTINGS_SCHEMA);
/* Get current values */
GVariant *cpu_colors_var = g_settings_get_value (settings, GSM_SETTING_CPU_COLORS);
GVariant *cpu_colors_var = g_settings_get_value (settings->gobj(), GSM_SETTING_CPU_COLORS);
gsize children_n = g_variant_n_children(cpu_colors_var);
/* Create builder to contruct new setting with updated value for cpu i */
......@@ -123,11 +123,10 @@ cb_cpu_color_changed (GsmColorButton *cp, gpointer data)
}
/* Just set the value and let the changed::cpu-colors signal callback do the rest. */
g_settings_set_value (settings, GSM_SETTING_CPU_COLORS,
g_variant_builder_end(&builder));
settings->set_value (GSM_SETTING_CPU_COLORS, Glib::wrap (g_variant_builder_end(&builder)));
}
static void change_settings_color(GSettings *settings, const char *key,
static void change_settings_color(Gio::Settings& settings, const char *key,
GsmColorButton *cp)
{
GdkRGBA c;
......@@ -135,7 +134,7 @@ static void change_settings_color(GSettings *settings, const char *key,
gsm_color_button_get_color(cp, &c);
color = gdk_rgba_to_string (&c);
g_settings_set_string (settings, key, color);
settings.set_string (key, color);
g_free (color);
}
......@@ -143,7 +142,7 @@ static void
cb_mem_color_changed (GsmColorButton *cp, gpointer data)
{
GsmApplication *app = (GsmApplication *) data;
change_settings_color (app->settings, GSM_SETTING_MEM_COLOR, cp);
change_settings_color (*app->settings.operator->(), GSM_SETTING_MEM_COLOR, cp);
}
......@@ -151,21 +150,21 @@ static void
cb_swap_color_changed (GsmColorButton *cp, gpointer data)
{
GsmApplication *app = (GsmApplication *) data;
change_settings_color (app->settings, GSM_SETTING_SWAP_COLOR, cp);
change_settings_color (*app->settings.operator->(), GSM_SETTING_SWAP_COLOR, cp);
}
static void
cb_net_in_color_changed (GsmColorButton *cp, gpointer data)
{
GsmApplication *app = (GsmApplication *) data;
change_settings_color (app->settings, GSM_SETTING_NET_IN_COLOR, cp);
change_settings_color (*app->settings.operator->(), GSM_SETTING_NET_IN_COLOR, cp);
}
static void
cb_net_out_color_changed (GsmColorButton *cp, gpointer data)
{
GsmApplication *app = (GsmApplication *) data;
change_settings_color(app->settings, GSM_SETTING_NET_OUT_COLOR, cp);
change_settings_color(*app->settings.operator->(), GSM_SETTING_NET_OUT_COLOR, cp);
}
static void
......@@ -383,7 +382,7 @@ on_activate_refresh (GSimpleAction *, GVariant *, gpointer data)
static void
kill_process_with_confirmation (GsmApplication *app, int signal) {
gboolean kill_dialog = g_settings_get_boolean (app->settings, GSM_SETTING_SHOW_KILL_DIALOG);
gboolean kill_dialog = app->settings->get_boolean(GSM_SETTING_SHOW_KILL_DIALOG);
if (kill_dialog)
procdialog_create_kill_dialog (app, signal);
......@@ -469,8 +468,9 @@ change_show_page_state (GSimpleAction *action, GVariant *state, gpointer data)
{
GsmApplication *app = (GsmApplication *) data;
auto state_var = Glib::wrap(state, true);
g_simple_action_set_state (action, state);
g_settings_set_value (app->settings, GSM_SETTING_CURRENT_TAB, state);
app->settings->set_value (GSM_SETTING_CURRENT_TAB, state_var);
}
static void
......@@ -478,8 +478,9 @@ change_show_processes_state (GSimpleAction *action, GVariant *state, gpointer da
{
GsmApplication *app = (GsmApplication *) data;
auto state_var = Glib::wrap(state, true);
g_simple_action_set_state (action, state);
g_settings_set_value (app->settings, GSM_SETTING_SHOW_WHOSE_PROCESSES, state);
app->settings->set_value (GSM_SETTING_SHOW_WHOSE_PROCESSES, state_var);
}
static void
......@@ -487,8 +488,9 @@ change_show_dependencies_state (GSimpleAction *action, GVariant *state, gpointer
{
GsmApplication *app = (GsmApplication *) data;
auto state_var = Glib::wrap(state, true);
g_simple_action_set_state (action, state);
g_settings_set_value (app->settings, GSM_SETTING_SHOW_DEPENDENCIES, state);
app->settings->set_value (GSM_SETTING_SHOW_DEPENDENCIES, state_var);
}
static void
......@@ -585,34 +587,33 @@ static gboolean
cb_main_window_state_changed (GtkWidget *window, GdkEventWindowState *event, gpointer data)
{
GsmApplication *app = (GsmApplication *) data;
gchar * current_page = g_settings_get_string (app->settings, GSM_SETTING_CURRENT_TAB);
auto current_page = app->settings->get_string (GSM_SETTING_CURRENT_TAB);
if (event->new_window_state & GDK_WINDOW_STATE_BELOW ||
event->new_window_state & GDK_WINDOW_STATE_ICONIFIED ||
event->new_window_state & GDK_WINDOW_STATE_WITHDRAWN)
{
if (strcmp (current_page, "processes") == 0) {
if (current_page == "processes") {
proctable_freeze (app);
} else if (strcmp (current_page, "resources") == 0) {
} else if (current_page == "resources") {
load_graph_stop (app->cpu_graph);
load_graph_stop (app->mem_graph);
load_graph_stop (app->net_graph);
} else if (strcmp (current_page, "disks") == 0) {
} else if (current_page == "disks") {
disks_freeze (app);
}
} else {
if (strcmp (current_page, "processes") == 0) {
if (current_page == "processes") {
proctable_update (app);
proctable_thaw (app);
} else if (strcmp (current_page, "resources") == 0) {
} else if (current_page == "resources") {
load_graph_start (app->cpu_graph);
load_graph_start (app->mem_graph);
load_graph_start (app->net_graph);
} else if (strcmp (current_page, "disks") == 0) {
} else if (current_page == "disks") {
disks_update (app);
disks_thaw (app);
}
}
g_free (current_page);
return FALSE;
}
......@@ -650,14 +651,14 @@ create_main_window (GsmApplication *app)
gtk_box_pack_start (mainbox, GTK_WIDGET (headerbar), FALSE, FALSE, 0);
}
g_settings_get (app->settings, GSM_SETTING_WINDOW_STATE, "(iiii)",
g_settings_get (app->settings->gobj(), GSM_SETTING_WINDOW_STATE, "(iiii)",
&width, &height, &xpos, &ypos);
width = CLAMP (width, 50, gdk_screen_width ());
height = CLAMP (height, 50, gdk_screen_height ());
gtk_window_set_default_size (GTK_WINDOW (main_window), width, height);
gtk_window_move (GTK_WINDOW (main_window), xpos, ypos);
if (g_settings_get_boolean (app->settings, GSM_SETTING_MAXIMIZED))
if (app->settings->get_boolean (GSM_SETTING_MAXIMIZED))
gtk_window_maximize (GTK_WINDOW (main_window));
app->process_menu_button = process_menu_button = GTK_MENU_BUTTON (gtk_builder_get_object (builder, "process_menu_button"));
......@@ -706,7 +707,7 @@ create_main_window (GsmApplication *app)
create_disk_view (app, builder);
g_settings_bind (app->settings, GSM_SETTING_CURRENT_TAB, stack, "visible-child-name", G_SETTINGS_BIND_DEFAULT);
g_settings_bind (app->settings->gobj (), GSM_SETTING_CURRENT_TAB, stack, "visible-child-name", G_SETTINGS_BIND_DEFAULT);
g_signal_connect (G_OBJECT (stack), "notify::visible-child",
G_CALLBACK (cb_change_current_page), app);
......@@ -722,13 +723,13 @@ create_main_window (GsmApplication *app)
action = g_action_map_lookup_action (G_ACTION_MAP (main_window),
"show-dependencies");
g_action_change_state (action,
g_settings_get_value (app->settings, GSM_SETTING_SHOW_DEPENDENCIES));
g_settings_get_value (app->settings->gobj (), GSM_SETTING_SHOW_DEPENDENCIES));
action = g_action_map_lookup_action (G_ACTION_MAP (main_window),
"show-whose-processes");
g_action_change_state (action,
g_settings_get_value (app->settings, GSM_SETTING_SHOW_WHOSE_PROCESSES));
g_settings_get_value (app->settings->gobj (), GSM_SETTING_SHOW_WHOSE_PROCESSES));
gtk_widget_show (GTK_WIDGET (main_window));
......
......@@ -345,13 +345,13 @@ create_memmapsdata (GsmApplication *app)
G_TYPE_UINT64 /* MMAP_COL_INODE */
);
GSettings *settings = g_settings_get_child (app->settings, GSM_SETTINGS_CHILD_MEMMAP);
auto settings = g_settings_get_child (app->settings->gobj (), GSM_SETTINGS_CHILD_MEMMAP);
tree = gsm_tree_view_new (settings, FALSE);
gtk_tree_view_set_model (GTK_TREE_VIEW (tree), GTK_TREE_MODEL (model));
g_object_unref (G_OBJECT (model));
gchar *font = get_monospace_system_font_name ();
auto font = get_monospace_system_font_name ();
for (i = 0; i < MMAP_COL_MAX; i++) {
GtkCellRenderer *cell;
......@@ -390,13 +390,11 @@ create_memmapsdata (GsmApplication *app)
case MMAP_COL_VMEND:
case MMAP_COL_FLAGS:
case MMAP_COL_VMOFFSET:
g_object_set (cell, "font", font, NULL);
g_object_set (cell, "font", font.c_str (), NULL);
break;
}
}
g_free (font);
return new MemMapsData(tree);
}
......
......@@ -260,7 +260,7 @@ create_openfiles_tree (GsmApplication *app)
G_TYPE_POINTER /* open_files_entry */
);
GSettings *settings = g_settings_get_child (app->settings, GSM_SETTINGS_CHILD_OPEN_FILES);
auto settings = g_settings_get_child (app->settings->gobj (), GSM_SETTINGS_CHILD_OPEN_FILES);
tree = gsm_tree_view_new (settings, FALSE);
gtk_tree_view_set_model (GTK_TREE_VIEW (tree), GTK_TREE_MODEL (model));
......
......@@ -45,8 +45,7 @@ private:
{
int new_value = int(1000 * gtk_spin_button_get_value(spin));
g_settings_set_int(GsmApplication::get()->settings,
this->key.c_str(), new_value);
GsmApplication::get()->settings->set_int(this->key, new_value);
procman_debug("set %s to %d", this->key.c_str(), new_value);
}
......@@ -62,8 +61,7 @@ field_toggled (const gchar *gsettings_parent, gchar *path_str, gpointer data)
GtkTreeIter iter;
GtkTreeViewColumn *column;
gboolean toggled;
GSettings *settings = g_settings_get_child (GsmApplication::get()->settings, gsettings_parent);
gchar *key;
auto settings = GsmApplication::get()->settings->get_child (gsettings_parent);
int id;
if (!path)
......@@ -79,9 +77,8 @@ field_toggled (const gchar *gsettings_parent, gchar *path_str, gpointer data)
id = gtk_tree_view_column_get_sort_column_id (column);
key = g_strdup_printf ("col-%d-visible", id);
g_settings_set_boolean (settings, key, !toggled);
g_free (key);
auto key = Glib::ustring::compose ("col-%1-visible", id);
settings->set_boolean (key, !toggled);
gtk_tree_path_free (path);
......@@ -236,20 +233,20 @@ create_preferences_dialog (GsmApplication *app)
G_CALLBACK (SBU::callback), &interval_updater);
smooth_button = GTK_CHECK_BUTTON (gtk_builder_get_object (builder, "smooth_button"));
g_settings_bind(app->settings, SmoothRefresh::KEY.c_str(), smooth_button, "active", G_SETTINGS_BIND_DEFAULT);
g_settings_bind(app->settings->gobj (), SmoothRefresh::KEY.c_str(), smooth_button, "active", G_SETTINGS_BIND_DEFAULT);
check_button = GTK_CHECK_BUTTON (gtk_builder_get_object (builder, "check_button"));
g_settings_bind (app->settings, GSM_SETTING_SHOW_KILL_DIALOG,
g_settings_bind (app->settings->gobj (), GSM_SETTING_SHOW_KILL_DIALOG,
check_button, "active",
G_SETTINGS_BIND_DEFAULT);
GtkCheckButton *solaris_button = GTK_CHECK_BUTTON (gtk_builder_get_object (builder, "solaris_button"));
g_settings_bind (app->settings, GSM_SETTING_SOLARIS_MODE,
g_settings_bind (app->settings->gobj (), GSM_SETTING_SOLARIS_MODE,
solaris_button, "active",
G_SETTINGS_BIND_DEFAULT);
GtkCheckButton *draw_stacked_button = GTK_CHECK_BUTTON (gtk_builder_get_object (builder, "draw_stacked_button"));
g_settings_bind (app->settings, GSM_SETTING_DRAW_STACKED,
g_settings_bind (app->settings->gobj (), GSM_SETTING_DRAW_STACKED,
draw_stacked_button, "active",
G_SETTINGS_BIND_DEFAULT);
......@@ -265,7 +262,7 @@ create_preferences_dialog (GsmApplication *app)
&graph_interval_updater);
GtkCheckButton *bits_button = GTK_CHECK_BUTTON (gtk_builder_get_object (builder, "bits_button"));
g_settings_bind(app->settings, GSM_SETTING_NETWORK_IN_BITS,
g_settings_bind(app->settings->gobj (), GSM_SETTING_NETWORK_IN_BITS,
bits_button, "active",
G_SETTINGS_BIND_DEFAULT);
......@@ -280,7 +277,7 @@ create_preferences_dialog (GsmApplication *app)
check_button = GTK_CHECK_BUTTON (gtk_builder_get_object (builder, "all_devices_check"));
g_settings_bind (app->settings, GSM_SETTING_SHOW_ALL_FS,
g_settings_bind (app->settings->gobj (), GSM_SETTING_SHOW_ALL_FS,
check_button, "active",
G_SETTINGS_BIND_DEFAULT);
......@@ -292,16 +289,14 @@ create_preferences_dialog (GsmApplication *app)
g_signal_connect (G_OBJECT (prefs_dialog), "response",
G_CALLBACK (prefs_dialog_button_pressed), app);
char *current_tab = g_settings_get_string (app->settings, GSM_SETTING_CURRENT_TAB);
if (strcmp (current_tab, "processes") == 0)
auto current_tab = app->settings->get_string(GSM_SETTING_CURRENT_TAB);
if (current_tab == "processes")
gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0);
else if (strcmp (current_tab, "resources") == 0)
else if (current_tab == "resources")
gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 1);
else if (strcmp (current_tab, "disks") == 0)
else if (current_tab == "disks")
gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 2);
g_free (current_tab);
gtk_builder_connect_signals (builder, NULL);
g_object_unref (G_OBJECT (builder));
}
......
......@@ -254,7 +254,7 @@ process_visibility_func (GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
// in case we are in dependencies view, we show (and expand) rows not matching the text, but having a matching child
gboolean match = false;
if (g_settings_get_boolean (app->settings, GSM_SETTING_SHOW_DEPENDENCIES)) {
if (app->settings->get_boolean (GSM_SETTING_SHOW_DEPENDENCIES)) {
GtkTreeIter child;
if (gtk_tree_model_iter_children (model, &child, iter)) {
gboolean child_match = FALSE;
......@@ -296,14 +296,12 @@ proctable_clear_tree (GsmApplication * const app)
update_sensitivity(app);
}
static void
cb_show_dependencies_changed (GSettings *settings, const gchar *key, gpointer data)
{
GsmApplication *app = (GsmApplication *) data;
cb_show_dependencies_changed(Gio::Settings& settings, Glib::ustring key, GsmApplication* app) {
if (app->timeout) {
gtk_tree_view_set_show_expanders (GTK_TREE_VIEW (app->tree),
g_settings_get_boolean (settings, GSM_SETTING_SHOW_DEPENDENCIES));
settings.get_boolean (GSM_SETTING_SHOW_DEPENDENCIES));
proctable_clear_tree (app);
proctable_update (app);
......@@ -311,9 +309,7 @@ cb_show_dependencies_changed (GSettings *settings, const gchar *key, gpointer da
}
static void
cb_show_whose_processes_changed (GSettings *settings, const gchar *key, gpointer data)
{
GsmApplication *app = (GsmApplication *) data;
cb_show_whose_processes_changed(Gio::Settings& settings, Glib::ustring key, GsmApplication* app) {
if (app->timeout) {
proctable_clear_tree (app);
proctable_update (app);
......@@ -362,7 +358,7 @@ proctable_new (GsmApplication * const app)
};