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

« back to all changes in this revision

Viewing changes to src/FileExportDlg.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 <algorithm>
18
18
#include "mru.h"
 
19
#include "lib/FilePath.h"
19
20
 
20
21
extern GtkWidget *window1;
21
22
extern IniFile g_objIni;
26
27
static void on_save_clicked(GtkButton *button, gpointer user_data);
27
28
static void on_format_combo_selected (GtkComboBox *widget, gpointer user_data);
28
29
static void on_use_custom_css (GtkMenuItem *menuitem, gpointer user_data);
 
30
static void on_use_post_export (GtkMenuItem *menuitem, gpointer user_data);
 
31
 
 
32
typedef struct {
 
33
        std::string strTitle;
 
34
        std::string strPath;
 
35
} tScriptInfo;
 
36
 
 
37
static std::vector<tScriptInfo> g_lstExportScripts;
29
38
 
30
39
FileExportDlg::FileExportDlg()
31
40
{
91
100
        //restore last used export file name
92
101
        std::string strFile;
93
102
        g_objIni.GetValue("Export", "TargetFile", strFile, "");
94
 
        if(!strFile.empty())
95
 
        {
96
 
                GtkWidget *entry5 = lookup_widget(m_pDialog, "entry5");
97
 
                gtk_entry_set_text(GTK_ENTRY(entry5), strFile.c_str());
 
103
        if(strFile.empty())
 
104
        {
 
105
                //default export directory/name
 
106
                strFile = GetHomeDir();
 
107
                #ifdef _NOKIA_MAEMO
 
108
                        //Maemo file selector is not easy to use, by default set correct document directory
 
109
                        EnsureTerminated(strFile, '/');
 
110
                        strFile += "MyDocs/.documents/";
 
111
                #endif
 
112
                strFile += "default.ncd";
 
113
        }
 
114
        GtkWidget *entry5 = lookup_widget(m_pDialog, "entry5");
 
115
        gtk_entry_set_text(GTK_ENTRY(entry5), strFile.c_str());
 
116
        ForceFormatExtension();
 
117
 
 
118
        //fill post export scripts
 
119
        g_lstExportScripts.clear();
 
120
        GtkWidget *combobox3 = lookup_widget(m_pDialog, "combobox3");
 
121
        int nNumScripts = 0;
 
122
        g_objIni.GetValue("Export", "PostExportCount", nNumScripts);
 
123
 
 
124
        for(int j=0; j<nNumScripts; j++)
 
125
        {
 
126
                tScriptInfo info;
 
127
 
 
128
                char szKey[100];
 
129
                sprintf(szKey, "PostExportTitle_%d", j+1);
 
130
                g_objIni.GetValue("Export", szKey, info.strTitle, "");
 
131
                sprintf(szKey, "PostExportScript_%d", j+1);
 
132
                g_objIni.GetValue("Export", szKey, info.strPath, "");
 
133
 
 
134
                g_lstExportScripts.push_back(info);
 
135
                gtk_combo_box_append_text (GTK_COMBO_BOX (combobox3), info.strTitle.c_str());
 
136
        }
 
137
        if(nNumScripts < 1)
 
138
        {
 
139
                GtkWidget *checkbox3 = lookup_widget(m_pDialog, "checkbox3");
 
140
                gtk_widget_hide(checkbox3);
 
141
                gtk_widget_hide(combobox3);
 
142
        }
 
143
        else{
 
144
                gtk_combo_box_set_active (GTK_COMBO_BOX (combobox3), 0);
 
145
                on_use_post_export (NULL, this);
98
146
        }
99
147
}
100
148
 
178
226
        return  gtk_entry_get_text(GTK_ENTRY(entry5));
179
227
}
180
228
 
 
229
const char *FileExportDlg::GetPostExportScript()
 
230
{
 
231
        GtkWidget *checkbox3 = lookup_widget(m_pDialog, "checkbox3");
 
232
        if(gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(checkbox3)))
 
233
        {
 
234
                GtkWidget *combobox3 = lookup_widget(m_pDialog, "combobox3");
 
235
                int nIdx = gtk_combo_box_get_active (GTK_COMBO_BOX (combobox3));
 
236
                if(nIdx >= 0)
 
237
                        return g_lstExportScripts[nIdx].strPath.c_str();
 
238
        }
 
239
        return "";
 
240
}
 
241
 
