Code

45ad08aa92134a96a2af151eaf43fb28e3880999
[inkscape.git] / src / widgets / calligraphic-profile-rename.cpp
1 /**
2  *
3  * \brief  Dialog for naming calligraphic profiles
4  *
5  * Author:
6  *   Aubanel MONNIER 
7  *
8  * Copyright (C) 2007 Aubanel MONNIER
9  *
10  * Released under GNU GPL.  Read the file 'COPYING' for more information
11  */
13 #ifdef HAVE_CONFIG_H
14 # include <config.h>
15 #endif
17 #include <glibmm/i18n.h>
18 #include <gtkmm/stock.h>
20 #include "desktop.h"
21 #include "calligraphic-profile-rename.h"
24 namespace Inkscape {
25 namespace UI {
26 namespace Dialogs {
27 CalligraphicProfileDialog::CalligraphicProfileDialog(): _applied(false){
28   Gtk::VBox *mainVBox = get_vbox();
29   _layout_table.set_spacings(4);
30   _layout_table.resize (1, 2);
32   _profile_name_entry.set_activates_default(true);
34   _profile_name_label.set_label(_("Profile name:"));
35   _profile_name_label.set_alignment(1.0, 0.5);
36   
37   _layout_table.attach(_profile_name_label,
38                        0, 1, 0, 1, Gtk::FILL, Gtk::FILL);
39   _layout_table.attach(_profile_name_entry,
40                        1, 2, 0, 1, Gtk::FILL | Gtk::EXPAND, Gtk::FILL);
41   mainVBox->pack_start(_layout_table, false, false, 4);
42   // Buttons
43   _close_button.set_use_stock(true);
44   _close_button.set_label(Gtk::Stock::CANCEL.id);
45   _close_button.set_flags(Gtk::CAN_DEFAULT);
46   
47   _apply_button.set_use_underline(true);
48   _apply_button.set_label(_("Save"));
49   _apply_button.set_flags(Gtk::CAN_DEFAULT);
50   
51   _close_button.signal_clicked()
52     .connect(sigc::mem_fun(*this, &CalligraphicProfileDialog::_close));
53   _apply_button.signal_clicked()
54     .connect(sigc::mem_fun(*this, &CalligraphicProfileDialog::_apply));
55   
56   signal_delete_event().connect(
57         sigc::bind_return(
58             sigc::hide(sigc::mem_fun(*this, &CalligraphicProfileDialog::_close)),
59             true
60         )
61     );
63   add_action_widget(_close_button, Gtk::RESPONSE_CLOSE);
64   add_action_widget(_apply_button, Gtk::RESPONSE_APPLY);
66   _apply_button.grab_default();
68   show_all_children();
70 }
72 void
73 CalligraphicProfileDialog::_apply()
74 {
75   _profile_name = _profile_name_entry.get_text();
76   _applied = true;
77   _close();
78 }
80 void
81 CalligraphicProfileDialog::_close()
82 {
83   this->Gtk::Dialog::hide();
84   
85 }
87 void CalligraphicProfileDialog::show(SPDesktop *desktop){
88   CalligraphicProfileDialog &dial = instance();
89   dial._applied=false;
90   dial.set_modal(true);
91   desktop->setWindowTransient (dial.gobj());
92   dial.property_destroy_with_parent() = true;
93   //  dial.Gtk::Dialog::show();
94   //dial.present();
95   dial.run();
96 }
99 }}}