2010-12-12 14:08:40 -05:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Red Hat, Inc
|
|
|
|
* Copyright (C) 2008 William Jon McCann <jmccann@redhat.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2014-01-23 12:57:27 +01:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2010-12-12 14:08:40 -05:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-02-24 19:51:44 +01:00
|
|
|
#include <config.h>
|
|
|
|
|
2010-12-12 14:08:40 -05:00
|
|
|
#include "cc-info-panel.h"
|
2017-02-25 14:38:00 +05:30
|
|
|
#include "cc-info-overview-panel.h"
|
2017-05-23 16:45:08 +05:30
|
|
|
#include "cc-info-default-apps-panel.h"
|
2017-05-25 14:13:19 +05:30
|
|
|
#include "cc-info-removable-media-panel.h"
|
2013-01-04 15:05:07 +01:00
|
|
|
#include "cc-info-resources.h"
|
2016-11-16 15:07:10 +01:00
|
|
|
#include "info-cleanup.h"
|
2010-12-12 14:08:40 -05:00
|
|
|
|
2011-01-10 18:30:45 -05:00
|
|
|
#include <glib.h>
|
|
|
|
#include <glib/gi18n.h>
|
2011-01-18 19:26:37 -05:00
|
|
|
#include <gio/gio.h>
|
|
|
|
#include <gio/gunixmounts.h>
|
2012-04-14 01:51:35 +02:00
|
|
|
#include <gio/gdesktopappinfo.h>
|
2011-01-10 18:30:45 -05:00
|
|
|
|
2011-01-10 17:56:52 -05:00
|
|
|
#include <glibtop/fsusage.h>
|
|
|
|
#include <glibtop/mountlist.h>
|
|
|
|
#include <glibtop/mem.h>
|
|
|
|
#include <glibtop/sysinfo.h>
|
|
|
|
|
2014-04-24 16:35:35 +02:00
|
|
|
#ifdef GDK_WINDOWING_WAYLAND
|
2014-04-21 14:12:12 -04:00
|
|
|
#include <gdk/gdkwayland.h>
|
2014-04-24 16:35:35 +02:00
|
|
|
#endif
|
|
|
|
#ifdef GDK_WINDOWING_X11
|
2013-01-12 17:43:21 +01:00
|
|
|
#include <gdk/gdkx.h>
|
2014-04-24 16:35:35 +02:00
|
|
|
#endif
|
2013-01-12 17:43:21 +01:00
|
|
|
|
2012-04-19 12:00:04 +01:00
|
|
|
#include "gsd-disk-space-helper.h"
|
2011-05-13 16:07:55 +01:00
|
|
|
|
2017-09-25 16:11:32 -04:00
|
|
|
#define WID(w) (GtkWidget *) gtk_builder_get_object (self->builder, w)
|
2010-12-12 14:08:40 -05:00
|
|
|
|
2017-09-25 16:11:32 -04:00
|
|
|
struct _CcInfoPanel
|
2010-12-12 14:08:40 -05:00
|
|
|
{
|
2017-09-25 16:11:32 -04:00
|
|
|
CcPanel parent_instance;
|
|
|
|
|
|
|
|
GtkBuilder *builder;
|
2010-12-12 14:08:40 -05:00
|
|
|
};
|
|
|
|
|
2017-09-25 16:11:32 -04:00
|
|
|
CC_PANEL_REGISTER (CcInfoPanel, cc_info_panel)
|
|
|
|
|
2010-12-12 14:08:40 -05:00
|
|
|
static void
|
|
|
|
cc_info_panel_dispose (GObject *object)
|
|
|
|
{
|
2017-09-25 16:11:32 -04:00
|
|
|
CcInfoPanel *self = CC_INFO_PANEL (object);
|
2010-12-12 14:08:40 -05:00
|
|
|
|
2017-09-25 16:11:32 -04:00
|
|
|
g_clear_object (&self->builder);
|
2011-02-25 11:04:02 -05:00
|
|
|
|
2010-12-12 14:08:40 -05:00
|
|
|
G_OBJECT_CLASS (cc_info_panel_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cc_info_panel_class_init (CcInfoPanelClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->dispose = cc_info_panel_dispose;
|
2012-11-24 14:01:59 -05:00
|
|
|
|
2017-02-25 14:38:00 +05:30
|
|
|
g_type_ensure (CC_TYPE_INFO_OVERVIEW_PANEL);
|
2017-05-23 16:45:08 +05:30
|
|
|
g_type_ensure (CC_TYPE_INFO_DEFAULT_APPS_PANEL);
|
2017-05-25 14:13:19 +05:30
|
|
|
g_type_ensure (CC_TYPE_INFO_REMOVABLE_MEDIA_PANEL);
|
2011-01-10 18:30:45 -05:00
|
|
|
}
|
|
|
|
|
2010-12-12 14:08:40 -05:00
|
|
|
static void
|
2011-02-10 14:13:28 -05:00
|
|
|
on_section_changed (GtkTreeSelection *selection,
|
|
|
|
gpointer data)
|
2010-12-12 14:08:40 -05:00
|
|
|
{
|
2011-02-10 14:13:28 -05:00
|
|
|
CcInfoPanel *self = CC_INFO_PANEL (data);
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreePath *path;
|
|
|
|
gint *indices;
|
|
|
|
int index;
|
2010-12-12 14:08:40 -05:00
|
|
|
|
2011-02-10 14:13:28 -05:00
|
|
|
if (!gtk_tree_selection_get_selected (selection, &model, &iter))
|
|
|
|
return;
|
2010-12-12 14:08:40 -05:00
|
|
|
|
2011-02-10 14:13:28 -05:00
|
|
|
path = gtk_tree_model_get_path (model, &iter);
|
2010-12-12 14:08:40 -05:00
|
|
|
|
2011-02-10 14:13:28 -05:00
|
|
|
indices = gtk_tree_path_get_indices (path);
|
|
|
|
index = indices[0];
|
2010-12-12 14:08:40 -05:00
|
|
|
|
2011-02-10 14:13:28 -05:00
|
|
|
if (index >= 0)
|
2010-12-12 14:08:40 -05:00
|
|
|
{
|
2011-05-11 14:18:37 +01:00
|
|
|
g_object_set (G_OBJECT (WID ("notebook")),
|
2011-02-10 14:13:28 -05:00
|
|
|
"page", index, NULL);
|
2010-12-12 14:08:40 -05:00
|
|
|
}
|
|
|
|
|
2011-02-10 14:13:28 -05:00
|
|
|
gtk_tree_path_free (path);
|
|
|
|
}
|
2011-09-09 10:33:10 +01:00
|
|
|
|
2011-02-10 14:13:28 -05:00
|
|
|
static void
|
|
|
|
info_panel_setup_selector (CcInfoPanel *self)
|
|
|
|
{
|
|
|
|
GtkTreeView *view;
|
|
|
|
GtkListStore *model;
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
GtkTreeViewColumn *column;
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
int section_name_column = 0;
|
|
|
|
|
2011-05-11 14:18:37 +01:00
|
|
|
view = GTK_TREE_VIEW (WID ("overview_treeview"));
|
2011-02-10 14:13:28 -05:00
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
|
|
|
|
|
|
|
|
model = gtk_list_store_new (1, G_TYPE_STRING);
|
|
|
|
gtk_tree_view_set_model (view, GTK_TREE_MODEL (model));
|
|
|
|
g_object_unref (model);
|
|
|
|
|
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
2011-05-20 12:43:51 -04:00
|
|
|
gtk_cell_renderer_set_padding (renderer, 4, 4);
|
2011-02-10 14:13:28 -05:00
|
|
|
g_object_set (renderer,
|
|
|
|
"width-chars", 20,
|
|
|
|
"ellipsize", PANGO_ELLIPSIZE_END,
|
|
|
|
NULL);
|
|
|
|
column = gtk_tree_view_column_new_with_attributes (_("Section"),
|
|
|
|
renderer,
|
|
|
|
"text", section_name_column,
|
|
|
|
NULL);
|
|
|
|
gtk_tree_view_append_column (view, column);
|
|
|
|
|
|
|
|
|
|
|
|
gtk_list_store_append (model, &iter);
|
|
|
|
gtk_list_store_set (model, &iter, section_name_column,
|
|
|
|
_("Overview"),
|
|
|
|
-1);
|
|
|
|
gtk_tree_selection_select_iter (selection, &iter);
|
|
|
|
|
2011-02-14 19:45:43 -05:00
|
|
|
gtk_list_store_append (model, &iter);
|
|
|
|
gtk_list_store_set (model, &iter, section_name_column,
|
|
|
|
_("Default Applications"),
|
|
|
|
-1);
|
|
|
|
|
2011-09-09 10:33:10 +01:00
|
|
|
gtk_list_store_append (model, &iter);
|
|
|
|
gtk_list_store_set (model, &iter, section_name_column,
|
|
|
|
_("Removable Media"),
|
|
|
|
-1);
|
|
|
|
|
2011-02-10 14:13:28 -05:00
|
|
|
g_signal_connect (selection, "changed",
|
|
|
|
G_CALLBACK (on_section_changed), self);
|
|
|
|
on_section_changed (selection, self);
|
|
|
|
|
|
|
|
gtk_widget_show_all (GTK_WIDGET (view));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
info_panel_setup_overview (CcInfoPanel *self)
|
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
2011-02-04 14:27:25 -05:00
|
|
|
|
2011-05-11 14:18:37 +01:00
|
|
|
widget = WID ("info_vbox");
|
2013-09-17 14:33:09 +02:00
|
|
|
gtk_container_add (GTK_CONTAINER (self), widget);
|
2011-02-14 22:33:42 -05:00
|
|
|
}
|
|
|
|
|
2012-10-15 16:04:17 +02:00
|
|
|
static void
|
|
|
|
cc_info_panel_init (CcInfoPanel *self)
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
|
2013-01-04 15:05:07 +01:00
|
|
|
g_resources_register (cc_info_get_resource ());
|
2012-10-15 16:04:17 +02:00
|
|
|
|
2017-09-25 16:11:32 -04:00
|
|
|
self->builder = gtk_builder_new ();
|
2012-10-15 16:04:17 +02:00
|
|
|
|
2017-09-25 16:11:32 -04:00
|
|
|
if (gtk_builder_add_from_resource (self->builder,
|
2013-01-04 15:05:07 +01:00
|
|
|
"/org/gnome/control-center/info/info.ui",
|
|
|
|
&error) == 0)
|
2011-02-10 14:13:28 -05:00
|
|
|
{
|
|
|
|
g_warning ("Could not load interface file: %s", error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
info_panel_setup_selector (self);
|
|
|
|
info_panel_setup_overview (self);
|
|
|
|
}
|