~ubuntu-branches/ubuntu/intrepid/notecase/intrepid

« back to all changes in this revision

Viewing changes to src/ShortcutsListDlg.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mitsuya Shibata
  • Date: 2008-01-18 01:54:05 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080118015405-id2r7kphpxlyjzfi
Tags: 1.7.6-0ubuntu1
* New Upstream Release (Closes LP: #182226)
*  Fix failed assertion when change node level (Closes LP: #137464)
* Exclude help.ncd and any .ncd file from compression (Closes LP: #113959)
* Adapted debian/ directory to upstream deb/ directory
* Add debian/watch file
* Remove debian/README.Debian because it is now unnecessary
* Bump up compat level from 4 to 5
* Updating debian/menu file to use the new menu hierarchy
* Modify debian/control file
*  Bump up Standards-Version field from 3.6.1 to 3.7.3
*  Change Section field from x11 to editors
*  Change Build-Depends debhelper version to >=5, libgtk2.0-dev to >=2.4
*  Move Homepage field from description to regular field

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
#include <string>
17
17
#include <gdk/gdkkeysyms.h>
18
18
 
 
19
#include "../res/bulb.xpm"
 
20
 
19
21
#ifdef _WIN32
20
22
 #include <windows.h>
21
23
 #ifndef __MINGW32__
29
31
extern ShortcutsList g_lstDefAction;
30
32
gint treeview_keyboard_handler(GtkWidget *widget, GdkEventKey *event, gpointer data);
31
33
static void on_ok_clicked (GtkButton *button, gpointer user_data);
 
34
static void on_cancel_clicked (GtkButton *button, gpointer user_data);
32
35
static void on_context_combo_selected (GtkComboBox *widget, gpointer user_data);
33
36
static void on_clear_all_clicked (GtkButton *button, gpointer user_data);
34
37
static void on_reset_all_clicked (GtkButton *button, gpointer user_data);
101
104
        shortcuts_dialog = gtk_dialog_new ();
102
105
        gtk_window_set_title (GTK_WINDOW (shortcuts_dialog), _("Shortcut editor"));
103
106
        gtk_window_set_type_hint (GTK_WINDOW (shortcuts_dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
104
 
        gtk_widget_set_size_request(shortcuts_dialog, 400, 300);
 
107
        gtk_window_set_default_size(GTK_WINDOW(shortcuts_dialog), 420, 450);
 
108
        gtk_window_set_modal (GTK_WINDOW (shortcuts_dialog), TRUE);
 
109
        gtk_window_set_destroy_with_parent (GTK_WINDOW (shortcuts_dialog), TRUE);
 
110
#ifndef _WIN32  //TOFIX API is buggy on Win32 (kills modal dialog state)
 
111
        gtk_window_set_skip_taskbar_hint (GTK_WINDOW (shortcuts_dialog), TRUE);
 
112
#endif
 
113
        gtk_window_set_skip_pager_hint (GTK_WINDOW (shortcuts_dialog), TRUE);
 
114
        gtk_window_set_transient_for(GTK_WINDOW (shortcuts_dialog), GTK_WINDOW(window1));   //set parent
 
115
 
105
116
 
106
117
        dialog_vbox8 = GTK_DIALOG (shortcuts_dialog)->vbox;
107
118
        gtk_widget_show (dialog_vbox8);
167
178
        gtk_tree_view_column_add_attribute(col, renderer, "text", 1); 
168
179
        gtk_tree_view_append_column(GTK_TREE_VIEW(treeview3), col);
169
180
 
 
181
        GtkWidget *hbox1 = gtk_hbox_new (FALSE, 0);
 
182
        gtk_widget_show (hbox1);
 
183
        gtk_box_pack_start (GTK_BOX (dialog_vbox8), hbox1, FALSE, TRUE, 5);
 
184
        
 
185
        GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **)&bulb);
 
186
        GtkWidget *icon = gtk_image_new_from_pixbuf (pixbuf);
 
187
        gtk_widget_show (icon);
 
188
        gtk_box_pack_start (GTK_BOX (hbox1), icon, FALSE, TRUE, 2);
 
189
 
170
190
        label35 = gtk_label_new (_("Use mouse click to select an action, and then press key combination to assign the shortcut to it. Some actions are listed in more than one context so they can have more than one shortcut attached."));
171
191
        gtk_widget_show (label35);
172
 
        gtk_box_pack_start (GTK_BOX (dialog_vbox8), label35, FALSE, TRUE, 5);
 
192
        gtk_box_pack_start (GTK_BOX (hbox1), label35, TRUE, TRUE, 2);
173
193
        gtk_misc_set_alignment (GTK_MISC (label35), 0.5, 0.5);
174
194
        gtk_label_set_line_wrap(GTK_LABEL(label35), true); 
 
195
#if GTK_CHECK_VERSION(2,10,0) //minimal version for this api
 
196
        gtk_label_set_line_wrap_mode(GTK_LABEL(label35), PANGO_WRAP_WORD_CHAR);
 
197
#endif
 
198
 
 
199
        //action area
175
200
 
176
201
        dialog_action_area8 = GTK_DIALOG (shortcuts_dialog)->action_area;
177
202
        gtk_widget_show (dialog_action_area8);
189
214
        GTK_WIDGET_SET_FLAGS (resetall_btn, GTK_CAN_DEFAULT);
190
215
        g_signal_connect(resetall_btn, "clicked", G_CALLBACK (on_reset_all_clicked), this);
191
216
 
192
 
        cancelbutton8 = gtk_button_new_from_stock ("gtk-cancel");
 
217
        cancelbutton8 = gtk_button_new_with_mnemonic (_("Cancel"));
193
218
        gtk_widget_show (cancelbutton8);
194
219
        gtk_dialog_add_action_widget (GTK_DIALOG (shortcuts_dialog), cancelbutton8, GTK_RESPONSE_CANCEL);
195
220
        GTK_WIDGET_SET_FLAGS (cancelbutton8, GTK_CAN_DEFAULT);
 
221
        g_signal_connect(cancelbutton8, "clicked", G_CALLBACK (on_cancel_clicked), this);
196
222
 
197
 
        okbutton8 = gtk_button_new_from_stock ("gtk-ok");
 
223
        okbutton8 = gtk_button_new_with_mnemonic (_("OK"));
198
224
        gtk_widget_show (okbutton8);
199
225
        gtk_container_add (GTK_CONTAINER(dialog_action_area8), okbutton8);
200
226
        GTK_WIDGET_SET_FLAGS (okbutton8, GTK_CAN_DEFAULT);
264
290
 
265
291
        //check if shortcut is already taken by someone else
266
292
        int nOwnerIdx = m_list.FindByKey(def, nIdx);
267
 
        if(nOwnerIdx >= 0){
 
293
        if(nOwnerIdx >= 0 && 
 
294
                (m_list[nOwnerIdx].m_nActionID != def.m_nActionID ||
 
295
                 m_list[nOwnerIdx].m_nCtx != def.m_nCtx)){
268
296
                gtkMessageBox(_("This shortcut combination is already taken!"));        
269
297
                return;
270
298
        }
314
342
                        continue;       //skip different context
315
343
                                
316
344
                int nPos = g_lstDefAction.FindByAction(m_list[j].m_nActionID, nCtx);
317
 
                ASSERT(nPos >= 0);
318
 
                int nIdx = nPos - nStart;
319
 
 
320
 
 
321
 
                //calc iterator from index
322
 
                char szLevel[30]="";
323
 
                snprintf(szLevel, sizeof(szLevel), "%d", nIdx);
324
 
                GtkTreePath *path1 = gtk_tree_path_new_from_string(szLevel);
325
 
                if(!path1)
326
 
                        return;
327
 
                GtkTreeIter iter;
328
 
                bool bResult;
329
 
                bResult = (FALSE != gtk_tree_model_get_iter(model, &iter, path1));
330
 
                gtk_tree_path_free(path1);
331
 
                if(!bResult) return;
332
 
                ASSERT(bResult);
333
 
 
334
 
                gtk_list_store_set ((GtkListStore *)model, &iter, 1, m_list[j].GetDisplayString().c_str(), -1);
 
345
                if(nPos >= 0)
 
346
                {
 
347
                        int nIdx = nPos - nStart;
 
348
 
 
349
                        //calc iterator from index
 
350
                        char szLevel[30]="";
 
351
                        snprintf(szLevel, sizeof(szLevel), "%d", nIdx);
 
352
                        GtkTreePath *path1 = gtk_tree_path_new_from_string(szLevel);
 
353
                        if(!path1)
 
354
                                return;
 
355
                        GtkTreeIter iter;
 
356
                        bool bResult;
 
357
                        bResult = (FALSE != gtk_tree_model_get_iter(model, &iter, path1));
 
358
                        gtk_tree_path_free(path1);
 
359
                        if(!bResult) return;
 
360
                        ASSERT(bResult);
 
361
 
 
362
                        gtk_list_store_set ((GtkListStore *)model, &iter, 1, m_list[j].GetDisplayString().c_str(), -1);
 
363
                }
335
364
        }
336
365
}
337
366
 
363
392
        bool bCtrl  = ( event->state & GDK_CONTROL_MASK ) ? true : false;
364
393
        bool bShift = ( event->state & GDK_SHIFT_MASK ) ? true : false;
365
394
 
 
395
        // allow navigation with UP/DOWN/HOME/END keys
 
396
        if(!bAlt && !bCtrl && !bShift && (event->keyval == GDK_Up || event->keyval == GDK_Down || event->keyval == GDK_Home || event->keyval == GDK_End))
 
397
                return FALSE;
 
398
 
366
399
        ShortcutDef def;
367
400
        def.m_bModShift = bShift;
368
401
        def.m_bModCtrl  = bCtrl;
380
413
        gtk_dialog_response(GTK_DIALOG(pDlg->m_pDialog), GTK_RESPONSE_OK);
381
414
}
382
415
 
 
416
void on_cancel_clicked (GtkButton *button, gpointer user_data)
 
417
{
 
418
        ShortcutsListDlg *pDlg = (ShortcutsListDlg *)user_data;
 
419
        gtk_dialog_response(GTK_DIALOG(pDlg->m_pDialog), GTK_RESPONSE_CANCEL);
 
420
}
 
421
 
383
422
void on_clear_all_clicked (GtkButton *button, gpointer user_data)
384
423
{
385
424
        ShortcutsListDlg *pDlg = (ShortcutsListDlg *)user_data;