181
242
bool FileExportDlg::GetHtmlExportCSS(std::string &strCSS)
182
243
{
183
244
        if(3 != GetExportFormat())
214
275
        GtkWidget *checkbox1;
215
276
        GtkWidget *entry6;
216
277
        GtkWidget *checkbox2;
 
278
        GtkWidget *checkbox3;
 
279
        GtkWidget *combobox3;
217
280
        GtkWidget *dialog_action_area6;
218
281
        GtkWidget *cancelbutton6;
219
282
        GtkWidget *okbutton6;
231
294
                gtk_window_set_transient_for(GTK_WINDOW (file_export_dialog), GTK_WINDOW(parent));   //set parent
232
295
#if GTK_CHECK_VERSION(2,4,0) //new API TOFIX set proper version
233
296
        #ifndef _WIN32  //TOFIX API is buggy on Win32 (kills modal dialog state)
234
 
          gtk_window_set_keep_above(GTK_WINDOW (file_export_dialog), TRUE);
 
297
          //gtk_window_set_keep_above(GTK_WINDOW (file_export_dialog), TRUE);
235
298
        #endif
236
299
#endif
237
300
        gtk_widget_realize(file_export_dialog);
317
380
                (GtkAttachOptions) (GTK_FILL),
318
381
                (GtkAttachOptions) (GTK_FILL), 0, 0);
319
382
 
 
383
        checkbox3 = gtk_check_button_new_with_mnemonic (_("Post-export script:"));
 
384
        gtk_widget_show (checkbox3);
 
385
        gtk_table_attach (GTK_TABLE (table7), checkbox3, 0, 1, 5, 6,
 
386
                (GtkAttachOptions) (GTK_FILL),
 
387
                (GtkAttachOptions) (GTK_FILL), 0, 0);
 
388
 
 
389
        combobox3 = gtk_combo_box_new_text ();
 
390
        gtk_widget_show (combobox3);
 
391
        gtk_table_attach (GTK_TABLE (table7), combobox3, 1, 2, 5, 6,
 
392
                (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
 
393
                (GtkAttachOptions) (GTK_FILL), 0, 0);
 
394
 
320
395
        dialog_action_area6 = GTK_DIALOG (file_export_dialog)->action_area;
321
396
        gtk_widget_show (dialog_action_area6);
322
397
        gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area6), GTK_BUTTONBOX_END);
335
410
        g_signal_connect(okbutton6, "clicked", G_CALLBACK (on_save_clicked), this);
336
411
        g_signal_connect(combobox2, "changed", G_CALLBACK (on_format_combo_selected), this);
337
412
        g_signal_connect(checkbox1, "clicked", G_CALLBACK (on_use_custom_css), this);
 
413
        g_signal_connect(checkbox3, "clicked", G_CALLBACK (on_use_post_export), this);
338
414
 
339
415
        /* Store pointers to all widgets, for use by lookup_widget(). */
340
416
        GLADE_HOOKUP_OBJECT_NO_REF (file_export_dialog, file_export_dialog, "file_export_dialog");
351
427
        GLADE_HOOKUP_OBJECT (file_export_dialog, image2, "image2");
352
428
        GLADE_HOOKUP_OBJECT (file_export_dialog, checkbox1, "checkbox1");
353
429
        GLADE_HOOKUP_OBJECT (file_export_dialog, checkbox2, "checkbox2");
 
430
        GLADE_HOOKUP_OBJECT (file_export_dialog, checkbox3, "checkbox3");
 
431
        GLADE_HOOKUP_OBJECT (file_export_dialog, combobox3, "combobox3");
354
432
        GLADE_HOOKUP_OBJECT (file_export_dialog, entry6, "entry6");
355
433
        GLADE_HOOKUP_OBJECT (file_export_dialog, hbox4, "hbox4");
356
434
        GLADE_HOOKUP_OBJECT_NO_REF (file_export_dialog, dialog_action_area6, "dialog_action_area6");
457
535
                gtk_widget_set_sensitive(entry6, FALSE);
458
536
}
459
537
 
 
538
void on_use_post_export (GtkMenuItem *menuitem, gpointer user_data)
 
539
{
 
540
        FileExportDlg *pDlg = (FileExportDlg *)user_data;
 
541
 
 
542
        GtkWidget *checkbox3 = lookup_widget(pDlg->m_pDialog, "checkbox3");
 
543
        GtkWidget *combobox3 = lookup_widget(pDlg->m_pDialog, "combobox3");
 
544
 
 
545
        if(gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(checkbox3)))
 
546
                gtk_widget_set_sensitive(combobox3, TRUE);
 
547
        else
 
548
                gtk_widget_set_sensitive(combobox3, FALSE);
 
549
}