[Xfce4-commits] [apps/xfburn] 22/42: cleaned up ToggleAction
noreply at xfce.org
noreply at xfce.org
Tue Oct 15 02:22:05 CEST 2019
This is an automated email from the git hooks/post-receive script.
k a t a n a s t e e l p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository apps/xfburn.
commit 9e7a160fcb8ce704b9d95726dde64251c66191fd
Author: Rene Kjellerup <rk.katana.steel at gmail.com>
Date: Thu Dec 13 18:07:25 2018 -0800
cleaned up ToggleAction
using change_state signal to update the statefull
gsimpleaction used to show/hide toolbar and filebrowser
instread of modifying the simple action directly
---
xfburn/xfburn-data-composition.c | 2 +-
xfburn/xfburn-main-window.c | 32 +++++++++++++-------------------
xfburn/xfburn-main.c | 1 +
xfburn/xfburn-preferences-dialog.c | 4 ++--
4 files changed, 17 insertions(+), 22 deletions(-)
diff --git a/xfburn/xfburn-data-composition.c b/xfburn/xfburn-data-composition.c
index 3b00e1c..8dcc5e4 100644
--- a/xfburn/xfburn-data-composition.c
+++ b/xfburn/xfburn-data-composition.c
@@ -1991,7 +1991,7 @@ fill_image_with_composition (GtkTreeModel *model, IsoImage *image, IsoDir * pare
continue;
}
- if (src != '\0') {
+ if (src != NULL && *src != '\0') {
basename = g_path_get_basename (src);
/* check if the file has been renamed */
diff --git a/xfburn/xfburn-main-window.c b/xfburn/xfburn-main-window.c
index aca2848..8a4b9da 100644
--- a/xfburn/xfburn-main-window.c
+++ b/xfburn/xfburn-main-window.c
@@ -93,7 +93,6 @@ static void action_burn_dvd_image (GAction *, GVariant*, XfburnMainWindow *);
static void action_refresh_directorybrowser (GAction *, GVariant*, XfburnMainWindow *);
static void action_show_filebrowser (GSimpleAction *, GVariant*, XfburnMainWindow *);
static void action_show_toolbar (GSimpleAction * action, GVariant*, XfburnMainWindow * window);
-static void action_toggle_state (GSimpleAction *);
/* globals */
static GtkWindowClass *parent_class = NULL;
@@ -166,8 +165,8 @@ static const struct {
};
*/
static const GActionEntry toggle_action_entries[] = {
- { .name = "show-filebrowser", .activate = (gActionCallback)action_show_filebrowser, .state = "true", .change_state = (gActionCallback)NULL },
- { .name = "show-toolbar", .activate = (gActionCallback)action_show_toolbar , .state = "true", .change_state = (gActionCallback)NULL },
+ { .name = "show-filebrowser", .state = "false", .change_state = (gActionCallback)action_show_filebrowser },
+ { .name = "show-toolbar", .state = "false", .change_state = (gActionCallback)action_show_toolbar },
};
/* static const GtkToggleActionEntry toggle_action_entries[] = {
{"show-filebrowser", NULL, N_("Show file browser"), NULL, N_("Show/hide the file browser"),
@@ -630,13 +629,15 @@ action_refresh_directorybrowser (GAction * action, GVariant* param, XfburnMainWi
}
static void
-action_show_filebrowser (GSimpleAction * action, GVariant* param, XfburnMainWindow * window)
+action_show_filebrowser (GSimpleAction * action, GVariant* value, XfburnMainWindow * window)
{
- action_toggle_state(action);
+ if(g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN))
+ g_simple_action_set_state (action, value);
+
XfburnMainWindowPrivate *priv = XFBURN_MAIN_WINDOW_GET_PRIVATE (window);
GAction *file = g_action_map_lookup_action(G_ACTION_MAP(priv->action_map), "show-filebrowser");
gboolean toggle = g_variant_get_boolean (g_action_get_state (file));
- xfburn_settings_set_boolean ("show-filebrowser", !toggle);
+ xfburn_settings_set_boolean ("show-filebrowser", toggle);
if ( toggle ) {
gtk_widget_show (priv->file_browser);
@@ -647,14 +648,15 @@ action_show_filebrowser (GSimpleAction * action, GVariant* param, XfburnMainWind
}
static void
-action_show_toolbar (GSimpleAction * action, GVariant* param, XfburnMainWindow * window)
+action_show_toolbar (GSimpleAction * action, GVariant* value, XfburnMainWindow * window)
{
- action_toggle_state(action);
+ if(g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN))
+ g_simple_action_set_state (action, value);
XfburnMainWindowPrivate *priv = XFBURN_MAIN_WINDOW_GET_PRIVATE (window);
GAction *tool = g_action_map_lookup_action(G_ACTION_MAP(priv->action_map), "show-toolbar");
gboolean toggle = g_variant_get_boolean (g_action_get_state (tool));
- xfburn_settings_set_boolean ("show-toolbar", !toggle);
+ xfburn_settings_set_boolean ("show-toolbar", toggle);
if ( toggle ) {
gtk_widget_show (priv->toolbars);
@@ -664,14 +666,6 @@ action_show_toolbar (GSimpleAction * action, GVariant* param, XfburnMainWindow *
}
}
-static void
-action_toggle_state (GSimpleAction * action)
-{
- GVariant *state = g_action_get_state (G_ACTION(action));
- gboolean toggle = g_variant_get_boolean (state);
- toggle = !(toggle);
- g_simple_action_set_state (action, g_variant_new_boolean (toggle));
-}
/******************/
/* public methods */
@@ -701,9 +695,9 @@ xfburn_main_window_new (void)
action_map = G_ACTION_MAP (priv->action_map);
/* load settings */
action = g_action_map_lookup_action (action_map, "show-filebrowser");
- g_action_change_state(action, g_variant_new_boolean (xfburn_settings_get_boolean ("show-filebrowser", FALSE)));
+ g_action_change_state (action, g_variant_new_boolean (xfburn_settings_get_boolean ("show-filebrowser", FALSE)));
action = g_action_map_lookup_action (action_map, "show-toolbar");
- g_action_change_state(action, g_variant_new_boolean (xfburn_settings_get_boolean ("show-toolbar", FALSE)));
+ g_action_change_state (action, g_variant_new_boolean (xfburn_settings_get_boolean ("show-toolbar", FALSE)));
/* action = gtk_action_group_get_action (priv->action_group, "save-composition");
gtk_action_set_sensitive (GTK_ACTION (action), FALSE);*/
diff --git a/xfburn/xfburn-main.c b/xfburn/xfburn-main.c
index e06ca6f..014f3bd 100644
--- a/xfburn/xfburn-main.c
+++ b/xfburn/xfburn-main.c
@@ -211,6 +211,7 @@ main (int argc, char **argv)
if (error != NULL) {
g_print (_("%s: %s\nTry %s --help to see a full list of available command line options.\n"), PACKAGE, error->message, PACKAGE_NAME);
g_error_free (error);
+ gdk_threads_leave ();
return EXIT_FAILURE;
}
}
diff --git a/xfburn/xfburn-preferences-dialog.c b/xfburn/xfburn-preferences-dialog.c
index 4c7dd3d..8c3ceae 100644
--- a/xfburn/xfburn-preferences-dialog.c
+++ b/xfburn/xfburn-preferences-dialog.c
@@ -349,7 +349,7 @@ xfburn_preferences_dialog_init (XfburnPreferencesDialog * obj)
/* action buttons */
button_close = gtk_button_new ();
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL,0);
-
+
label = gtk_image_new_from_icon_name ("gtk-close", GTK_ICON_SIZE_BUTTON);
gtk_widget_show (label);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
@@ -361,7 +361,7 @@ xfburn_preferences_dialog_init (XfburnPreferencesDialog * obj)
gtk_container_add (GTK_CONTAINER(button_close), hbox);
gtk_widget_show (button_close);
-
+
gtk_dialog_add_action_widget (GTK_DIALOG (obj), button_close, GTK_RESPONSE_CLOSE);
gtk_widget_set_can_default (button_close, TRUE);
gtk_widget_grab_focus (button_close);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list