[gnome-panel/wip/muktupavels/launcher: 19/20] more removal



commit 3e7633c000f7c818df7a35801f7603da006853b7
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Mon Apr 13 14:28:28 2020 +0300

    more removal

 gnome-panel/Makefile.am                        |    2 -
 gnome-panel/libpanel-util/Makefile.am          |    2 -
 gnome-panel/libpanel-util/panel-icon-chooser.c |  549 -------------
 gnome-panel/libpanel-util/panel-icon-chooser.h |   73 --
 gnome-panel/libpanel-util/panel-keyfile.c      |   55 --
 gnome-panel/libpanel-util/panel-keyfile.h      |    8 -
 gnome-panel/libpanel-util/panel-xdg.c          |   99 ---
 gnome-panel/libpanel-util/panel-xdg.h          |    3 -
 gnome-panel/panel-ditem-editor.c               | 1000 ------------------------
 gnome-panel/panel-ditem-editor.h               |   76 --
 gnome-panel/panel-util.c                       |   31 -
 gnome-panel/panel-util.h                       |    2 -
 gnome-panel/panel.c                            |  251 ++----
 po/POTFILES.in                                 |    2 -
 14 files changed, 72 insertions(+), 2081 deletions(-)
---
diff --git a/gnome-panel/Makefile.am b/gnome-panel/Makefile.am
index e6fdca248..339781195 100644
--- a/gnome-panel/Makefile.am
+++ b/gnome-panel/Makefile.am
@@ -46,7 +46,6 @@ panel_sources =                       \
        panel-force-quit.c      \
        panel-lockdown.c        \
        panel-addto-dialog.c    \
-       panel-ditem-editor.c    \
        panel-layout.c          \
        panel-object-loader.c   \
        panel-applet-info.c
@@ -75,7 +74,6 @@ panel_headers =                       \
        panel-force-quit.h      \
        panel-lockdown.h        \
        panel-addto-dialog.h    \
-       panel-ditem-editor.h    \
        panel-icon-names.h      \
        panel-layout.h          \
        panel-object-loader.h   \
diff --git a/gnome-panel/libpanel-util/Makefile.am b/gnome-panel/libpanel-util/Makefile.am
index 122f18f82..425e110ba 100644
--- a/gnome-panel/libpanel-util/Makefile.am
+++ b/gnome-panel/libpanel-util/Makefile.am
@@ -38,8 +38,6 @@ libpanel_util_la_SOURCES =            \
        panel-gsettings.h               \
        panel-gtk.c                     \
        panel-gtk.h                     \
-       panel-icon-chooser.c            \
-       panel-icon-chooser.h            \
        panel-keyfile.c                 \
        panel-keyfile.h                 \
        panel-launch.c                  \
diff --git a/gnome-panel/libpanel-util/panel-keyfile.c b/gnome-panel/libpanel-util/panel-keyfile.c
index 64efb4560..22934f4b1 100644
--- a/gnome-panel/libpanel-util/panel-keyfile.c
+++ b/gnome-panel/libpanel-util/panel-keyfile.c
@@ -196,58 +196,3 @@ panel_key_file_set_locale_string (GKeyFile    *keyfile,
                g_key_file_set_string (keyfile, G_KEY_FILE_DESKTOP_GROUP,
                                       key, value);
 }
