summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx76
-rw-r--r--vcl/unx/gtk/fpicker/SalGtkFilePicker.hxx1
-rw-r--r--vcl/unx/gtk/fpicker/SalGtkFolderPicker.cxx16
-rw-r--r--vcl/unx/gtk/fpicker/SalGtkPicker.cxx8
4 files changed, 45 insertions, 56 deletions
diff --git a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
index 7ffcb69b22c3..fb88175d8e00 100644
--- a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
+++ b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
@@ -59,8 +59,6 @@
#include "gtk/fpicker/resourceprovider.hxx"
#include "gtk/fpicker/SalGtkFilePicker.hxx"
-#if !GTK_CHECK_VERSION(3,0,0)
-
//------------------------------------------------------------------------
// namespace directives
//------------------------------------------------------------------------
@@ -211,7 +209,14 @@ SalGtkFilePicker::SalGtkFilePicker( const uno::Reference< uno::XComponentContext
m_pAligns[i] = gtk_alignment_new(0, 0, 0, 1);
- m_pLists[i] = gtk_combo_box_new_text();
+ m_pListStores[i] = gtk_list_store_new (1, G_TYPE_STRING);
+ m_pLists[i] = gtk_combo_box_new_with_model(GTK_TREE_MODEL(m_pListStores[i]));
+ g_object_unref (m_pListStores[i]); // owned by the widget.
+ GtkCellRenderer *pCell = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start(
+ GTK_CELL_LAYOUT(m_pLists[i]), pCell, TRUE);
+ gtk_cell_layout_set_attributes(
+ GTK_CELL_LAYOUT (m_pLists[i]), pCell, "text", 0, NULL);
m_pListLabels[i] = gtk_label_new( "" );
@@ -497,8 +502,16 @@ dialog_remove_buttons( GtkDialog *pDialog )
{
g_return_if_fail( GTK_IS_DIALOG( pDialog ) );
+ GtkWidget *pActionArea;
+
+#if GTK_CHECK_VERSION(3,0,0)
+ pActionArea = gtk_dialog_get_action_area( pDialog );
+#else
+ pActionArea = pDialog->action_area;
+#endif
+
GList *pChildren =
- gtk_container_get_children( GTK_CONTAINER( pDialog->action_area ) );
+ gtk_container_get_children( GTK_CONTAINER( pActionArea ) );
for( GList *p = pChildren; p; p = p->next )
gtk_widget_destroy( GTK_WIDGET( p->data ) );
@@ -1136,14 +1149,20 @@ GtkWidget *SalGtkFilePicker::getWidget( sal_Int16 nControlId, GType *pType )
//------------------------------------------------------------------------------------
// XFilePickerControlAccess functions
//------------------------------------------------------------------------------------
-namespace
+static void HackWidthToFirst(GtkComboBox *pWidget)
{
- void HackWidthToFirst(GtkComboBox *pWidget)
- {
- GtkRequisition requisition;
- gtk_widget_size_request(GTK_WIDGET(pWidget), &requisition);
- gtk_widget_set_size_request(GTK_WIDGET(pWidget), requisition.width, -1);
- }
+ GtkRequisition requisition;
+ gtk_widget_size_request(GTK_WIDGET(pWidget), &requisition);
+ gtk_widget_set_size_request(GTK_WIDGET(pWidget), requisition.width, -1);
+}
+
+static void ComboBoxAppendText(GtkComboBox *pCombo, const rtl::OUString &rStr)
+{
+ GtkTreeIter aIter;
+ GtkListStore *pStore = GTK_LIST_STORE(gtk_combo_box_get_model(pCombo));
+ rtl::OString aStr = rtl::OUStringToOString(rStr, RTL_TEXTENCODING_UTF8);
+ gtk_list_store_append(pStore, &aIter);
+ gtk_list_store_set(pStore, &aIter, 0, aStr.getStr(), -1);
}
void SalGtkFilePicker::HandleSetListValue(GtkComboBox *pWidget, sal_Int16 nControlAction, const uno::Any& rValue)
@@ -1154,7 +1173,7 @@ void SalGtkFilePicker::HandleSetListValue(GtkComboBox *pWidget, sal_Int16 nContr
{
OUString sItem;
rValue >>= sItem;
- gtk_combo_box_append_text(pWidget, rtl::OUStringToOString(sItem, RTL_TEXTENCODING_UTF8).getStr());
+ ComboBoxAppendText(pWidget, sItem);
if (!bVersionWidthUnset)
{
HackWidthToFirst(pWidget);
@@ -1169,8 +1188,7 @@ void SalGtkFilePicker::HandleSetListValue(GtkComboBox *pWidget, sal_Int16 nContr
sal_Int32 nItemCount = aStringList.getLength();
for (sal_Int32 i = 0; i < nItemCount; ++i)
{
- gtk_combo_box_append_text(pWidget,
- rtl::OUStringToOString(aStringList[i], RTL_TEXTENCODING_UTF8).getStr());
+ ComboBoxAppendText(pWidget,aStringList[i]);
if (!bVersionWidthUnset)
{
HackWidthToFirst(pWidget);
@@ -1183,22 +1201,20 @@ void SalGtkFilePicker::HandleSetListValue(GtkComboBox *pWidget, sal_Int16 nContr
{
sal_Int32 nPos=0;
rValue >>= nPos;
- gtk_combo_box_remove_text(pWidget, nPos);
+
+ GtkTreeIter aIter;
+ GtkListStore *pStore = GTK_LIST_STORE(
+ gtk_combo_box_get_model(GTK_COMBO_BOX(pWidget)));
+ if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(pStore), &aIter, NULL, nPos))
+ gtk_list_store_remove(pStore, &aIter);
}
break;
case ControlActions::DELETE_ITEMS:
{
gtk_combo_box_set_active(pWidget, -1);
- gint nItems = 0;
- do
- {
- nItems =
- gtk_tree_model_iter_n_children(
- gtk_combo_box_get_model(pWidget), NULL);
- for (gint nI = 0; nI < nItems; ++nI)
- gtk_combo_box_remove_text(pWidget, nI);
- }
- while (nItems);
+ GtkListStore *pStore = GTK_LIST_STORE(
+ gtk_combo_box_get_model(GTK_COMBO_BOX(pWidget)));
+ gtk_list_store_clear(pStore);
}
break;
case ControlActions::SET_SELECT_ITEM:
@@ -1587,7 +1603,7 @@ sal_Bool SAL_CALL SalGtkFilePicker::setShowState( sal_Bool bShowState ) throw( u
}
// also emit the signal
- g_signal_emit_by_name( GTK_OBJECT( m_pDialog ), "update-preview" );
+ g_signal_emit_by_name( G_OBJECT( m_pDialog ), "update-preview" );
mbPreviewState = bShowState;
}
@@ -2018,23 +2034,15 @@ SalGtkFilePicker::~SalGtkFilePicker()
gtk_widget_destroy( m_pVBox );
}
-#endif
-
using namespace ::com::sun::star;
uno::Reference< ui::dialogs::XFilePicker2 >
GtkInstance::createFilePicker( const com::sun::star::uno::Reference<
com::sun::star::uno::XComponentContext > &xMSF )
{
-#if GTK_CHECK_VERSION(3,0,0)
- fprintf( stderr, "Create dummy gtk file picker\n" );
- (void)xMSF;
- return uno::Reference< ui::dialogs::XFilePicker2 >();
-#else
fprintf( stderr, "Create gtk file picker\n" );
return uno::Reference< ui::dialogs::XFilePicker2 >(
new SalGtkFilePicker( xMSF ) );
-#endif
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk/fpicker/SalGtkFilePicker.hxx b/vcl/unx/gtk/fpicker/SalGtkFilePicker.hxx
index aadff65a52cd..8d39e42fde82 100644
--- a/vcl/unx/gtk/fpicker/SalGtkFilePicker.hxx
+++ b/vcl/unx/gtk/fpicker/SalGtkFilePicker.hxx
@@ -280,6 +280,7 @@ class SalGtkFilePicker :
GtkWidget *m_pHBoxs[ LIST_LAST ];
GtkWidget *m_pAligns[ LIST_LAST ];
GtkWidget *m_pLists[ LIST_LAST ];
+ GtkListStore *m_pListStores[ LIST_LAST ];
GtkWidget *m_pListLabels[ LIST_LAST ];
bool mbListVisibility[ LIST_LAST ];
bool mbButtonVisibility[ BUTTON_LAST ];
diff --git a/vcl/unx/gtk/fpicker/SalGtkFolderPicker.cxx b/vcl/unx/gtk/fpicker/SalGtkFolderPicker.cxx
index 07b6bb2abd29..f4e2476cedd6 100644
--- a/vcl/unx/gtk/fpicker/SalGtkFolderPicker.cxx
+++ b/vcl/unx/gtk/fpicker/SalGtkFolderPicker.cxx
@@ -50,19 +50,12 @@
#include <string.h>
-
-//------------------------------------------------------------------------
-// namespace directives
-//------------------------------------------------------------------------
-
using namespace ::rtl;
using namespace ::com::sun::star;
using namespace ::com::sun::star::ui::dialogs;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;
-#if !GTK_CHECK_VERSION(3,0,0)
-
//-----------------------------------------------------------------------------------------
// constructor
//-----------------------------------------------------------------------------------------
@@ -133,8 +126,6 @@ void SAL_CALL SalGtkFolderPicker::setDescription( const rtl::OUString& rDescript
::rtl::OString aDescription = OUStringToOString( rDescription, RTL_TEXTENCODING_UTF8 );
}
-
-
//-----------------------------------------------------------------------------------------
// XExecutableDialog functions
//-----------------------------------------------------------------------------------------
@@ -186,7 +177,6 @@ sal_Int16 SAL_CALL SalGtkFolderPicker::execute() throw( uno::RuntimeException )
return retVal;
}
-
//------------------------------------------------------------------------------------
// XCancellable
//------------------------------------------------------------------------------------
@@ -199,19 +189,13 @@ void SAL_CALL SalGtkFolderPicker::cancel() throw( uno::RuntimeException )
// TODO m_pImpl->cancel();
}
-#endif
uno::Reference< ui::dialogs::XFolderPicker >
GtkInstance::createFolderPicker( const uno::Reference< uno::XComponentContext > &xMSF )
{
fprintf( stderr, "Create gtk folder picker\n" );
-#if GTK_CHECK_VERSION(3,0,0)
- (void)xMSF;
- return uno::Reference< ui::dialogs::XFolderPicker >();
-#else
return uno::Reference< ui::dialogs::XFolderPicker >(
new SalGtkFolderPicker( xMSF ) );
-#endif
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk/fpicker/SalGtkPicker.cxx b/vcl/unx/gtk/fpicker/SalGtkPicker.cxx
index 0520f2a823bc..7146b99f6b20 100644
--- a/vcl/unx/gtk/fpicker/SalGtkPicker.cxx
+++ b/vcl/unx/gtk/fpicker/SalGtkPicker.cxx
@@ -66,8 +66,6 @@ using namespace ::com::sun::star;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;
-#if !GTK_CHECK_VERSION(3,0,0)
-
rtl::OUString SalGtkPicker::uritounicode(const gchar* pIn)
{
if (!pIn)
@@ -92,7 +90,7 @@ rtl::OUString SalGtkPicker::uritounicode(const gchar* pIn)
}
else
{
- OUString aNewURL = Reference<uri::XExternalUriReferenceTranslator>(Reference<XMultiComponentFactory>(comphelper::getProcessServiceFactory(), UNO_QUERY_THROW)->createInstanceWithContext(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uri.ExternalUriReferenceTranslator")), m_xContext), UNO_QUERY_THROW)->translateToInternal(sURL);
+ OUString aNewURL = uno::Reference<uri::XExternalUriReferenceTranslator>(uno::Reference<XMultiComponentFactory>(comphelper::getProcessServiceFactory(), UNO_QUERY_THROW)->createInstanceWithContext(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uri.ExternalUriReferenceTranslator")), m_xContext), UNO_QUERY_THROW)->translateToInternal(sURL);
if( aNewURL.getLength() )
sURL = aNewURL;
}
@@ -108,7 +106,7 @@ rtl::OString SalGtkPicker::unicodetouri(const rtl::OUString &rURL)
INetURLObject aURL(rURL);
if (INET_PROT_FILE == aURL.GetProtocol())
{
- OUString aNewURL = Reference<uri::XExternalUriReferenceTranslator>(Reference<XMultiComponentFactory>(comphelper::getProcessServiceFactory(), UNO_QUERY_THROW)->createInstanceWithContext(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uri.ExternalUriReferenceTranslator")), m_xContext ), UNO_QUERY_THROW)->translateToExternal( rURL );
+ OUString aNewURL = uno::Reference<uri::XExternalUriReferenceTranslator>(uno::Reference<XMultiComponentFactory>(comphelper::getProcessServiceFactory(), UNO_QUERY_THROW)->createInstanceWithContext(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uri.ExternalUriReferenceTranslator")), m_xContext ), UNO_QUERY_THROW)->translateToExternal( rURL );
if( aNewURL.getLength() )
{
@@ -290,6 +288,4 @@ uno::Reference< uno::XInterface > SalGtkPicker::createInstance( const rtl::OUStr
return m_xContext->getServiceManager()->createInstanceWithContext( rName, m_xContext );
}
-#endif
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */