Merge lp:~pivanov/xpad/devel into lp:xpad

Proposed by Paul Ivanov
Status: Merged
Merged at revision: 617
Proposed branch: lp:~pivanov/xpad/devel
Merge into: lp:xpad
Diff against target: None lines
To merge this branch: bzr merge lp:~pivanov/xpad/devel
Reviewer Review Type Date Requested Status
Michael Terry Approve
Review via email: mp+5849@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Paul Ivanov (pivanov) wrote :

I've added a --toggle option

Revision history for this message
Michael Terry (mterry) wrote :

Hey, thanks for the code! It looks good in theory, but I haven't yet had time to sit down and look at the patch. Sorry for the late response. I'll try to get to it soon.

Revision history for this message
Michael Terry (mterry) wrote :

Looks great! Thanks so much. I've made a minor change to xpad_pad_toggle to not require loading and saving the pad's info extra times:

 void
 xpad_pad_toggle(XpadPad *pad)
 {
- gboolean show = TRUE;
- load_info (pad, &show);
- if (show)
+ if (GTK_WIDGET_VISIBLE (pad))
         xpad_pad_close (pad);
     else
         gtk_widget_show (GTK_WIDGET (pad));
- xpad_pad_save_info (pad);
 }

It's merged now!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'NEWS'
--- NEWS 2009-01-11 16:36:47 +0000
+++ NEWS 2009-04-24 07:22:14 +0000
@@ -1,3 +1,5 @@
1* Added --toggle (between --hide and --show). Patch by Paul Ivanov.
2
1Version 3.13Version 3.1
2* Updated Danish, French, Russian, Spanish, and Swedish translations4* Updated Danish, French, Russian, Spanish, and Swedish translations
3* New Czech, Japanese, and Latvian translations5* New Czech, Japanese, and Latvian translations
46
=== modified file 'doc/xpad.1'
--- doc/xpad.1 2008-09-20 22:56:50 +0000
+++ doc/xpad.1 2009-04-24 07:22:14 +0000
@@ -24,6 +24,9 @@
24.B \-s, \-\-show24.B \-s, \-\-show
25Shows existing pads on startup.25Shows existing pads on startup.
26.TP26.TP
27.B \-t, \-\-toggle
28Toggle between showing and hiding each of the existing pads on startup.
29.TP
27.B \-n, \-\-new30.B \-n, \-\-new
28Open a new pad.31Open a new pad.
29.TP32.TP
3033
=== modified file 'src/xpad-app.c'
--- src/xpad-app.c 2008-09-21 00:03:40 +0000
+++ src/xpad-app.c 2009-04-24 07:22:14 +0000
@@ -64,6 +64,7 @@
64static gboolean option_new;64static gboolean option_new;
65static gboolean option_hide;65static gboolean option_hide;
66static gboolean option_show;66static gboolean option_show;
67static gboolean option_toggle;
67static gboolean option_version;68static gboolean option_version;
68static gboolean option_quit;69static gboolean option_quit;
69static gchar **option_files;70static gchar **option_files;
@@ -772,6 +773,7 @@
772 {"new", 'n', 0, G_OPTION_ARG_NONE, &option_new, N_("Create a new pad on startup even if pads already exist"), NULL},773 {"new", 'n', 0, G_OPTION_ARG_NONE, &option_new, N_("Create a new pad on startup even if pads already exist"), NULL},
773 {"hide", 'h', 0, G_OPTION_ARG_NONE, &option_hide, N_("Hide all pads"), NULL},774 {"hide", 'h', 0, G_OPTION_ARG_NONE, &option_hide, N_("Hide all pads"), NULL},
774 {"show", 's', 0, G_OPTION_ARG_NONE, &option_show, N_("Show all pads"), NULL},775 {"show", 's', 0, G_OPTION_ARG_NONE, &option_show, N_("Show all pads"), NULL},
776 {"toggle", 't', 0, G_OPTION_ARG_NONE, &option_toggle, N_("Toggle between show and hide all pads"), NULL},
775 {"new-from-file", 'f', 0, G_OPTION_ARG_FILENAME_ARRAY, &option_files, N_("Create a new pad with the contents of a file"), N_("FILE")},777 {"new-from-file", 'f', 0, G_OPTION_ARG_FILENAME_ARRAY, &option_files, N_("Create a new pad with the contents of a file"), N_("FILE")},
776 {"quit", 'q', 0, G_OPTION_ARG_NONE, &option_quit, N_("Close all pads"), NULL},778 {"quit", 'q', 0, G_OPTION_ARG_NONE, &option_quit, N_("Close all pads"), NULL},
777 {"sm-client-id", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING, &option_smid, NULL, NULL},779 {"sm-client-id", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING, &option_smid, NULL, NULL},
@@ -833,6 +835,7 @@
833 option_smid = NULL;835 option_smid = NULL;
834 option_hide = FALSE;836 option_hide = FALSE;
835 option_show = FALSE;837 option_show = FALSE;
838 option_toggle = FALSE;
836 839
837 context = g_option_context_new (NULL);840 context = g_option_context_new (NULL);
838 g_option_context_set_ignore_unknown_options (context, TRUE);841 g_option_context_set_ignore_unknown_options (context, TRUE);
@@ -855,6 +858,9 @@
855 if (have_gtk && option_hide)858 if (have_gtk && option_hide)
856 xpad_pad_group_close_all (pad_group);859 xpad_pad_group_close_all (pad_group);
857 860
861 if (have_gtk && option_toggle)
862 xpad_pad_group_toggle_hide (pad_group);
863
858 if (have_gtk && option_files)864 if (have_gtk && option_files)
859 {865 {
860 int i;866 int i;
@@ -884,5 +890,5 @@
884 g_option_context_free (context);890 g_option_context_free (context);
885 891
886 return(option_new || option_quit || option_smid || option_files ||892 return(option_new || option_quit || option_smid || option_files ||
887 option_hide || option_show);893 option_hide || option_show || option_toggle);
888}894}
889895
=== modified file 'src/xpad-pad-group.c'
--- src/xpad-pad-group.c 2008-09-21 00:03:40 +0000
+++ src/xpad-pad-group.c 2009-04-24 07:22:14 +0000
@@ -175,3 +175,11 @@
175 g_slist_foreach (group->priv->pads, (GFunc) gtk_widget_show, NULL);175 g_slist_foreach (group->priv->pads, (GFunc) gtk_widget_show, NULL);
176}176}
177177
178
179void
180xpad_pad_group_toggle_hide(XpadPadGroup *group)
181{
182 if (group)
183 g_slist_foreach (group->priv->pads, (GFunc) xpad_pad_toggle, NULL);
184}
185
178186
=== modified file 'src/xpad-pad.c'
--- src/xpad-pad.c 2008-09-21 00:03:40 +0000
+++ src/xpad-pad.c 2009-04-24 07:22:14 +0000
@@ -615,6 +615,18 @@
615 g_signal_emit (pad, signals[CLOSED], 0);615 g_signal_emit (pad, signals[CLOSED], 0);
616}616}
617617
618void
619xpad_pad_toggle(XpadPad *pad)
620{
621 gboolean show = TRUE;
622 load_info (pad, &show);
623 if (show)
624 xpad_pad_close (pad);
625 else
626 gtk_widget_show (GTK_WIDGET (pad));
627 xpad_pad_save_info (pad);
628}
629
618static gboolean630static gboolean
619should_confirm_delete (XpadPad *pad)631should_confirm_delete (XpadPad *pad)
620{632{
621633
=== modified file 'src/xpad-pad.h'
--- src/xpad-pad.h 2008-09-21 00:03:40 +0000
+++ src/xpad-pad.h 2009-04-24 07:22:14 +0000
@@ -57,6 +57,7 @@
57GtkWidget *xpad_pad_new_with_info (XpadPadGroup *group, const gchar *info_filename, gboolean *show);57GtkWidget *xpad_pad_new_with_info (XpadPadGroup *group, const gchar *info_filename, gboolean *show);
58GtkWidget *xpad_pad_new_from_file (XpadPadGroup *group, const gchar *filename);58GtkWidget *xpad_pad_new_from_file (XpadPadGroup *group, const gchar *filename);
59void xpad_pad_close (XpadPad *pad);59void xpad_pad_close (XpadPad *pad);
60void xpad_pad_toggle (XpadPad *pad);
60void xpad_pad_save_info (XpadPad *pad);61void xpad_pad_save_info (XpadPad *pad);
6162
62G_END_DECLS63G_END_DECLS

Subscribers

People subscribed via source and target branches