-
-void
-panel_key_file_remove_all_locale_key (GKeyFile    *keyfile,
-                                     const gchar *key)
-{
-       char **keys;
-       int    key_len;
-       int    i;
-
-       if (!key)
-               return;
-
-       keys = g_key_file_get_keys (keyfile, G_KEY_FILE_DESKTOP_GROUP, NULL, NULL);
-       if (!keys)
-               return;
-
-       key_len = strlen (key);
-
-       for (i = 0; keys[i] != NULL; i++) {
-               int len;
-
-               if (strncmp (keys[i], key, key_len))
-                       continue;
-
-               len = strlen (keys[i]);
-               if (len == key_len ||
-                   (len > key_len && keys[i][key_len] == '['))
-                       g_key_file_remove_key (keyfile, G_KEY_FILE_DESKTOP_GROUP,
-                                              keys[i], NULL);
-       }
-
-       g_strfreev (keys);
-}
-
-void
-panel_key_file_ensure_C_key (GKeyFile   *keyfile,
-                            const char *key)
-{
-       char *C_value;
-       char *buffer;
-
-       /* Make sure we set the "C" locale strings to the terms we set here.
-        * This is so that if the user logs into another locale they get their
-        * own description there rather then empty. It is not the C locale
-        * however, but the user created this entry herself so it's OK */
-       C_value = panel_key_file_get_string (keyfile, key);
-       if (C_value == NULL || C_value [0] == '\0') {
-               buffer = panel_key_file_get_locale_string (keyfile, key);
-               if (buffer) {
-                       panel_key_file_set_string (keyfile, key, buffer);
-                       g_free (buffer);
-               }
-       }
-       g_free (C_value);
-}
diff --git a/gnome-panel/libpanel-util/panel-keyfile.h b/gnome-panel/libpanel-util/panel-keyfile.h
index 0db2d39fe..91f4401bc 100644
--- a/gnome-panel/libpanel-util/panel-keyfile.h
+++ b/gnome-panel/libpanel-util/panel-keyfile.h
@@ -29,7 +29,6 @@
 
 G_BEGIN_DECLS
 
