File: gmentrydialog.c

package info (click to toggle)
ekiga 4.0.1-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 31,612 kB
  • ctags: 14,511
  • sloc: cpp: 72,155; sh: 11,298; xml: 8,904; ansic: 8,572; makefile: 1,738; asm: 453; awk: 16
file content (130 lines) | stat: -rw-r--r-- 3,816 bytes parent folder | download | duplicates (2)
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

/* Ekiga -- A VoIP and Video-Conferencing application
 * Copyright (C) 2000-2009 Damien Sandras <dsandras@seconix.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 *
 * Ekiga is licensed under the GPL license and as a special exception,
 * you have permission to link or otherwise combine this program with the
 * programs OPAL, OpenH323 and PWLIB, and distribute the combination,
 * without applying the requirements of the GNU GPL to the OPAL, OpenH323
 * and PWLIB programs, as long as you do follow the requirements of the
 * GNU GPL for all the rest of the software thus combined.
 */


/*
 *                         gmentrydialog.c  -  description
 *                         -------------------------------
 *   begin                : Sat Jan 03 2004
 *   copyright            : (C) 2000-2006 by Damien Sandras
 *   description          : Contains a gmentrydialog widget permitting to
 *                          quickly build GtkDialogs with a +rw GtkEntry
 *                          field.
 *
 */


#include "gmentrydialog.h"


struct _GmEntryDialogPrivate {

  GtkWidget *field_entry;
  GtkWidget *label;
};

G_DEFINE_TYPE (GmEntryDialog, gm_entry_dialog, GTK_TYPE_DIALOG);

/* Static functions and declarations */
static void gm_entry_dialog_class_init (GmEntryDialogClass *);

static void gm_entry_dialog_init (GmEntryDialog *);


static void
gm_entry_dialog_class_init (GmEntryDialogClass *klass)
{
  g_type_class_add_private (klass, sizeof (GmEntryDialogPrivate));
}


static void
gm_entry_dialog_init (GmEntryDialog* self)
{
  GtkWidget *hbox = NULL;

  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
					    GM_TYPE_ENTRY_DIALOG,
					    GmEntryDialogPrivate);
  self->priv->field_entry = gtk_entry_new ();
  gtk_entry_set_activates_default (GTK_ENTRY (self->priv->field_entry), TRUE);

  self->priv->label = gtk_label_new (NULL);

  hbox = gtk_hbox_new (FALSE, 6);
  gtk_box_pack_start (GTK_BOX (hbox), self->priv->label, FALSE, FALSE, 6);
  gtk_box_pack_start (GTK_BOX (hbox), self->priv->field_entry, FALSE, FALSE, 6);

  gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (self))), hbox);

  gtk_dialog_add_buttons (GTK_DIALOG (self),
			  GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);

  gtk_window_set_modal (GTK_WINDOW (self), TRUE);
}


/* public api */

GtkWidget *
gm_entry_dialog_new (const char *label,
		     const char *button_label)
{
  GmEntryDialog *ed = NULL;

  ed =
    GM_ENTRY_DIALOG (g_object_new (GM_TYPE_ENTRY_DIALOG, NULL));

  gtk_label_set_text (GTK_LABEL (GM_ENTRY_DIALOG (ed)->priv->label), label);

  gtk_dialog_add_buttons (GTK_DIALOG (ed),
			  button_label, GTK_RESPONSE_ACCEPT, NULL);

  gtk_widget_show_all (GTK_WIDGET (ed));

  return GTK_WIDGET (ed);
}


void
gm_entry_dialog_set_text (GmEntryDialog *ed,
			  const char *text)
{
  g_return_if_fail (GM_ENTRY_DIALOG (ed));
  g_return_if_fail (text != NULL);

  gtk_entry_set_text (GTK_ENTRY (ed->priv->field_entry), text);
}


const gchar *
gm_entry_dialog_get_text (GmEntryDialog *ed)
{
  g_return_val_if_fail (GM_ENTRY_DIALOG (ed), NULL);

  return gtk_entry_get_text (GTK_ENTRY (ed->priv->field_entry));
}