Debian Codegraph @

src/af/xap/gtk/xap_UnixDlg_DocComparison.cpp

raw
1 /* AbiWord
2 * Copyright (C) 2000 AbiSource, Inc.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301 USA.
18 */
19
20 #include <stdlib.h>
21 #include <time.h>
22 #include <stdio.h>
23 #include "ut_string.h"
24 #include "xap_UnixDialogHelper.h"
25 #include "ut_string.h"
26 #include "ut_assert.h"
27 #include "ut_debugmsg.h"
28
29 // This header defines some functions for Unix dialogs,
30 // like centering them, measuring them, etc.
31 #include "xap_UnixDialogHelper.h"
32
33 #include "xap_App.h"
34 #include "xap_UnixApp.h"
35 #include "xap_Frame.h"
36 #include "xap_Dialog.h"
37 #include "xap_Strings.h"
38 #include "xap_Dialog_Id.h"
39 #include "xap_UnixDlg_DocComparison.h"
40 #include "xap_UnixDialogFactory.h"
41
42 /*****************************************************************/
43
44
45 XAP_Dialog * XAP_UnixDialog_DocComparison::static_constructor(XAP_DialogFactory * pFactory, XAP_Dialog_Id id)
46 {
47 XAP_UnixDialog_DocComparison * p = new XAP_UnixDialog_DocComparison(pFactory,id);
48 return p;
49 }
50
51 XAP_UnixDialog_DocComparison::XAP_UnixDialog_DocComparison(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id)
52 : XAP_Dialog_DocComparison(pDlgFactory,id),
53 m_windowMain(NULL)
54 {
55 }
56
57
58 XAP_UnixDialog_DocComparison::~XAP_UnixDialog_DocComparison(void)
59 {
60 }
61
62 void XAP_UnixDialog_DocComparison::runModal(XAP_Frame * pFrame)
63 {
64 UT_ASSERT(pFrame);
65 // build the dialog
66 GtkWidget * cf = constructWindow();
67 UT_return_if_fail(cf);
68
69 abiRunModalDialog ( GTK_DIALOG(cf), pFrame, this, GTK_RESPONSE_CLOSE,false );
70 abiDestroyWidget(cf);
71 }
72
73 GtkWidget * XAP_UnixDialog_DocComparison::constructWindow(void)
74 {
75 const XAP_StringSet * pSS = m_pApp->getStringSet();
76
77 // load the dialog from the UI file
78 #if GTK_CHECK_VERSION(3,0,0)
79 GtkBuilder* builder = newDialogBuilder("xap_UnixDlg_DocComparison.ui");
80 #else
81 GtkBuilder* builder = newDialogBuilder("xap_UnixDlg_DocComparison-2.ui");
82 #endif
83 // Update our member variables with the important widgets that
84 // might need to be queried or altered later
85 m_windowMain = GTK_WIDGET(gtk_builder_get_object(builder, "xap_UnixDlg_DocComparison"));
86 std::string s;
87 pSS->getValueUTF8(XAP_STRING_ID_DLG_DocComparison_WindowLabel,s);
88 gtk_window_set_title (GTK_WINDOW(m_windowMain), s.c_str());
89
90 _populateWindowData(builder);
91
92 g_object_unref(G_OBJECT(builder));
93
94 return m_windowMain;
95 }
96
97
98 void XAP_UnixDialog_DocComparison::_populateWindowData(GtkBuilder* builder)
99 {
100 const XAP_StringSet * pSS = m_pApp->getStringSet();
101 std::string text;
102 localizeLabelMarkup (GTK_WIDGET(gtk_builder_get_object(builder, "lbDocCompared")), pSS, XAP_STRING_ID_DLG_DocComparison_DocsCompared);
103 gtk_label_set_text (GTK_LABEL(gtk_builder_get_object(builder, "lbDocument1")), getPath1());
104 gtk_label_set_text (GTK_LABEL(gtk_builder_get_object(builder, "lbDocument2")), getPath2());
105 localizeLabelMarkup (GTK_WIDGET(gtk_builder_get_object(builder, "lbResults")), pSS, XAP_STRING_ID_DLG_DocComparison_Results);
106 pSS->getValueUTF8(XAP_STRING_ID_DLG_DocComparison_Relationship, text);
107 gtk_label_set_text (GTK_LABEL(gtk_builder_get_object(builder, "lbRelationship")), text.c_str());
108 gtk_label_set_text (GTK_LABEL(gtk_builder_get_object(builder, "lbRelationshipRes")), getResultValue(0));
109 pSS->getValueUTF8(XAP_STRING_ID_DLG_DocComparison_Content, text);
110 gtk_label_set_text (GTK_LABEL(gtk_builder_get_object(builder, "lbContent")), text.c_str());
111 gtk_label_set_text (GTK_LABEL(gtk_builder_get_object(builder, "lbContentRes")), getResultValue(1));
112 pSS->getValueUTF8(XAP_STRING_ID_DLG_DocComparison_Fmt, text);
113 gtk_label_set_text (GTK_LABEL(gtk_builder_get_object(builder, "lbFormat")), text.c_str());
114 gtk_label_set_text (GTK_LABEL(gtk_builder_get_object(builder, "lbFormatRes")), getResultValue(2));
115 pSS->getValueUTF8(XAP_STRING_ID_DLG_DocComparison_Styles, text);
116 gtk_label_set_text (GTK_LABEL(gtk_builder_get_object(builder, "lbStyles")), text.c_str());
117 gtk_label_set_text (GTK_LABEL(gtk_builder_get_object(builder, "lbStylesRes")),getResultValue(3));
118 }