-
 GKeyFile *panel_key_file_new_desktop  (void);
 gboolean  panel_key_file_to_file      (GKeyFile       *keyfile,
                                       const gchar    *file,
@@ -51,13 +50,6 @@ void    panel_key_file_set_locale_string (GKeyFile    *keyfile,
                                          const gchar *key,
                                          const gchar *value);
 
-#define panel_key_file_remove_key(key_file, key) \
-       g_key_file_remove_key (key_file, G_KEY_FILE_DESKTOP_GROUP, key, NULL)
-void panel_key_file_remove_all_locale_key (GKeyFile    *keyfile,
-                                          const gchar *key);
-void panel_key_file_ensure_C_key      (GKeyFile   *keyfile,
-                                      const char *key);
-
 G_END_DECLS
 
 #endif /* PANEL_KEYFILE_H */
diff --git a/gnome-panel/libpanel-util/panel-xdg.c b/gnome-panel/libpanel-util/panel-xdg.c
index 6c2f242dd..f9c9ef74c 100644
--- a/gnome-panel/libpanel-util/panel-xdg.c
+++ b/gnome-panel/libpanel-util/panel-xdg.c
@@ -27,8 +27,6 @@
 
 #include "panel-xdg.h"
 
-#define DEFAULT_THEME_NAME "hicolor"
-
 /*
  * Originally based on code from panel-util.c. This part of the code was:
  * Copyright (C) 2006 Vincent Untz <vuntz gnome org>
@@ -51,100 +49,3 @@ panel_xdg_icon_remove_extension (const char *icon)
 
        return icon_no_extension;
 }
-
-/*
- * End of code coming from panel-util.c
- */
-
-char *
-panel_xdg_icon_name_from_icon_path (const char *path,
-                                   GdkScreen  *screen)
-{
-       GtkIconTheme  *theme;
-       GtkSettings   *settings;
-       char          *theme_name;
-       char          *icon;
-       char         **paths;
-       int            n_paths;
-       int            i;
-       GFile         *file;
-
-       /* we look if the icon comes from the current icon theme */
-       if (!screen)
-               screen = gdk_screen_get_default ();
-
-       settings = gtk_settings_get_for_screen (screen);
-       g_object_get (settings,
-                     "gtk-icon-theme-name", &theme_name,
-                     NULL);
-
-       theme = gtk_icon_theme_get_for_screen (screen);
-       gtk_icon_theme_get_search_path (theme, &paths, &n_paths);
-
-       file = g_file_new_for_path (path);
-       icon = NULL;
-
-       for (i = 0; i < n_paths; i++) {
-               GFile *parent;
-               char  *basename;
-
-               parent = g_file_new_for_path (paths[i]);
-
-               if (!g_file_has_prefix (file, parent)) {
-                       g_object_unref (parent);
-                       continue;
-               }
-
-               basename = g_file_get_basename (parent);
-
-               if (g_strcmp0 (basename, "pixmaps") == 0) {
-                       char *relative_path;
-
-                       relative_path = g_file_get_relative_path (parent, file);
-
-                       /* if the icon is in a subdir of pixmaps, then it's not
-                        * a real icon name */
-                       if (!strchr (relative_path, G_DIR_SEPARATOR))
-                               icon = panel_xdg_icon_remove_extension (relative_path);
-
-                       g_free (relative_path);
-               } else {
-                       /* real icon theme; but is it the current one? */
-                       GFile    *theme_dir;
-                       gboolean  current;
-
-                       theme_dir = g_file_get_child (parent, theme_name);
-
-                       current = FALSE;
-                       if (g_file_has_prefix (file, theme_dir)) {
-                               /* it's the current one */
-                               current = TRUE;
-                       } else {
-                               /* it's the default one */
-                               g_object_unref (theme_dir);
-                               theme_dir = g_file_get_child (parent, DEFAULT_THEME_NAME);
-                               current = g_file_has_prefix (file, theme_dir);
-                       }
-
-                       g_object_unref (theme_dir);
-
-                       if (current) {
-                               char *buffer;
-
-                               buffer = g_file_get_basename (file);
-                               icon = panel_xdg_icon_remove_extension (buffer);
-                               g_free (buffer);
-                       }
-               }
-
-               g_free (basename);
-               g_object_unref (parent);
-
-               break;
-       }
-
-       g_object_unref (file);
-       g_free (theme_name);
-
-       return icon;
-}
diff --git a/gnome-panel/libpanel-util/panel-xdg.h b/gnome-panel/libpanel-util/panel-xdg.h
index 86c7b9f87..08cc082ae 100644
--- a/gnome-panel/libpanel-util/panel-xdg.h
+++ b/gnome-panel/libpanel-util/panel-xdg.h
@@ -29,9 +29,6 @@ G_BEGIN_DECLS
 
 char *panel_xdg_icon_remove_extension (const char *icon);
 
-char *panel_xdg_icon_name_from_icon_path (const char *path,
-                                         GdkScreen  *screen);
-
 G_END_DECLS
 
 #endif /* PANEL_XDG_H */
diff --git a/gnome-panel/panel-util.c b/gnome-panel/panel-util.c
index 8e007aad1..ebd6b6183 100644
--- a/gnome-panel/panel-util.c
+++ b/gnome-panel/panel-util.c
@@ -39,37 +39,6 @@
 #include "panel-icon-names.h"
 #include "panel-schemas.h"
 
-char *
-panel_util_make_exec_uri_for_desktop (const char *exec)
-{
-       GString    *str;
-       const char *c;
-
-       if (!exec)
-               return g_strdup ("");
-
-       if (!strchr (exec, ' '))
-               return g_strdup (exec);
-
-       str = g_string_new_len (NULL, strlen (exec));
-
-       str = g_string_append_c (str, '"');
-       for (c = exec; *c != '\0'; c++) {
-               /* FIXME: GKeyFile will add an additional backslach so we'll
-                * end up with toto\\" instead of toto\"
-                * We could use g_key_file_set_value(), but then we don't
-                * benefit from the other escaping that glib is doing...
-                */
-               if (*c == '"')
-                       str = g_string_append (str, "\\\"");
-               else
-                       str = g_string_append_c (str, *c);
-       }
-       str = g_string_append_c (str, '"');
-
-       return g_string_free (str, FALSE);
-}
-
 void
 panel_push_window_busy (GtkWidget *window)
 {
diff --git a/gnome-panel/panel-util.h b/gnome-panel/panel-util.h
index 0d347e783..910a23885 100644
--- a/gnome-panel/panel-util.h
+++ b/gnome-panel/panel-util.h
@@ -8,8 +8,6 @@ G_BEGIN_DECLS
 
 #define                sure_string(s)          ((const char *)((s)!=NULL?(s):""))
 
-char *          panel_util_make_exec_uri_for_desktop (const char *exec);
-
 void           panel_push_window_busy  (GtkWidget *window);
 void           panel_pop_window_busy   (GtkWidget *window);
 
diff --git a/gnome-panel/panel.c b/gnome-panel/panel.c
index b06425527..289dcd124 100644
--- a/gnome-panel/panel.c
+++ b/gnome-panel/panel.c
@@ -31,7 +31,6 @@
 #include "panel-applets-manager.h"
 #include "panel-bindings.h"
 #include "panel-context-menu.h"
-#include "panel-ditem-editor.h"
 #include "panel-util.h"
 #include "panel-applet-frame.h"
 #include "panel-action-button.h"
@@ -433,141 +432,111 @@ create_launcher (PanelToplevel       *toplevel,
   g_variant_unref (settings);
 }
 
-static char *
-panel_launcher_find_writable_uri (const char *launcher_location,
-                                 const char *source)
+typedef struct
 {
-       char *path;
-       char *uri;
-
-       if (!launcher_location)
-               return panel_make_unique_desktop_uri (NULL, source);
-
-       if (!strchr (launcher_location, G_DIR_SEPARATOR)) {
-               path = panel_make_full_path (NULL, launcher_location);
-               uri = g_filename_to_uri (path, NULL, NULL);
-               g_free (path);
-               return uri;
-       }
-
-       if (panel_launcher_get_filename (launcher_location) != NULL) {
-               /* we have a file in the user directory. We either have a path
-                * or an URI */
-               if (g_path_is_absolute (launcher_location))
-                       return g_filename_to_uri (launcher_location,
-                                                 NULL, NULL);
-               else
-                       return g_strdup (launcher_location);
-       }
+       PanelWidget         *panel;
 
-       return panel_make_unique_desktop_uri (NULL, source);
-}
+       PanelObjectPackType  pack_type;
+       int                  pack_index;
+       gchar               *iid;
+} InitialSetupData;
 
-static char *
-launcher_save_uri (PanelDItemEditor *dialog,
-                  gpointer          data)
+static InitialSetupData *
+initial_setup_data_new (PanelWidget         *panel,
+                        PanelObjectPackType  pack_type,
+                        int                  pack_index,
+                        const gchar         *iid)
 {
-       GKeyFile   *key_file;
-       char       *type;
-       char       *exec_or_uri;
-       char       *new_uri;
-       const char *uri;
-
-       key_file = panel_ditem_editor_get_key_file (dialog);
-       type = panel_key_file_get_string (key_file, "Type");
-       if (type && !strcmp (type, "Application"))
-               exec_or_uri = panel_key_file_get_string (key_file, "Exec");
-       else if (type && !strcmp (type, "Link"))
-               exec_or_uri = panel_key_file_get_string (key_file, "URL");
-       else
-               exec_or_uri = panel_key_file_get_string (key_file, "Name");
-       g_free (type);
-
-       new_uri = panel_launcher_find_writable_uri (NULL, exec_or_uri);
-
-       g_free (exec_or_uri);
+       InitialSetupData *data;
 
-       uri = panel_ditem_editor_get_uri (dialog);
+       data = g_new0 (InitialSetupData, 1);
 
-       if (!uri || (new_uri && strcmp (new_uri, uri)))
-               return new_uri;
+       data->panel = panel;
 
-       g_free (new_uri);
+       data->pack_type = pack_type;
+       data->pack_index = pack_index;
+       data->iid = g_strdup (iid);
 
-       return NULL;
+       return data;
 }
 
 static void
-launcher_error_reported (GtkWidget  *dialog,
-                        const char *primary,
-                        const char *secondary,
-                        gpointer    data)
+initial_setup_data_free (gpointer user_data)
 {
-       panel_error_dialog (GTK_WINDOW (dialog), NULL,
-                           "error_editing_launcher", TRUE,
-                           primary, secondary);
+       InitialSetupData *data;
+
+       data = (InitialSetupData *) user_data;
+
+       g_free (data->iid);
+       g_free (data);
 }
 
 static void
-launcher_new_saved (GtkWidget *dialog,
-                   gpointer   data)
+initial_setup_dialog_cb (GpInitialSetupDialog *dialog,
+                         gboolean              canceled,
+                         gpointer              user_data)
 {
-       PanelWidget         *panel;
-       PanelObjectPackType  pack_type;
-       int                  pack_index;
-       const char          *uri;
+       InitialSetupData *data;
+       GVariant *initial_settings;
 
-       pack_type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (dialog),
-                                    "pack-type"));
-       panel = g_object_get_data (G_OBJECT (dialog), "panel");
+       data = (InitialSetupData *) user_data;
 
