summaryrefslogtreecommitdiff
path: root/libxfce4kbd-private/xfce-shortcuts-editor-dialog.c
blob: b13e2135b424b787941820c0c1cbb5e3ee63ac70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/* vi:set expandtab sw=2 sts=2: */
/*
 * Copyright (c) 2021 Sergios - Anestis Kefalidis <sergioskefalidis@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <gdk/gdkkeysyms.h>
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>

#include <libxfce4util/libxfce4util.h>
#include <libxfce4ui/libxfce4ui.h>

#include <libxfce4kbd-private/xfce-shortcuts.h>
#include <libxfce4kbd-private/xfce-shortcut-dialog.h>
#include <libxfce4kbd-private/xfce-shortcuts-editor.h>
#include <libxfce4kbd-private/xfce-shortcuts-editor-dialog.h>



struct _XfceShortcutsEditorDialogClass
{
  XfceTitledDialogClass __parent__;
};

struct _XfceShortcutsEditorDialog
{
  XfceTitledDialog    __parent__;
};



G_DEFINE_TYPE (XfceShortcutsEditorDialog, xfce_shortcuts_editor_dialog, XFCE_TYPE_TITLED_DIALOG)



static void
xfce_shortcuts_editor_dialog_class_init (XfceShortcutsEditorDialogClass *klass)
{
  /* Make sure to use the translations from libxfce4ui */
  xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
}



static void
xfce_shortcuts_editor_dialog_init (XfceShortcutsEditorDialog *dialog)
{
  ;
}



/**
 * xfce_shortcuts_editor_dialog_new:
 * @argument_count : #int, the number of arguments, including this one.
 *
 * Returns a dialog that includes a XfceShortcutsEditor.
 * See xfce_shortcuts_editor_new_variadic for the expected types of the variable argument list.
 *
 * Since: 4.17.2
 **/
GtkWidget*
xfce_shortcuts_editor_dialog_new (int argument_count, ...)
{
  XfceShortcutsEditorDialog *dialog;
  va_list                    argument_list;

  va_start (argument_list, argument_count);

  dialog = g_object_new (XFCE_TYPE_SHORTCUTS_EDITOR_DIALOG, NULL);
  gtk_window_set_title (GTK_WINDOW (dialog), _("Shortcuts Editor"));
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), xfce_shortcuts_editor_new_variadic (argument_count, argument_list), TRUE, TRUE, 0);

  /* set a reasonable default size */
  gtk_window_set_default_size (GTK_WINDOW (dialog), 500, 600);

  gtk_widget_show (GTK_WIDGET (dialog));

  va_end (argument_list);

  return GTK_WIDGET (dialog);
}



/**
 * xfce_shortcuts_editor_dialog_new_with_parent:
 * @parent         : #GtkWindow, the parent window of the dialog, used in gtk_window_set_transient_for (can be NULL).
 * @argument_count : #int, the number of arguments, including this one.
 *
 * Returns a dialog that includes a XfceShortcutsEditor.
 * See xfce_shortcuts_editor_new_variadic for the expected types of the variable argument list.
 *
 * Since: 4.17.5
 **/
GtkWidget*
xfce_shortcuts_editor_dialog_new_with_parent (GtkWindow *parent,
                                              int        argument_count,
                                              ...        )
{
  XfceShortcutsEditorDialog *dialog;
  va_list                    argument_list;

  va_start (argument_list, argument_count);

  /* create the dialog and its content */
  dialog = g_object_new (XFCE_TYPE_SHORTCUTS_EDITOR_DIALOG, NULL);
  gtk_window_set_title (GTK_WINDOW (dialog), _("Shortcuts Editor"));
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), xfce_shortcuts_editor_new_variadic (argument_count, argument_list), TRUE, TRUE, 0);

  /* set a reasonable default size */
  gtk_window_set_default_size (GTK_WINDOW (dialog), 500, 600);

  /* center the dialog on top of the parent widget */
  gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));

  gtk_widget_show (GTK_WIDGET (dialog));

  va_end (argument_list);

  return GTK_WIDGET (dialog);
}