Skip to content

Commit 735150e

Browse files
committed
polish
1 parent b012811 commit 735150e

File tree

5 files changed

+49
-35
lines changed

5 files changed

+49
-35
lines changed

TODO

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
- merge tab should not work when locked
2-
3-
- scroll to view current column after tab merge
4-
5-
- merge actions should be more robust
6-
71
- load ws with locked tab, rightclick menu on locked tab does not
82
have tick selected
93

104
two tabs, lock one, menu on other also shows lock
115

126
a bit tricky to fix
137

8+
maybe we are forced to have a separate menu for each tab?
9+
1410
- the "new tab" icon is still broken in the windows build
1511

1612
# menu redesign

src/columnview.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,10 +568,13 @@ columnview_action(GSimpleAction *action, GVariant *parameter, View *view)
568568
}
569569
else if (g_str_equal(name, "column-merge") &&
570570
parameter) {
571-
Column *from =
572-
workspace_column_find(ws, g_variant_get_string(parameter, NULL));
573-
char filename[VIPS_PATH_MAX];
571+
const char *from_name = g_variant_get_string(parameter, NULL);
572+
Column *from = workspace_column_find(ws, from_name);
573+
574+
if (!(from = workspace_column_find(ws, from_name)))
575+
return;
574576

577+
char filename[VIPS_PATH_MAX];
575578
if (!temp_name(filename, IOBJECT(from)->name, "ws")) {
576579
workspace_set_show_error(ws, TRUE);
577580
return;

src/workspacegroup.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,21 @@ workspacegroup_map(Workspacegroup *wsg, workspace_map_fn fn, void *a, void *b)
8686
(icontainer_map_fn) fn, a, b);
8787
}
8888

89+
static void *
90+
workspacegroup_find_workspace_sub(Workspace *ws, void *a)
91+
{
92+
const char *name = (const char *) a;
93+
94+
return g_str_equal(IOBJECT(ws)->name, name) ? ws : NULL;
95+
}
96+
97+
Workspace *
98+
workspacegroup_find_workspace(Workspacegroup *wsg, const char *name)
99+
{
100+
return WORKSPACE(workspacegroup_map(wsg,
101+
workspacegroup_find_workspace_sub, (void *) name, NULL));
102+
}
103+
89104
static void *
90105
workspacegroup_is_empty_sub(Workspace *ws, gboolean *empty)
91106
{

src/workspacegroup.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ Workspace *workspacegroup_map(Workspacegroup *wsg,
105105

106106
GType workspacegroup_get_type(void);
107107

108+
Workspace *workspacegroup_find_workspace(Workspacegroup *wsg, const char *name);
108109
gboolean workspacegroup_is_empty(Workspacegroup *wsg);
109110

110111
Workspacegroup *workspacegroup_new(Workspaceroot *wsr);

src/workspaceview.c

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -824,14 +824,6 @@ workspaceview_merge(Workspaceview *wview)
824824
&workspaceview_merge_sub, wview);
825825
}
826826

827-
static void *
828-
workspaceview_find_workspace(Workspace *ws, void *a)
829-
{
830-
const char *name = (const char *) a;
831-
832-
return g_str_equal(IOBJECT(ws)->name, name) ? ws : NULL;
833-
}
834-
835827
static void
836828
workspaceview_action(GSimpleAction *action, GVariant *parameter, View *view)
837829
{
@@ -841,41 +833,48 @@ workspaceview_action(GSimpleAction *action, GVariant *parameter, View *view)
841833
Workspace *ws = WORKSPACE(VOBJECT(wview)->iobject);
842834
const char *name = g_action_get_name(G_ACTION(action));
843835

844-
if (g_str_equal(name, "column-new"))
836+
if (g_str_equal(name, "column-new") &&
837+
!ws->locked)
845838
workspace_column_new(ws);
846839
else if (g_str_equal(name, "next-error"))
847840
workspace_set_show_error(ws, workspace_next_error(ws));
848-
else if (g_str_equal(name, "program"))
841+
else if (g_str_equal(name, "program") &&
842+
!ws->locked)
849843
program_new(app, ws->kitg);
850-
else if (g_str_equal(name, "tab-rename"))
844+
else if (g_str_equal(name, "tab-rename") &&
845+
!ws->locked)
851846
g_object_set(wview->label,
852847
"edit", TRUE,
853848
NULL);
854-
else if (g_str_equal(name, "tab-select-all")) {
855-
if (!ws->locked)
856-
workspace_select_all(ws);
857-
}
849+
else if (g_str_equal(name, "tab-select-all") &&
850+
!ws->locked)
851+
workspace_select_all(ws);
858852
else if (g_str_equal(name, "tab-duplicate"))
859853
workspace_duplicate(ws);
860854
else if (g_str_equal(name, "tab-merge") &&
861-
parameter) {
855+
parameter &&
856+
!ws->locked) {
857+
const char *from_name = g_variant_get_string(parameter, NULL);
862858
Workspacegroup *wsg = workspace_get_workspacegroup(ws);
863-
Workspace *from = workspacegroup_map(wsg,
864-
workspaceview_find_workspace,
865-
(void *) g_variant_get_string(parameter, NULL), NULL);
866-
char filename[VIPS_PATH_MAX];
867859

860+
Workspace *from;
861+
862+
if (!(from = workspacegroup_find_workspace(wsg, from_name)))
863+
return;
864+
865+
char filename[VIPS_PATH_MAX];
868866
if (!temp_name(filename, IOBJECT(from)->name, "ws")) {
869867
workspace_set_show_error(ws, TRUE);
870868
return;
871869
}
872870

873-
icontainer_current(ICONTAINER(wsg), ICONTAINER(ws));
871+
icontainer_current(ICONTAINER(wsg), ICONTAINER(from));
874872
if (!workspacegroup_save_current(wsg, filename)) {
875873
workspace_set_show_error(ws, TRUE);
876874
return;
877875
}
878876

877+
icontainer_current(ICONTAINER(wsg), ICONTAINER(ws));
879878
if (!workspace_merge_file(ws, filename)) {
880879
workspace_set_show_error(ws, TRUE);
881880
return;
@@ -886,7 +885,8 @@ workspaceview_action(GSimpleAction *action, GVariant *parameter, View *view)
886885
workspace_deselect_all(ws);
887886
symbol_recalculate_all();
888887
}
889-
else if (g_str_equal(name, "tab-merge-file"))
888+
else if (g_str_equal(name, "tab-merge-file") &&
889+
!ws->locked)
890890
workspaceview_merge(wview);
891891
else if (g_str_equal(name, "tab-saveas"))
892892
workspaceview_saveas(wview);
@@ -896,10 +896,9 @@ workspaceview_action(GSimpleAction *action, GVariant *parameter, View *view)
896896
GVariant *locked = g_variant_new_boolean(ws->locked);
897897
g_simple_action_set_state(action, locked);
898898
}
899-
else if (g_str_equal(name, "tab-delete")) {
900-
if (!ws->locked)
901-
model_check_destroy(view_get_window(VIEW(wview)), MODEL(ws));
902-
}
899+
else if (g_str_equal(name, "tab-delete") &&
900+
!ws->locked)
901+
model_check_destroy(view_get_window(VIEW(wview)), MODEL(ws));
903902
}
904903

905904
static void

0 commit comments

Comments
 (0)