#include <gtk/gtk.h>
Go to the source code of this file.
Functions | |
G_BEGIN_DECLS GtkWidget * | rename_dialog_create (const GtkWidget *parent, const gchar *current_filename) |
void | rename_locale_changed () |
const gchar * | rename_get_text () |
void | rename_set_focus () |
G_BEGIN_DECLS GtkWidget* rename_dialog_create | ( | const GtkWidget * | parent, | |
const gchar * | current_filename | |||
) |
File Name : notepad_rename.h
Description: rename dialog Copyright (C) 2010 IREX Technologies B.V. All rights reserved.
Definition at line 98 of file notepad_rename.cpp.
References BUTTON_HEIGHT, BUTTON_WIDTH, ergtk_keyb_new(), g_cancel_button, g_dialog, g_input_entry, g_lastfilename, g_rename_button, g_rename_label, MAX_FILENAME_LEN, POPUP_DIALOG_H_PADDING, POPUP_DIALOG_H_SPACING, POPUP_DIALOG_V_PADDING, POPUP_DIALOG_V_SPACING, POPUP_DIALOG_WIDTH, rename_locale_changed(), rename_on_cancel_button_clicked(), rename_on_hbox_size_allocate(), rename_on_rename_button_clicked(), TEXT_ENTRY_HEIGHT, and TEXT_ENTRY_WIDTH.
Referenced by notepad::CNotepadWindow::rename().
00099 { 00100 00101 // dialog 00102 GtkWidget* dialog = gtk_dialog_new (); 00103 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); 00104 gtk_window_set_title (GTK_WINDOW(dialog), ""); 00105 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); 00106 gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(parent)); 00107 gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); 00108 g_dialog = dialog; 00109 00110 // alignment 00111 GtkWidget* alignment = gtk_alignment_new(0.0, 0.0, 1.0, 0); 00112 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 00113 POPUP_DIALOG_V_PADDING, 00114 POPUP_DIALOG_V_PADDING, 00115 POPUP_DIALOG_H_PADDING, 00116 POPUP_DIALOG_H_PADDING); 00117 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), alignment); 00118 00119 // vbox 00120 GtkWidget* vbox = gtk_vbox_new(FALSE, POPUP_DIALOG_V_SPACING); 00121 gtk_container_add(GTK_CONTAINER(alignment), vbox); 00122 00123 // rename_label_widget 00124 GtkWidget * rename_label_widget = gtk_label_new(""); 00125 gtk_widget_set_name(rename_label_widget, "irex-normal-text"); 00126 gtk_widget_set_size_request(rename_label_widget, 00127 POPUP_DIALOG_WIDTH - 2 * POPUP_DIALOG_H_PADDING, -1); 00128 gtk_misc_set_alignment(GTK_MISC(rename_label_widget), 0.0, 0.0); 00129 gtk_label_set_justify(GTK_LABEL(rename_label_widget), GTK_JUSTIFY_LEFT); 00130 gtk_label_set_single_line_mode(GTK_LABEL(rename_label_widget), FALSE); 00131 gtk_label_set_line_wrap(GTK_LABEL(rename_label_widget), TRUE); 00132 gtk_label_set_ellipsize(GTK_LABEL(rename_label_widget), PANGO_ELLIPSIZE_NONE); 00133 gtk_box_pack_start(GTK_BOX(vbox), rename_label_widget, TRUE, TRUE, 0); 00134 g_rename_label = rename_label_widget; 00135 00136 // hbox 00137 GtkWidget* hbox = gtk_hbox_new(FALSE, POPUP_DIALOG_H_SPACING); 00138 gtk_widget_set_size_request(hbox, -1, -1); 00139 gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0); 00140 00141 // input_entry 00142 GtkWidget* entry_widget = gtk_entry_new(); 00143 gtk_widget_set_size_request(entry_widget, TEXT_ENTRY_WIDTH, TEXT_ENTRY_HEIGHT); 00144 gtk_entry_set_max_length(GTK_ENTRY(entry_widget), MAX_FILENAME_LEN); 00145 g_free(g_lastfilename); 00146 g_lastfilename = g_strdup(current_filename); 00147 00148 if (g_lastfilename) 00149 gtk_entry_set_text(GTK_ENTRY(entry_widget), g_lastfilename); 00150 else 00151 gtk_entry_set_text(GTK_ENTRY(entry_widget), ""); 00152 00153 gtk_box_pack_start(GTK_BOX(hbox), entry_widget, TRUE, TRUE, 0); 00154 g_object_set(G_OBJECT(entry_widget), "im-context-inhibit", TRUE, NULL ); 00155 g_object_set(G_OBJECT(entry_widget), "activates-default", TRUE, NULL ); 00156 g_input_entry = entry_widget; 00157 00158 // sub_hbox 00159 GtkWidget* sub_hbox = gtk_hbox_new(FALSE, POPUP_DIALOG_H_SPACING); 00160 gtk_box_pack_start(GTK_BOX(hbox), sub_hbox, FALSE, FALSE, 0); 00161 00162 // rename_button 00163 GtkWidget* button_widget = gtk_button_new(); 00164 gtk_widget_set_size_request(button_widget, BUTTON_WIDTH, BUTTON_HEIGHT); 00165 gtk_box_pack_start(GTK_BOX(sub_hbox), button_widget, FALSE, FALSE, 0); 00166 g_rename_button = button_widget; 00167 GTK_WIDGET_SET_FLAGS(g_rename_button, GTK_CAN_DEFAULT); 00168 gtk_window_set_default(GTK_WINDOW(dialog), g_rename_button); 00169 00170 // cancel_button 00171 GtkWidget* cancel_widget = gtk_button_new(); 00172 gtk_widget_set_size_request(cancel_widget, BUTTON_WIDTH, BUTTON_HEIGHT); 00173 gtk_box_pack_start(GTK_BOX(sub_hbox), cancel_widget, FALSE, FALSE, 0); 00174 g_cancel_button = cancel_widget; 00175 00176 // keyboard_widget 00177 GtkWidget* keyboard_widget = ergtk_keyb_new(); 00178 gtk_box_pack_start(GTK_BOX(vbox), keyboard_widget, TRUE, TRUE, 10); 00179 00180 // install signal hanlders. 00181 g_signal_connect(G_OBJECT(sub_hbox), "size-allocate", 00182 G_CALLBACK(rename_on_hbox_size_allocate), sub_hbox); 00183 g_signal_connect(G_OBJECT(button_widget), "clicked", 00184 G_CALLBACK(rename_on_rename_button_clicked), (gpointer) dialog); 00185 g_signal_connect(G_OBJECT(cancel_widget), "clicked", 00186 G_CALLBACK(rename_on_cancel_button_clicked), (gpointer) dialog); 00187 00188 // Focus on the entry in order to show keyboard automatically. 00189 gtk_widget_grab_focus(g_input_entry); 00190 00191 rename_locale_changed(); 00192 00193 gtk_widget_show_all(dialog); 00194 return dialog; 00195 }
const gchar* rename_get_text | ( | ) |
Definition at line 209 of file notepad_rename.cpp.
References g_lastfilename, and LOGPRINTF.
00210 { 00211 LOGPRINTF("%s", g_lastfilename); 00212 return g_lastfilename; 00213 }
void rename_locale_changed | ( | ) |
Definition at line 198 of file notepad_rename.cpp.
References g_cancel_button, g_rename_button, and g_rename_label.
Referenced by rename_dialog_create().
00199 { 00200 gtk_label_set_text(GTK_LABEL(g_rename_label), 00201 _("Type the new name for this note and then tap the Rename button to save it. \n" 00202 " / \\ |: * ? < or > cannot be used in the name and it cannot begin with a space or period.")); 00203 00204 gtk_button_set_label(GTK_BUTTON(g_rename_button), _("Rename")); 00205 gtk_button_set_label(GTK_BUTTON(g_cancel_button), _("Cancel")); 00206 }
void rename_set_focus | ( | ) |
Definition at line 216 of file notepad_rename.cpp.
References g_input_entry.
00217 { 00218 gtk_widget_grab_focus(g_input_entry); 00219 }