-       pack_index = panel_widget_get_new_pack_index (panel, pack_type);
+       if (canceled)
+               return;
 
-       uri = panel_ditem_editor_get_uri (PANEL_DITEM_EDITOR (dialog));
-       if (panel_launcher_get_filename (uri) != NULL)
-               uri = panel_launcher_get_filename (uri);
+       initial_settings = gp_initital_setup_dialog_get_settings (dialog);
 
-       create_launcher (panel->toplevel, pack_type, pack_index, uri);
+       panel_applet_frame_create (data->panel->toplevel,
+                                  data->pack_type,
+                                  data->pack_index,
+                                  data->iid,
+                                  initial_settings);
+
+       g_variant_unref (initial_settings);
 }
 
 static void
 ask_about_launcher (const char          *file,
-                   PanelWidget         *panel,
-                   PanelObjectPackType  pack_type)
+                    PanelWidget         *panel,
+                    PanelObjectPackType  pack_type)
 {
-       GtkWidget *dialog;
-       GKeyFile  *key_file;
+  int pack_index;
+  const char *iid;
+  InitialSetupData *initial_setup_data;
+  GVariantBuilder builder;
+  GVariant *variant;
+  GVariant *settings;
 
        if (panel_lockdown_get_disable_command_line_s ())
                return;
 
-       dialog = panel_ditem_editor_new (_("Create Launcher"));
-       panel_widget_register_open_dialog (panel, dialog);
+  iid = "org.gnome.gnome-panel.launcher::custom-launcher";
+  pack_index = panel_widget_get_new_pack_index (panel, pack_type);
+  initial_setup_data = initial_setup_data_new (panel, pack_type, pack_index, iid);
 
-       key_file = panel_ditem_editor_get_key_file (PANEL_DITEM_EDITOR (dialog));
-       if (file != NULL)
-               panel_key_file_set_string (key_file, "Exec", file);
-       panel_key_file_set_string (key_file, "Type", "Application");
-       panel_ditem_editor_sync_display (PANEL_DITEM_EDITOR (dialog));
+  g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
 
-       panel_ditem_register_save_uri_func (PANEL_DITEM_EDITOR (dialog),
-                                           launcher_save_uri,
-                                           NULL);
+  variant = g_variant_new_string ("Application");
+  g_variant_builder_add (&builder, "{sv}", "type", variant);
 
-       g_signal_connect (G_OBJECT (dialog), "saved",
-                         G_CALLBACK (launcher_new_saved), NULL);
+  if (file != NULL)
+    {
+      variant = g_variant_new_string (file);
+      g_variant_builder_add (&builder, "{sv}", "command", variant);
+    }
 
-       g_signal_connect (G_OBJECT (dialog), "error_reported",
-                         G_CALLBACK (launcher_error_reported), NULL);
+  settings = g_variant_builder_end (&builder);
+  g_variant_ref_sink (settings);
 
-       gtk_window_set_screen (GTK_WINDOW (dialog),
-                              gtk_widget_get_screen (GTK_WIDGET (panel)));
+  // FIXME: pass initial data to inital dialog :D
 
-       g_object_set_data (G_OBJECT (dialog), "pack-type",
-                          GINT_TO_POINTER (pack_type));
-       g_object_set_data (G_OBJECT (dialog), "panel", panel);
+  panel_applets_manager_open_initial_setup_dialog (iid,
+                                                                    NULL,
+                                                                    initial_setup_dialog_cb,
+                                                                    initial_setup_data,
+                                                                    initial_setup_data_free);
 
-       gtk_widget_show (dialog);
+  g_variant_unref (settings);
 }
 
 static void
