summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2022-02-09 21:33:44 +0100
committerBastien Nocera <hadess@hadess.net>2022-02-10 11:51:19 +0100
commitd640ea6b62bd8de95f80fd5eedfc827edb4311c5 (patch)
treeb6d2d3a92d5da2f22098f519b50723789dd670c5 /src
parent495279d182ec79fad46a89fd6e54aef5169c8d68 (diff)
downloadtotem-d640ea6b62bd8de95f80fd5eedfc827edb4311c5.tar.gz
main: Simplify TotemOpenLocation creation
Use G_DECLARE_FINAL_TYPE(), and remove intermediate private struct.
Diffstat (limited to 'src')
-rw-r--r--src/totem-open-location.c23
-rw-r--r--src/totem-open-location.h27
2 files changed, 13 insertions, 37 deletions
diff --git a/src/totem-open-location.c b/src/totem-open-location.c
index b9f34baab..9a676db2d 100644
--- a/src/totem-open-location.c
+++ b/src/totem-open-location.c
@@ -40,13 +40,13 @@
#include "totem-open-location.h"
#include "totem-interface.h"
-struct TotemOpenLocationPrivate
+struct _TotemOpenLocation
{
GtkWidget *uri_container;
GtkEntry *uri_entry;
};
-G_DEFINE_TYPE_WITH_PRIVATE (TotemOpenLocation, totem_open_location, GTK_TYPE_DIALOG)
+G_DEFINE_TYPE (TotemOpenLocation, totem_open_location, GTK_TYPE_DIALOG)
/* GtkBuilder callbacks */
G_MODULE_EXPORT void uri_entry_changed_cb (GtkEditable *entry, GtkDialog *dialog);
@@ -61,17 +61,16 @@ totem_open_location_init (TotemOpenLocation *self)
{
GtkBuilder *builder;
- self->priv = totem_open_location_get_instance_private (self);
builder = totem_interface_load ("uri.ui", FALSE, NULL, self);
if (builder == NULL)
return;
- self->priv->uri_container = GTK_WIDGET (gtk_builder_get_object (builder, "open_uri_dialog_content"));
- g_object_ref (self->priv->uri_container);
+ self->uri_container = GTK_WIDGET (gtk_builder_get_object (builder, "open_uri_dialog_content"));
+ g_object_ref (self->uri_container);
- self->priv->uri_entry = GTK_ENTRY (gtk_builder_get_object (builder, "uri"));
- gtk_entry_set_width_chars (self->priv->uri_entry, 50);
+ self->uri_entry = GTK_ENTRY (gtk_builder_get_object (builder, "uri"));
+ gtk_entry_set_width_chars (self->uri_entry, 50);
gtk_window_set_modal (GTK_WINDOW (self), TRUE);
@@ -114,7 +113,7 @@ totem_open_location_get_uri (TotemOpenLocation *open_location)
g_return_val_if_fail (TOTEM_IS_OPEN_LOCATION (open_location), NULL);
- uri = g_strdup (gtk_entry_get_text (open_location->priv->uri_entry));
+ uri = g_strdup (gtk_entry_get_text (open_location->uri_entry));
if (*uri == '\0')
g_clear_pointer (&uri, g_free);
@@ -172,7 +171,7 @@ totem_open_location_new (void)
open_location = TOTEM_OPEN_LOCATION (g_object_new (TOTEM_TYPE_OPEN_LOCATION,
"use-header-bar", 1, NULL));
- if (open_location->priv->uri_container == NULL) {
+ if (open_location->uri_container == NULL) {
g_object_unref (open_location);
return NULL;
}
@@ -189,13 +188,13 @@ totem_open_location_new (void)
/* Get item from clipboard to fill GtkEntry */
clipboard_location = totem_open_location_set_from_clipboard (open_location);
if (clipboard_location != NULL && strcmp (clipboard_location, "") != 0)
- gtk_entry_set_text (open_location->priv->uri_entry, clipboard_location);
+ gtk_entry_set_text (open_location->uri_entry, clipboard_location);
g_free (clipboard_location);
/* Add items in Totem's GtkRecentManager to the URI GtkEntry's GtkEntryCompletion */
completion = gtk_entry_completion_new();
model = GTK_TREE_MODEL (gtk_list_store_new (1, G_TYPE_STRING));
- gtk_entry_set_completion (open_location->priv->uri_entry, completion);
+ gtk_entry_set_completion (open_location->uri_entry, completion);
recent_items = gtk_recent_manager_get_items (gtk_recent_manager_get_default ());
@@ -236,7 +235,7 @@ totem_open_location_new (void)
gtk_entry_completion_set_match_func (completion, (GtkEntryCompletionMatchFunc) totem_open_location_match, model, NULL);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (open_location))),
- open_location->priv->uri_container,
+ open_location->uri_container,
TRUE, /* expand */
TRUE, /* fill */
0); /* padding */
diff --git a/src/totem-open-location.h b/src/totem-open-location.h
index d5bda752d..fffb7feb5 100644
--- a/src/totem-open-location.h
+++ b/src/totem-open-location.h
@@ -27,36 +27,13 @@
* Author: Bastien Nocera <hadess@hadess.net>, Philip Withnall <philip@tecnocode.co.uk>
*/
-#ifndef TOTEM_OPEN_LOCATION_H
-#define TOTEM_OPEN_LOCATION_H
+#pragma once
#include <gtk/gtk.h>
-G_BEGIN_DECLS
-
#define TOTEM_TYPE_OPEN_LOCATION (totem_open_location_get_type ())
-#define TOTEM_OPEN_LOCATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOTEM_TYPE_OPEN_LOCATION, TotemOpenLocation))
-#define TOTEM_OPEN_LOCATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOTEM_TYPE_OPEN_LOCATION, TotemOpenLocationClass))
-#define TOTEM_IS_OPEN_LOCATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOTEM_TYPE_OPEN_LOCATION))
-#define TOTEM_IS_OPEN_LOCATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOTEM_TYPE_OPEN_LOCATION))
-
-typedef struct TotemOpenLocation TotemOpenLocation;
-typedef struct TotemOpenLocationClass TotemOpenLocationClass;
-typedef struct TotemOpenLocationPrivate TotemOpenLocationPrivate;
-
-struct TotemOpenLocation {
- GtkDialog parent;
- TotemOpenLocationPrivate *priv;
-};
-
-struct TotemOpenLocationClass {
- GtkDialogClass parent_class;
-};
+G_DECLARE_FINAL_TYPE(TotemOpenLocation, totem_open_location, TOTEM, OPEN_LOCATION, GtkDialog)
GType totem_open_location_get_type (void);
GtkWidget *totem_open_location_new (void);
char *totem_open_location_get_uri (TotemOpenLocation *open_location);
-
-G_END_DECLS
-
-#endif /* TOTEM_OPEN_LOCATION_H */