[epiphany] Remove a bunch of dead code from ephy-gui



commit b79d35d9fe9260ce641209664390f6324b1e5cf6
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Fri Oct 14 17:41:21 2016 -0500

    Remove a bunch of dead code from ephy-gui

 lib/ephy-gui.c |  188 ++------------------------------------------------------
 lib/ephy-gui.h |   18 ------
 2 files changed, 6 insertions(+), 200 deletions(-)
---
diff --git a/lib/ephy-gui.c b/lib/ephy-gui.c
index 48a4b8a..8a3940b 100644
--- a/lib/ephy-gui.c
+++ b/lib/ephy-gui.c
@@ -21,79 +21,8 @@
 #include "config.h"
 #include "ephy-gui.h"
 
-#include "ephy-debug.h"
-
-#include <ctype.h>
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
-#include <string.h>
-#include <unistd.h>
-
-void
-ephy_gui_sanitise_popup_position (GtkMenu   *menu,
-                                  GtkWidget *widget,
-                                  gint      *x,
-                                  gint      *y)
-{
-  GdkScreen *screen = gtk_widget_get_screen (widget);
-  gint monitor_num;
-  GdkRectangle monitor;
-  GtkRequisition req;
-
-  g_return_if_fail (widget != NULL);
-
-  gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);
-
-  monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
-  gtk_menu_set_monitor (menu, monitor_num);
-  gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
-
-  *x = CLAMP (*x, monitor.x, monitor.x + MAX (0, monitor.width - req.width));
-  *y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height));
-}
-
-void
-ephy_gui_menu_position_tree_selection (GtkMenu  *menu,
-                                       gint     *x,
-                                       gint     *y,
-                                       gboolean *push_in,
-                                       gpointer  user_data)
-{
-  GtkTreeSelection *selection;
-  GList *selected_rows;
-  GtkTreeModel *model;
-  GtkTreeView *tree_view = GTK_TREE_VIEW (user_data);
-  GtkWidget *widget = GTK_WIDGET (user_data);
-  GtkRequisition req;
-  GtkAllocation allocation;
-  GdkRectangle visible;
-
-  gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);
-  gdk_window_get_origin (gtk_widget_get_window (widget), x, y);
-  gtk_widget_get_allocation (widget, &allocation);
-
-  *x += (allocation.width - req.width) / 2;
-
-  /* Add on height for the treeview title */
-  gtk_tree_view_get_visible_rect (tree_view, &visible);
-  *y += allocation.height - visible.height;
-
-  selection = gtk_tree_view_get_selection (tree_view);
-  selected_rows = gtk_tree_selection_get_selected_rows (selection, &model);
-  if (selected_rows) {
-    GdkRectangle cell_rect;
-
-    gtk_tree_view_get_cell_area (tree_view, selected_rows->data,
-                                 NULL, &cell_rect);
-
-    *y += CLAMP (cell_rect.y + cell_rect.height, 0, visible.height);
-
-    g_list_foreach (selected_rows, (GFunc)gtk_tree_path_free, NULL);
-    g_list_free (selected_rows);
-  }
-
-  ephy_gui_sanitise_popup_position (menu, widget, x, y);
-}
 
 GtkWindowGroup *
 ephy_gui_ensure_window_group (GtkWindow *window)
@@ -110,86 +39,6 @@ ephy_gui_ensure_window_group (GtkWindow *window)
   return group;
 }
 
