~ubuntu-branches/ubuntu/saucy/darktable/saucy

« back to all changes in this revision

Viewing changes to src/libs/file_manager.c

  • Committer: Bazaar Package Importer
  • Author(s): David Bremner
  • Date: 2011-07-12 09:36:46 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110712093646-yp9dbxan44dmw15h
Tags: 0.9-1
* New upstream release.
* Remove all patches now upstream; only patch for
  -Wno-error=unused-but-set-variable remains.
* Bump Standards-Version to 3.9.2 (no changes)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    This file is part of darktable,
 
3
    copyright (c) 2011 tobias ellinghaus.
 
4
 
 
5
    darktable is free software: you can redistribute it and/or modify
 
6
    it under the terms of the GNU General Public License as published by
 
7
    the Free Software Foundation, either version 3 of the License, or
 
8
    (at your option) any later version.
 
9
 
 
10
    darktable is distributed in the hope that it will be useful,
 
11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
    GNU General Public License for more details.
 
14
 
 
15
    You should have received a copy of the GNU General Public License
 
16
    along with darktable.  If not, see <http://www.gnu.org/licenses/>.
 
17
*/
 
18
 
 
19
#include "common/darktable.h"
 
20
#include "common/debug.h"
 
21
#include "control/control.h"
 
22
#include "control/conf.h"
 
23
#include "libs/lib.h"
 
24
#include "gui/gtk.h"
 
25
#include <vte/vte.h>
 
26
#include <signal.h>
 
27
 
 
28
DT_MODULE(1)
 
29
 
 
30
typedef struct dt_lib_file_manager_t
 
31
{
 
32
  pid_t        pid;
 
33
  VteTerminal *terminal;
 
34
}
 
35
dt_lib_file_manager_t;
 
36
 
 
37
const char* name()
 
38
{
 
39
  // FIXME: Hack to get a translated name without the need to touch the .po files
 
40
//   char* n = _("zoomable light table\nfile manager");
 
41
//   while(*n != '\n') n++; n++;
 
42
//   return n;
 
43
  return _("file manager");
 
44
}
 
45
 
 
46
uint32_t views()
 
47
{
 
48
  return DT_LIGHTTABLE_VIEW|DT_CAPTURE_VIEW;
 
49
}
 
50
 
 
51
void gui_reset(dt_lib_module_t *self)
 
52
{
 
53
  dt_lib_file_manager_t *d = (dt_lib_file_manager_t*) self->data;
 
54
  kill(d->pid, SIGHUP);
 
55
#ifdef VTE_DEPRECATED
 
56
  d->pid = vte_terminal_fork_command(d->terminal, NULL, NULL, NULL, NULL, FALSE, FALSE, FALSE);
 
57
#else
 
58
  char* argv[2] = {g_strdup(g_getenv("SHELL")), NULL};
 
59
  vte_terminal_fork_command_full(d->terminal, VTE_PTY_DEFAULT, NULL, argv, NULL, 0, NULL, NULL, &d->pid, NULL);
 
60
  g_free(argv[0]);
 
61
#endif
 
62
  vte_terminal_reset(d->terminal, TRUE, TRUE);
 
63
}
 
64
 
 
65
int position()
 
66
{
 
67
  return 510;
 
68
}
 
69
 
 
70
void gui_init(dt_lib_module_t *self)
 
71
{
 
72
  dt_lib_file_manager_t *d = (dt_lib_file_manager_t *)g_malloc(sizeof(dt_lib_file_manager_t));
 
73
  self->data = (void *)d;
 
74
 
 
75
  d->terminal = VTE_TERMINAL(vte_terminal_new());
 
76
  self->widget = GTK_WIDGET(d->terminal);
 
77
  dt_gui_key_accel_block_on_focus(GTK_WIDGET(d->terminal));
 
78
#if defined(__MACH__) || defined(__APPLE__)
 
79
  vte_terminal_set_font_from_string(d->terminal, "Monospace 11");
 
80
#else
 
81
  vte_terminal_set_font_from_string(d->terminal, "Monospace 8");
 
82
#endif
 
83
#ifdef VTE_DEPRECATED
 
84
  d->pid = vte_terminal_fork_command(d->terminal, NULL, NULL, NULL, NULL, FALSE, FALSE, FALSE);
 
85
#else
 
86
  char* argv[2] = {g_strdup(g_getenv("SHELL")), NULL};
 
87
  vte_terminal_fork_command_full(d->terminal, VTE_PTY_DEFAULT, NULL, argv, NULL, 0, NULL, NULL, &d->pid, NULL);
 
88
  g_free(argv[0]);
 
89
#endif
 
90
  g_object_set(G_OBJECT(d->terminal), "tooltip-text", _("\
 
91
ls\t\t\t\t\tlist content of directory\n\
 
92
cd <dir>\t\t\tchange directory\n\
 
93
mkdir <dir>\t\t\tcreate directory\n\
 
94
mv <src> <dst>\tmove <src> to <dst>\n\
 
95
cp <src> <dst>\t\tcopy <src> to <dst>\n\
 
96
rm <file>\t\t\tdelete <file>\n\
 
97
rmdir <dir>\t\t\tdelete empty directory"), (char *)NULL);
 
98
 
 
99
}
 
100
 
 
101
void gui_cleanup(dt_lib_module_t *self)
 
102
{
 
103
  darktable.gui->redraw_widgets = g_list_remove(darktable.gui->redraw_widgets, self->widget);
 
104
  dt_lib_file_manager_t *d = (dt_lib_file_manager_t*) self->data;
 
105
  kill(d->pid, SIGKILL);
 
106
  g_free(self->data);
 
107
  self->data = NULL;
 
108
}
 
109
 
 
110
// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-space on;