~ubuntu-branches/ubuntu/hoary/gimp/hoary

« back to all changes in this revision

Viewing changes to app/actions/text-editor-actions.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2005-04-04 14:51:23 UTC
  • Revision ID: james.westby@ubuntu.com-20050404145123-9py049eeelfymur8
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* The GIMP -- an image manipulation program
 
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; either version 2 of the License, or
 
7
 * (at your option) any later version.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software
 
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
17
 */
 
18
 
 
19
#include "config.h"
 
20
 
 
21
#include <gtk/gtk.h>
 
22
 
 
23
#include "libgimpwidgets/gimpwidgets.h"
 
24
 
 
25
#include "actions-types.h"
 
26
 
 
27
#include "widgets/gimpactiongroup.h"
 
28
#include "widgets/gimptexteditor.h"
 
29
#include "widgets/gimphelp-ids.h"
 
30
 
 
31
#include "text-editor-actions.h"
 
32
#include "text-editor-commands.h"
 
33
 
 
34
#include "gimp-intl.h"
 
35
 
 
36
 
 
37
static GimpActionEntry text_editor_actions[] =
 
38
{
 
39
  { "text-editor-toolbar", GIMP_STOCK_EDIT,
 
40
    "Text Editor Toolbar", NULL, NULL, NULL,
 
41
    GIMP_HELP_TEXT_EDITOR_DIALOG },
 
42
 
 
43
  { "text-editor-load", GTK_STOCK_OPEN,
 
44
    N_("Open"), "",
 
45
    N_("Load text from file"),
 
46
    G_CALLBACK (text_editor_load_cmd_callback),
 
47
    NULL },
 
48
 
 
49
  { "text-editor-clear", GTK_STOCK_CLEAR,
 
50
    N_("Clear"), "",
 
51
    N_("Clear all text"),
 
52
    G_CALLBACK (text_editor_clear_cmd_callback),
 
53
    NULL }
 
54
};
 
55
 
 
56
static GimpRadioActionEntry text_editor_direction_actions[] =
 
57
{
 
58
  { "text-editor-direction-ltr", GIMP_STOCK_TEXT_DIR_LTR,
 
59
    N_("LTR"), "",
 
60
    N_("From left to right"),
 
61
    GIMP_TEXT_DIRECTION_LTR,
 
62
    NULL },
 
63
 
 
64
  { "text-editor-direction-rtl", GIMP_STOCK_TEXT_DIR_RTL,
 
65
    N_("RTL"), "",
 
66
    N_("From right to left"),
 
67
    GIMP_TEXT_DIRECTION_RTL,
 
68
    NULL }
 
69
};
 
70
 
 
71
 
 
72
void
 
73
text_editor_actions_setup (GimpActionGroup *group)
 
74
{
 
75
  gimp_action_group_add_actions (group,
 
76
                                 text_editor_actions,
 
77
                                 G_N_ELEMENTS (text_editor_actions));
 
78
 
 
79
  gimp_action_group_add_radio_actions (group,
 
80
                                       text_editor_direction_actions,
 
81
                                       G_N_ELEMENTS (text_editor_direction_actions),
 
82
                                       GIMP_TEXT_DIRECTION_LTR,
 
83
                                       G_CALLBACK (text_editor_direction_cmd_callback));
 
84
}
 
85
 
 
86
void
 
87
text_editor_actions_update (GimpActionGroup *group,
 
88
                            gpointer         data)
 
89
{
 
90
  GimpTextEditor *editor = GIMP_TEXT_EDITOR (data);
 
91
 
 
92
#define SET_ACTIVE(action,condition) \
 
93
        gimp_action_group_set_action_active (group, action, (condition) != 0)
 
94
 
 
95
  switch (editor->base_dir)
 
96
    {
 
97
    case GIMP_TEXT_DIRECTION_LTR:
 
98
      SET_ACTIVE ("text-editor-direction-ltr", TRUE);
 
99
      break;
 
100
 
 
101
    case GIMP_TEXT_DIRECTION_RTL:
 
102
      SET_ACTIVE ("text-editor-direction-rtl", TRUE);
 
103
      break;
 
104
    }
 
105
 
 
106
#undef SET_ACTIVE
 
107
}