@@ -1126,80 +1095,6 @@ drag_leave_cb (GtkWidget      *widget,
        panel_toplevel_queue_auto_hide (toplevel);
 }
 
-typedef struct
-{
-       PanelWidget         *panel;
-
-       GdkDragContext      *context;
-       guint                time;
-
-       PanelObjectPackType  pack_type;
-       int                  pack_index;
-       gchar               *iid;
-} InitialSetupData;
-
-static InitialSetupData *
-initial_setup_data_new (PanelWidget         *panel,
-                        GdkDragContext      *context,
-                        guint                time,
-                        PanelObjectPackType  pack_type,
-                        int                  pack_index,
-                        const gchar         *iid)
-{
-       InitialSetupData *data;
-
-       data = g_new0 (InitialSetupData, 1);
-
-       data->panel = panel;
-
-       data->context = context;
-       data->time = time;
-
-       data->pack_type = pack_type;
-       data->pack_index = pack_index;
-       data->iid = g_strdup (iid);
-
-       return data;
-}
-
-static void
-initial_setup_data_free (gpointer user_data)
-{
-       InitialSetupData *data;
-
-       data = (InitialSetupData *) user_data;
-
-       g_free (data->iid);
-       g_free (data);
-}
-
-static void
-initial_setup_dialog_cb (GpInitialSetupDialog *dialog,
-                         gboolean              canceled,
-                         gpointer              user_data)
-{
-       InitialSetupData *data;
-       GVariant *initial_settings;
-
-       data = (InitialSetupData *) user_data;
-
-       if (canceled) {
-               gtk_drag_finish (data->context, FALSE, FALSE, data->time);
-               return;
-       }
-
-       initial_settings = gp_initital_setup_dialog_get_settings (dialog);
-
-       panel_applet_frame_create (data->panel->toplevel,
-                                  data->pack_type,
-                                  data->pack_index,
-                                  data->iid,
-                                  initial_settings);
-
-       gtk_drag_finish (data->context, TRUE, FALSE, data->time);
-       g_variant_unref (initial_settings);
-}
-
 static void
 panel_receive_dnd_data (PanelWidget         *panel,
                        guint                info,
@@ -1247,7 +1142,7 @@ panel_receive_dnd_data (PanelWidget         *panel,
                if (panel_layout_is_writable ()) {
                        InitialSetupData *initial_setup_data;
 
-                       initial_setup_data = initial_setup_data_new (panel, context, time_,
+                       initial_setup_data = initial_setup_data_new (panel,
                                                                     pack_type, pack_index,
                                                                     (char *) data);
 
@@ -1259,11 +1154,9 @@ panel_receive_dnd_data (PanelWidget         *panel,
                                panel_applet_frame_create (panel->toplevel,
                                                           pack_type, pack_index,
                                                           (char *) data, NULL);
-
-                               success = TRUE;
-                       } else {
-                               return;
                        }
+
+                       success = TRUE;
                } else {
                        success = FALSE;
                }
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 76253d3c7..3d23da159 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -16,7 +16,6 @@ gnome-panel/gp-main.c
 gnome-panel/gp-properties-dialog.c
 gnome-panel/gp-properties-dialog.ui
 gnome-panel/libpanel-util/panel-error.c
-gnome-panel/libpanel-util/panel-icon-chooser.c
 gnome-panel/libpanel-util/panel-launch.c
 gnome-panel/libpanel-util/panel-show.c
 gnome-panel/panel-action-button.c
@@ -26,7 +25,6 @@ gnome-panel/panel-applet-frame.c
 gnome-panel/panel-bindings.c
 gnome-panel/panel.c
 gnome-panel/panel-context-menu.c
-gnome-panel/panel-ditem-editor.c
 gnome-panel/panel-force-quit.c
 gnome-panel/panel-layout.c
 gnome-panel/panel-run-dialog.c


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]