-gboolean
-ephy_gui_check_location_writable (GtkWidget  *parent,
-                                  const char *filename)
-{
-  GtkWidget *dialog;
-  char *display_name;
-
-  if (filename == NULL) return FALSE;
-
-  if (!g_file_test (filename, G_FILE_TEST_EXISTS)) {
-    char *path = g_path_get_dirname (filename);
-    gboolean writable = access (path, W_OK) == 0;
-
-    /* check if path is writable to */
-    if (!writable) {
-      dialog = gtk_message_dialog_new (
-        parent ? GTK_WINDOW (parent) : NULL,
-        GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
-        GTK_MESSAGE_ERROR,
-        GTK_BUTTONS_CLOSE,
-        _("Directory ā€œ%sā€ is not writable"), path);
-
-      gtk_message_dialog_format_secondary_text (
-        GTK_MESSAGE_DIALOG (dialog),
-        _("You do not have permission to "
-          "create files in this directory."));
-
-      gtk_window_set_title (GTK_WINDOW (dialog), _("Directory not Writable"));
-
-      if (parent != NULL) {
-        gtk_window_group_add_window (
-          ephy_gui_ensure_window_group (GTK_WINDOW (parent)),
-          GTK_WINDOW (dialog));
-      }
-
-      gtk_dialog_run (GTK_DIALOG (dialog));
-
-      gtk_widget_destroy (dialog);
-    }
-
-    g_free (path);
-
-    return writable;
-  }
-
-  display_name = g_filename_display_basename (filename);
-
-  /* check if file is writable */
-  if (access (filename, W_OK) != 0) {
-    dialog = gtk_message_dialog_new (
-      parent ? GTK_WINDOW (parent) : NULL,
-      GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
-      GTK_MESSAGE_ERROR,
-      GTK_BUTTONS_CLOSE,
-      _("Cannot overwrite existing file ā€œ%sā€"), display_name);
-
-    gtk_message_dialog_format_secondary_text (
-      GTK_MESSAGE_DIALOG (dialog),
-      _("A file with this name already exists and "
-        "you don't have permission to overwrite it."));
-
-    gtk_window_set_title (GTK_WINDOW (dialog), _("Cannot Overwrite File"));
-
-    if (parent != NULL) {
-      gtk_window_group_add_window (
-        ephy_gui_ensure_window_group (GTK_WINDOW (parent)),
-        GTK_WINDOW (dialog));
-    }
-
-    gtk_dialog_run (GTK_DIALOG (dialog));
-
-    gtk_widget_destroy (dialog);
-
-    return FALSE;
-  }
-
-
-  return TRUE;
-}
-
 /**
  * ephy_gui_help:
  * @parent: the parent window where help is being called
@@ -266,35 +115,10 @@ ephy_gui_get_current_event (GdkEventType *otype,
     gdk_event_free (event);
   }
 
-  if (otype) *otype = type;
-  if (ostate) *ostate = state & gtk_accelerator_get_default_mod_mask ();
-  if (obutton) *obutton = button;
-}
-
-gboolean
-ephy_gui_is_middle_click (void)
-{
-  gboolean is_middle_click = FALSE;
-  GdkEvent *event;
-
-  event = gtk_get_current_event ();
-  if (event != NULL) {
-    if (event->type == GDK_BUTTON_RELEASE) {
-      guint modifiers, button, state;
-
-      modifiers = gtk_accelerator_get_default_mod_mask ();
-      button = event->button.button;
-      state = event->button.state;
-
-      /* middle-click or control-click */
-      if ((button == 1 && ((state & modifiers) == GDK_CONTROL_MASK)) ||
-          (button == 2 && ((state & modifiers) == 0))) {
-        is_middle_click = TRUE;
-      }
-    }
-
-    gdk_event_free (event);
-  }
-
-  return is_middle_click;
+  if (otype)
+    *otype = type;
+  if (ostate)
+    *ostate = state & gtk_accelerator_get_default_mod_mask ();
+  if (obutton)
+    *obutton = button;
 }
diff --git a/lib/ephy-gui.h b/lib/ephy-gui.h
index d0ce8d8..6283e73 100644
--- a/lib/ephy-gui.h
+++ b/lib/ephy-gui.h
@@ -20,34 +20,16 @@
 
 #pragma once
 
-#include <gdk/gdkkeysyms.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
 #include <gtk/gtk.h>
 
 G_BEGIN_DECLS
 
-void            ephy_gui_sanitise_popup_position         (GtkMenu *menu,
-                                                          GtkWidget *parent_widget,
-                                                          gint *x,
-                                                          gint *y);
-
-void            ephy_gui_menu_position_tree_selection    (GtkMenu   *menu,
-                                                          gint      *x,
-                                                          gint      *y,
-                                                          gboolean  *push_in,
-                                                          gpointer  user_data);
-
 GtkWindowGroup *ephy_gui_ensure_window_group             (GtkWindow *window);
 
 void            ephy_gui_get_current_event               (GdkEventType *type,
                                                           guint *state,
                                                           guint *button);
 
-gboolean        ephy_gui_is_middle_click                 (void);
-
-gboolean        ephy_gui_check_location_writable         (GtkWidget *parent,
-                                                          const char *filename);
-
 void            ephy_gui_help                            (GtkWidget *parent,
                                                           const char *page);
 


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