Commit 2b1b6d72 authored by Paolo Borelli's avatar Paolo Borelli

file-chooser: use G_DECLARE macros

parent 35a7f96d
......@@ -41,8 +41,10 @@
#define ALL_FILES _("All Files")
#define ALL_TEXT_FILES _("All Text Files")
struct _GeditFileChooserDialogGtkPrivate
struct _GeditFileChooserDialogGtk
{
GtkFileChooserDialog parent_instance;
GSettings *filter_settings;
GtkWidget *option_menu;
......@@ -60,33 +62,32 @@ G_DEFINE_TYPE_EXTENDED (GeditFileChooserDialogGtk,
GTK_TYPE_FILE_CHOOSER_DIALOG,
0,
G_IMPLEMENT_INTERFACE (GEDIT_TYPE_FILE_CHOOSER_DIALOG,
gedit_file_chooser_dialog_gtk_chooser_init)
G_ADD_PRIVATE (GeditFileChooserDialogGtk))
gedit_file_chooser_dialog_gtk_chooser_init))
static void
chooser_set_encoding (GeditFileChooserDialog *dialog,
const GtkSourceEncoding *encoding)
{
GeditFileChooserDialogGtkPrivate *priv = GEDIT_FILE_CHOOSER_DIALOG_GTK (dialog)->priv;
GeditFileChooserDialogGtk *dialog_gtk = GEDIT_FILE_CHOOSER_DIALOG_GTK (dialog);
g_return_if_fail (GEDIT_IS_ENCODINGS_COMBO_BOX (priv->option_menu));
g_return_if_fail (GEDIT_IS_ENCODINGS_COMBO_BOX (dialog_gtk->option_menu));
gedit_encodings_combo_box_set_selected_encoding (GEDIT_ENCODINGS_COMBO_BOX (priv->option_menu),
gedit_encodings_combo_box_set_selected_encoding (GEDIT_ENCODINGS_COMBO_BOX (dialog_gtk->option_menu),
encoding);
}
static const GtkSourceEncoding *
chooser_get_encoding (GeditFileChooserDialog *dialog)
{
GeditFileChooserDialogGtkPrivate *priv = GEDIT_FILE_CHOOSER_DIALOG_GTK (dialog)->priv;
GeditFileChooserDialogGtk *dialog_gtk = GEDIT_FILE_CHOOSER_DIALOG_GTK (dialog);
g_return_val_if_fail (GEDIT_IS_ENCODINGS_COMBO_BOX (priv->option_menu), NULL);
g_return_val_if_fail (GEDIT_IS_ENCODINGS_COMBO_BOX (dialog_gtk->option_menu), NULL);
g_return_val_if_fail ((gtk_file_chooser_get_action (GTK_FILE_CHOOSER (dialog)) == GTK_FILE_CHOOSER_ACTION_OPEN ||
gtk_file_chooser_get_action (GTK_FILE_CHOOSER (dialog)) == GTK_FILE_CHOOSER_ACTION_SAVE), NULL);
return gedit_encodings_combo_box_get_selected_encoding (
GEDIT_ENCODINGS_COMBO_BOX (priv->option_menu));
GEDIT_ENCODINGS_COMBO_BOX (dialog_gtk->option_menu));
}
static void
......@@ -121,27 +122,27 @@ static void
chooser_set_newline_type (GeditFileChooserDialog *dialog,
GtkSourceNewlineType newline_type)
{
GeditFileChooserDialogGtkPrivate *priv = GEDIT_FILE_CHOOSER_DIALOG_GTK (dialog)->priv;
GeditFileChooserDialogGtk *dialog_gtk = GEDIT_FILE_CHOOSER_DIALOG_GTK (dialog);
g_return_if_fail (gtk_file_chooser_get_action (GTK_FILE_CHOOSER (dialog)) == GTK_FILE_CHOOSER_ACTION_SAVE);
set_enum_combo (GTK_COMBO_BOX (priv->newline_combo), newline_type);
set_enum_combo (GTK_COMBO_BOX (dialog_gtk->newline_combo), newline_type);
}
static GtkSourceNewlineType
chooser_get_newline_type (GeditFileChooserDialog *dialog)
{
GeditFileChooserDialogGtkPrivate *priv = GEDIT_FILE_CHOOSER_DIALOG_GTK (dialog)->priv;
GeditFileChooserDialogGtk *dialog_gtk = GEDIT_FILE_CHOOSER_DIALOG_GTK (dialog);
GtkTreeIter iter;
GtkSourceNewlineType newline_type;
g_return_val_if_fail (gtk_file_chooser_get_action (GTK_FILE_CHOOSER (dialog)) == GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_SOURCE_NEWLINE_TYPE_DEFAULT);
gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->newline_combo),
gtk_combo_box_get_active_iter (GTK_COMBO_BOX (dialog_gtk->newline_combo),
&iter);
gtk_tree_model_get (GTK_TREE_MODEL (priv->newline_store),
gtk_tree_model_get (GTK_TREE_MODEL (dialog_gtk->newline_store),
&iter,
1,
&newline_type,
......@@ -280,9 +281,9 @@ gedit_file_chooser_dialog_gtk_chooser_init (gpointer g_iface,
static void
gedit_file_chooser_dialog_gtk_dispose (GObject *object)
{
GeditFileChooserDialogGtk *dialog = GEDIT_FILE_CHOOSER_DIALOG_GTK (object);
GeditFileChooserDialogGtk *dialog_gtk = GEDIT_FILE_CHOOSER_DIALOG_GTK (object);
g_clear_object (&dialog->priv->filter_settings);
g_clear_object (&dialog_gtk->filter_settings);
G_OBJECT_CLASS (gedit_file_chooser_dialog_gtk_parent_class)->dispose (object);
}
......@@ -311,13 +312,13 @@ create_option_menu (GeditFileChooserDialogGtk *dialog,
gtk_label_set_mnemonic_widget (GTK_LABEL (label), menu);
gtk_box_pack_start (GTK_BOX (dialog->priv->extra_widget),
gtk_box_pack_start (GTK_BOX (dialog->extra_widget),
label,
FALSE,
TRUE,
0);
gtk_box_pack_start (GTK_BOX (dialog->priv->extra_widget),
gtk_box_pack_start (GTK_BOX (dialog->extra_widget),
menu,
TRUE,
TRUE,
......@@ -326,7 +327,7 @@ create_option_menu (GeditFileChooserDialogGtk *dialog,
gtk_widget_show (label);
gtk_widget_show (menu);
dialog->priv->option_menu = menu;
dialog->option_menu = menu;
}
static void
......@@ -334,8 +335,8 @@ update_newline_visibility (GeditFileChooserDialogGtk *dialog)
{
gboolean visible = gtk_file_chooser_get_action (GTK_FILE_CHOOSER (dialog)) == GTK_FILE_CHOOSER_ACTION_SAVE;
gtk_widget_set_visible (dialog->priv->newline_label, visible);
gtk_widget_set_visible (dialog->priv->newline_combo, visible);
gtk_widget_set_visible (dialog->newline_label, visible);
gtk_widget_set_visible (dialog->newline_combo, visible);
}
static void
......@@ -398,21 +399,21 @@ create_newline_combo (GeditFileChooserDialogGtk *dialog)
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
gtk_box_pack_start (GTK_BOX (dialog->priv->extra_widget),
gtk_box_pack_start (GTK_BOX (dialog->extra_widget),
label,
FALSE,
TRUE,
0);
gtk_box_pack_start (GTK_BOX (dialog->priv->extra_widget),
gtk_box_pack_start (GTK_BOX (dialog->extra_widget),
combo,
TRUE,
TRUE,
0);
dialog->priv->newline_combo = combo;
dialog->priv->newline_label = label;
dialog->priv->newline_store = store;
dialog->newline_combo = combo;
dialog->newline_label = label;
dialog->newline_store = store;
update_newline_visibility (dialog);
}
......@@ -432,9 +433,9 @@ create_extra_widget (GeditFileChooserDialogGtk *dialog,
return;
}
dialog->priv->extra_widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
dialog->extra_widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_widget_show (dialog->priv->extra_widget);
gtk_widget_show (dialog->extra_widget);
if (needs_encoding)
{
......@@ -446,8 +447,7 @@ create_extra_widget (GeditFileChooserDialogGtk *dialog,
create_newline_combo (dialog);
}
gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog),
dialog->priv->extra_widget);
gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog), dialog->extra_widget);
}
static void
......@@ -462,19 +462,19 @@ action_changed (GeditFileChooserDialogGtk *dialog,
switch (action)
{
case GTK_FILE_CHOOSER_ACTION_OPEN:
g_object_set (dialog->priv->option_menu,
"save_mode", FALSE,
NULL);
gtk_widget_show (dialog->priv->option_menu);
g_object_set (dialog->option_menu,
"save_mode", FALSE,
NULL);
gtk_widget_show (dialog->option_menu);
break;
case GTK_FILE_CHOOSER_ACTION_SAVE:
g_object_set (dialog->priv->option_menu,
"save_mode", TRUE,
NULL);
gtk_widget_show (dialog->priv->option_menu);
g_object_set (dialog->option_menu,
"save_mode", TRUE,
NULL);
gtk_widget_show (dialog->option_menu);
break;
default:
gtk_widget_hide (dialog->priv->option_menu);
gtk_widget_hide (dialog->option_menu);
}
update_newline_visibility (dialog);
......@@ -501,7 +501,7 @@ filter_changed (GeditFileChooserDialogGtk *dialog,
gedit_debug_message (DEBUG_COMMANDS, "Active filter: %s (%d)", name, id);
g_settings_set_int (dialog->priv->filter_settings,
g_settings_set_int (dialog->filter_settings,
GEDIT_SETTINGS_ACTIVE_FILE_FILTER, id);
}
}
......@@ -587,9 +587,7 @@ all_text_files_filter (const GtkFileFilterInfo *filter_info,
static void
gedit_file_chooser_dialog_gtk_init (GeditFileChooserDialogGtk *dialog)
{
dialog->priv = gedit_file_chooser_dialog_gtk_get_instance_private (dialog);
dialog->priv->filter_settings = g_settings_new ("org.gnome.gedit.state.file-filter");
dialog->filter_settings = g_settings_new ("org.gnome.gedit.state.file-filter");
}
GeditFileChooserDialog *
......@@ -602,7 +600,7 @@ gedit_file_chooser_dialog_gtk_create (const gchar *title,
const gchar *accept_label,
GtkResponseType accept_response)
{
GtkWidget *result;
GeditFileChooserDialogGtk *result;
GtkFileFilter *filter;
gint active_filter;
GtkFileChooserAction action;
......@@ -626,7 +624,7 @@ gedit_file_chooser_dialog_gtk_create (const gchar *title,
"select-multiple", select_multiple,
NULL);
create_extra_widget (GEDIT_FILE_CHOOSER_DIALOG_GTK (result), flags);
create_extra_widget (result, flags);
g_signal_connect (result,
"notify::action",
......@@ -635,13 +633,11 @@ gedit_file_chooser_dialog_gtk_create (const gchar *title,
if (encoding != NULL)
{
gedit_encodings_combo_box_set_selected_encoding (
GEDIT_ENCODINGS_COMBO_BOX (GEDIT_FILE_CHOOSER_DIALOG_GTK (result)->priv->option_menu),
encoding);
gedit_encodings_combo_box_set_selected_encoding (GEDIT_ENCODINGS_COMBO_BOX (result->option_menu),
encoding);
}
active_filter = g_settings_get_int (GEDIT_FILE_CHOOSER_DIALOG_GTK (result)->priv->filter_settings,
GEDIT_SETTINGS_ACTIVE_FILE_FILTER);
active_filter = g_settings_get_int (result->filter_settings, GEDIT_SETTINGS_ACTIVE_FILE_FILTER);
gedit_debug_message (DEBUG_COMMANDS, "Active filter: %d", active_filter);
if ((flags & GEDIT_FILE_CHOOSER_ENABLE_DEFAULT_FILTERS) != 0)
......@@ -688,8 +684,8 @@ gedit_file_chooser_dialog_gtk_create (const gchar *title,
gtk_dialog_add_button (GTK_DIALOG (result), cancel_label, cancel_response);
gtk_dialog_add_button (GTK_DIALOG (result), accept_label, accept_response);
gtk_dialog_set_default_response (GTK_DIALOG (result), accept_response);
return GEDIT_FILE_CHOOSER_DIALOG (result);
}
......
......@@ -27,30 +27,9 @@
G_BEGIN_DECLS
#define GEDIT_TYPE_FILE_CHOOSER_DIALOG_GTK (gedit_file_chooser_dialog_gtk_get_type ())
#define GEDIT_FILE_CHOOSER_DIALOG_GTK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_FILE_CHOOSER_DIALOG_GTK, GeditFileChooserDialogGtk))
#define GEDIT_FILE_CHOOSER_DIALOG_GTK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_FILE_CHOOSER_DIALOG_GTK, GeditFileChooserDialogGtkClass))
#define GEDIT_IS_FILE_CHOOSER_DIALOG_GTK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_FILE_CHOOSER_DIALOG_GTK))
#define GEDIT_IS_FILE_CHOOSER_DIALOG_GTK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_FILE_CHOOSER_DIALOG_GTK))
#define GEDIT_FILE_CHOOSER_DIALOG_GTK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEDIT_TYPE_FILE_CHOOSER_DIALOG_GTK, GeditFileChooserDialogGtkClass))
#define GEDIT_TYPE_FILE_CHOOSER_DIALOG_GTK (gedit_file_chooser_dialog_gtk_get_type ())
typedef struct _GeditFileChooserDialogGtk GeditFileChooserDialogGtk;
typedef struct _GeditFileChooserDialogGtkClass GeditFileChooserDialogGtkClass;
typedef struct _GeditFileChooserDialogGtkPrivate GeditFileChooserDialogGtkPrivate;
struct _GeditFileChooserDialogGtkClass
{
GtkFileChooserDialogClass parent_class;
};
struct _GeditFileChooserDialogGtk
{
GtkFileChooserDialog parent_instance;
GeditFileChooserDialogGtkPrivate *priv;
};
GType gedit_file_chooser_dialog_gtk_get_type (void) G_GNUC_CONST;
G_DECLARE_FINAL_TYPE (GeditFileChooserDialogGtk, gedit_file_chooser_dialog_gtk, GEDIT, FILE_CHOOSER_DIALOG_GTK, GtkFileChooserDialog)
GeditFileChooserDialog *gedit_file_chooser_dialog_gtk_create (const gchar *title,
GtkWindow *parent,
......
......@@ -32,8 +32,10 @@
#include "gedit-encodings-dialog.h"
#include "gedit-utils.h"
struct _GeditFileChooserDialogOSXPrivate
struct _GeditFileChooserDialogOSX
{
GObject parent_instance;
/* Note this can be either an NSSavePanel or NSOpenPanel,
* and NSOpenPanel inherits from NSSavePanel. */
NSSavePanel *panel;
......@@ -60,8 +62,7 @@ G_DEFINE_TYPE_EXTENDED (GeditFileChooserDialogOSX,
G_TYPE_OBJECT,
0,
G_IMPLEMENT_INTERFACE (GEDIT_TYPE_FILE_CHOOSER_DIALOG,
gedit_file_chooser_dialog_osx_chooser_init)
G_ADD_PRIVATE (GeditFileChooserDialogOSX))
gedit_file_chooser_dialog_osx_chooser_init))
@interface NewlineItem : NSMenuItem
......@@ -141,15 +142,15 @@ static void
chooser_set_encoding (GeditFileChooserDialog *dialog,
const GtkSourceEncoding *encoding)
{
GeditFileChooserDialogOSXPrivate *priv = GEDIT_FILE_CHOOSER_DIALOG_OSX (dialog)->priv;
GeditFileChooserDialogOSX *dialog_osx = GEDIT_FILE_CHOOSER_DIALOG_OSX (dialog);
gint i;
if (priv->encoding_button == NULL)
if (dialog_osx->encoding_button == NULL)
{
return;
}
NSMenu *menu = [priv->encoding_button menu];
NSMenu *menu = [dialog_osx->encoding_button menu];
NSArray *items = [menu itemArray];
for (i = 0; i < [items count]; i++)
......@@ -162,7 +163,7 @@ chooser_set_encoding (GeditFileChooserDialog *dialog,
if ([eitem source_encoding] == encoding)
{
[priv->encoding_button selectItemAtIndex:i];
[dialog_osx->encoding_button selectItemAtIndex:i];
break;
}
}
......@@ -172,15 +173,15 @@ chooser_set_encoding (GeditFileChooserDialog *dialog,
static const GtkSourceEncoding *
chooser_get_encoding (GeditFileChooserDialog *dialog)
{
GeditFileChooserDialogOSXPrivate *priv = GEDIT_FILE_CHOOSER_DIALOG_OSX (dialog)->priv;
GeditFileChooserDialogOSX *dialog_osx = GEDIT_FILE_CHOOSER_DIALOG_OSX (dialog);
NSMenuItem *item;
if (priv->encoding_button == NULL)
if (dialog_osx->encoding_button == NULL)
{
return gtk_source_encoding_get_utf8 ();
}
item = [priv->encoding_button selectedItem];
item = [dialog_osx->encoding_button selectedItem];
if (item != nil && [item isKindOfClass:[EncodingItem class]])
{
......@@ -194,15 +195,15 @@ static void
chooser_set_newline_type (GeditFileChooserDialog *dialog,
GtkSourceNewlineType newline_type)
{
GeditFileChooserDialogOSXPrivate *priv = GEDIT_FILE_CHOOSER_DIALOG_OSX (dialog)->priv;
GeditFileChooserDialogOSX *dialog_osx = GEDIT_FILE_CHOOSER_DIALOG_OSX (dialog);
gint i;
if (priv->newline_button == NULL)
if (dialog_osx->newline_button == NULL)
{
return;
}
NSMenu *menu = [priv->newline_button menu];
NSMenu *menu = [dialog_osx->newline_button menu];
NSArray *items = [menu itemArray];
for (i = 0; i < [items count]; i++)
......@@ -211,7 +212,7 @@ chooser_set_newline_type (GeditFileChooserDialog *dialog,
if (item.newline_type == newline_type)
{
[priv->newline_button selectItemAtIndex:i];
[dialog_osx->newline_button selectItemAtIndex:i];
break;
}
}
......@@ -220,14 +221,14 @@ chooser_set_newline_type (GeditFileChooserDialog *dialog,
static GtkSourceNewlineType
chooser_get_newline_type (GeditFileChooserDialog *dialog)
{
GeditFileChooserDialogOSXPrivate *priv = GEDIT_FILE_CHOOSER_DIALOG_OSX (dialog)->priv;
GeditFileChooserDialogOSX *dialog_osx = GEDIT_FILE_CHOOSER_DIALOG_OSX (dialog);
if (priv->newline_button == NULL)
if (dialog_osx->newline_button == NULL)
{
return GTK_SOURCE_NEWLINE_TYPE_DEFAULT;
}
NewlineItem *item = (NewlineItem *)[priv->newline_button selectedItem];
NewlineItem *item = (NewlineItem *)[dialog_osx->newline_button selectedItem];
return item.newline_type;
}
......@@ -235,14 +236,14 @@ static void
chooser_set_current_folder (GeditFileChooserDialog *dialog,
GFile *folder)
{
GeditFileChooserDialogOSXPrivate *priv = GEDIT_FILE_CHOOSER_DIALOG_OSX (dialog)->priv;
GeditFileChooserDialogOSX *dialog_osx = GEDIT_FILE_CHOOSER_DIALOG_OSX (dialog);
if (folder != NULL)
{
gchar *uri;
uri = g_file_get_uri (folder);
[priv->panel setDirectoryURL:[NSURL URLWithString:[NSString stringWithUTF8String:uri]]];
[dialog_osx->panel setDirectoryURL:[NSURL URLWithString:[NSString stringWithUTF8String:uri]]];
g_free (uri);
}
}
......@@ -251,9 +252,9 @@ static void
chooser_set_current_name (GeditFileChooserDialog *dialog,
const gchar *name)
{
GeditFileChooserDialogOSXPrivate *priv = GEDIT_FILE_CHOOSER_DIALOG_OSX (dialog)->priv;
GeditFileChooserDialogOSX *dialog_osx = GEDIT_FILE_CHOOSER_DIALOG_OSX (dialog);
[priv->panel setNameFieldStringValue:[NSString stringWithUTF8String:name]];
[dialog_osx->panel setNameFieldStringValue:[NSString stringWithUTF8String:name]];
}
static void
......@@ -294,9 +295,9 @@ ns_url_to_g_file (NSURL *url)
static GFile *
chooser_get_file (GeditFileChooserDialog *dialog)
{
GeditFileChooserDialogOSXPrivate *priv = GEDIT_FILE_CHOOSER_DIALOG_OSX (dialog)->priv;
GeditFileChooserDialogOSX *dialog_osx = GEDIT_FILE_CHOOSER_DIALOG_OSX (dialog);
if (priv->is_open)
if (dialog_osx->is_open)
{
GSList *ret;
GFile *file = NULL;
......@@ -314,7 +315,7 @@ chooser_get_file (GeditFileChooserDialog *dialog)
}
else
{
return ns_url_to_g_file ([priv->panel URL]);
return ns_url_to_g_file ([dialog_osx->panel URL]);
}
}
......@@ -322,16 +323,16 @@ chooser_get_file (GeditFileChooserDialog *dialog)
static GSList *
chooser_get_files (GeditFileChooserDialog *dialog)
{
GeditFileChooserDialogOSXPrivate *priv = GEDIT_FILE_CHOOSER_DIALOG_OSX (dialog)->priv;
GeditFileChooserDialogOSX *dialog_osx = GEDIT_FILE_CHOOSER_DIALOG_OSX (dialog);
GSList *ret = NULL;
if (priv->is_open)
if (dialog_osx->is_open)
{
NSArray *urls;
gint i;
urls = [(NSOpenPanel *)priv->panel URLs];
urls = [(NSOpenPanel *)dialog_osx->panel URLs];
for (i = 0; i < [urls count]; i++)
{
......@@ -376,7 +377,7 @@ fill_encodings (GeditFileChooserDialogOSX *dialog)
encoding = gedit_file_chooser_dialog_get_encoding (GEDIT_FILE_CHOOSER_DIALOG (dialog));
button = dialog->priv->encoding_button;
button = dialog->encoding_button;
menu = [button menu];
while (i < [menu numberOfItems])
......@@ -405,7 +406,7 @@ fill_encodings (GeditFileChooserDialogOSX *dialog)
{
i++;
if ((dialog->priv->flags & GEDIT_FILE_CHOOSER_OPEN) != 0 && first == 0)
if ((dialog->flags & GEDIT_FILE_CHOOSER_OPEN) != 0 && first == 0)
{
first = i;
}
......@@ -447,7 +448,7 @@ dialog_response_cb (GtkDialog *dialog,
if (response_id != GTK_RESPONSE_HELP)
{
[chooser_dialog->priv->panel setAlphaValue:1.0f];
[chooser_dialog->panel setAlphaValue:1.0f];
gtk_widget_destroy (GTK_WIDGET (dialog));
}
}
......@@ -487,21 +488,20 @@ dialog_response_cb (GtkDialog *dialog,
dialog = gedit_encodings_dialog_new ();
if (_dialog->priv->parent != NULL)
if (_dialog->parent != NULL)
{
GtkWindowGroup *wg;
gtk_window_set_transient_for (GTK_WINDOW (dialog),
_dialog->priv->parent);
gtk_window_set_transient_for (GTK_WINDOW (dialog), _dialog->parent);
if (gtk_window_has_group (_dialog->priv->parent))
if (gtk_window_has_group (_dialog->parent))
{
wg = gtk_window_get_group (_dialog->priv->parent);
wg = gtk_window_get_group (_dialog->parent);
}
else
{
wg = gtk_window_group_new ();
gtk_window_group_add_window (wg, _dialog->priv->parent);
gtk_window_group_add_window (wg, _dialog->parent);
}
gtk_window_group_add_window (wg, GTK_WINDOW (dialog));
......@@ -521,7 +521,7 @@ dialog_response_cb (GtkDialog *dialog,
should be modal on top of the NSPanel, but the modal loops of gtk and NS
do not mix. This is an ugly hack, but at least we can't interact with the
NSPanel while showing the encodings dialog... */
[_dialog->priv->panel setAlphaValue:0.0f];
[_dialog->panel setAlphaValue:0.0f];
}
-(void)selectionChanged:(id)sender
......@@ -558,7 +558,7 @@ create_encoding_combo (GeditFileChooserDialogOSX *dialog,
menu = [button menu];
if ((dialog->priv->flags & GEDIT_FILE_CHOOSER_OPEN) != 0)
if ((dialog->flags & GEDIT_FILE_CHOOSER_OPEN) != 0)
{
NSString *title;
......@@ -599,7 +599,7 @@ create_encoding_combo (GeditFileChooserDialogOSX *dialog,
metrics:nil
views:NSDictionaryOfVariableBindings(label, button)]];
dialog->priv->encoding_button = button;
dialog->encoding_button = button;
fill_encodings (dialog);
......@@ -653,7 +653,7 @@ create_newline_combo (GeditFileChooserDialogOSX *dialog,
metrics:nil
views:NSDictionaryOfVariableBindings(label, button)]];
dialog->priv->newline_button = button;
dialog->newline_button = button;
return (gint)([button intrinsicContentSize].width + [label intrinsicContentSize].width);
}
......@@ -669,7 +669,7 @@ create_extra_widget (GeditFileChooserDialogOSX *dialog)
NSView *container;
gint minw = 0;
flags = dialog->priv->flags;
flags = dialog->flags;
needs_encoding = (flags & GEDIT_FILE_CHOOSER_ENABLE_ENCODING) != 0;
needs_line_ending = (flags & GEDIT_FILE_CHOOSER_ENABLE_LINE_ENDING) != 0;
......@@ -695,7 +695,7 @@ create_extra_widget (GeditFileChooserDialogOSX *dialog)
[container setFrame:NSMakeRect(0, 0, minw, 30)];
[dialog->priv->panel setAccessoryView:container];
[dialog->panel setAccessoryView:container];
parent = [[container superview] superview];
......@@ -709,91 +709,91 @@ create_extra_widget (GeditFileChooserDialogOSX *dialog)
size.width = minw;
[container setFrame:NSMakeRect(0, 0, size.width, size.height)];
[dialog->priv->panel setContentMinSize:size];
[dialog->panel setContentMinSize:size];
}
static void
chooser_show (GeditFileChooserDialog *dialog)
{
GeditFileChooserDialogOSXPrivate *priv = GEDIT_FILE_CHOOSER_DIALOG_OSX (dialog)->priv;
GeditFileChooserDialogOSX *dialog_osx = GEDIT_FILE_CHOOSER_DIALOG_OSX (dialog);
if (priv->is_running)
if (dialog_osx->is_running)
{
// Just show it again
[priv->panel makeKeyAndOrderFront:nil];
[dialog_osx->panel makeKeyAndOrderFront:nil];
return;
}
priv->is_running = TRUE;
dialog_osx->is_running = TRUE;
void (^handler)(NSInteger ret) = ^(NSInteger result) {
GtkResponseType response;
if (result == NSFileHandlingPanelOKButton)
{
response = priv->accept_response;
response = dialog_osx->accept_response;
}
else
{
response = priv->cancel_response;
response = dialog_osx->cancel_response;
}
g_signal_emit_by_name (dialog, "response", response);
};
if (priv->parent != NULL && priv->is_modal)
if (dialog_osx->parent != NULL && dialog_osx->is_modal)
{
GdkWindow *win;
NSWindow *nswin;
win = gtk_widget_get_window (GTK_WIDGET (priv->parent));
win = gtk_widget_get_window (GTK_WIDGET (dialog_osx->parent));
nswin = gdk_quartz_window_get_nswindow (win);
[priv->panel setLevel:NSModalPanelWindowLevel];
[dialog_osx->panel setLevel:NSModalPanelWindowLevel];
[priv->panel beginSheetModalForWindow:nswin completionHandler:handler];
[dialog_osx->panel beginSheetModalForWindow:nswin completionHandler:handler];
}
else
{
[priv->panel setLevel:NSModalPanelWindowLevel];
[priv->panel beginWithCompletionHandler:handler];
[dialog_osx->panel setLevel:NSModalPanelWindowLevel];
[dialog_osx->panel beginWithCompletionHandler:handler];
}
}
static void
chooser_hide (GeditFileChooserDialog *dialog)
{
GeditFileChooserDialogOSXPrivate *priv = GEDIT_FILE_CHOOSER_DIALOG_OSX (dialog)->priv;
GeditFileChooserDialogOSX *dialog_osx = GEDIT_FILE_CHOOSER_DIALOG_OSX (dialog);
if (!priv->is_running || priv->panel == NULL)
if (!dialog_osx->is_running || dialog_osx->panel == NULL)
{
return;
}
[priv->panel orderOut:nil];
[dialog_osx->panel orderOut:nil];
}
static void
chooser_destroy (GeditFileChooserDialog *dialog)
{
GeditFileChooserDialogOSXPrivate *priv = GEDIT_FILE_CHOOSER_DIALOG_OSX (dialog)->priv;
GeditFileChooserDialogOSX *dialog_osx = GEDIT_FILE_CHOOSER_DIALOG_OSX (dialog);
if (priv->parent != NULL)
if (dialog_osx->parent != NULL)
{
g_object_remove_weak_pointer (G_OBJECT (priv->parent),
(gpointer *)&priv->parent);
g_object_remove_weak_pointer (G_OBJECT (dialog_osx->parent),
(gpointer *)&dialog_osx->parent);
if (priv->destroy_id != 0)
if (dialog_osx->destroy_id != 0)
{
g_signal_handler_disconnect (priv->parent, priv->destroy_id);
priv->destroy_id = 0;
g_signal_handler_disconnect (dialog_osx->parent, dialog_osx->destroy_id);
dialog_osx->destroy_id = 0;
}
}
if (priv->panel != NULL)
if (dialog_osx->panel != NULL)
{
[priv->panel close];
priv->panel = NULL;
[dialog_osx->panel close];
dialog_osx->panel = NULL;
}
g_object_unref (dialog);
......@@ -803,9 +803,9 @@ static void
chooser_set_modal (GeditFileChooserDialog *dialog,
gboolean is_modal)
{
GeditFileChooserDialogOSXPrivate *priv = GEDIT_FILE_CHOOSER_DIALOG_OSX (dialog)->priv;
GeditFileChooserDialogOSX *dialog_osx = GEDIT_FILE_CHOOSER_DIALOG_OSX (dialog);
priv->is_modal = is_modal;
dialog_osx->is_modal = is_modal;
}
static void
......@@ -835,12 +835,12 @@ gedit_file_chooser_dialog_osx_chooser_init (gpointer g_iface,
static void
gedit_file_chooser_dialog_osx_dispose (GObject *object)
{
GeditFileChooserDialogOSXPrivate *priv = GEDIT_FILE_CHOOSER_DIALOG_OSX (object)->priv;
GeditFileChooserDialogOSX *dialog_osx = GEDIT_FILE_CHOOSER_DIALOG_OSX (object);
if (priv->panel != NULL)
if (dialog_osx->panel != NULL)
{
[priv->panel close];
priv->panel = NULL;