Commit aba6293b authored by Martin Szulecki's avatar Martin Szulecki

Port code and ui to GTK3

parent f383be75
......@@ -14,21 +14,21 @@ AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_LIBTOOL
LIBIMOBILE_REQS=0.9.7
GLIB2_REQS=2.14.1
LIBPLIST_REQS=0.15
GTK2_REQS=2.16
LIBIMOBILE_REQS=1.1.7
GLIB2_REQS=2.38.0
LIBPLIST_REQS=1.12
GTK3_REQS=3.10.0
NAUTILUS_REQS=2.21.2
LIBGPOD_REQS=0.7.90
LIBGPOD_REQS=0.8.2
LIBXML_REQS=2.6.30
# Checks for libraries.
PKG_CHECK_MODULES(WIDGET, libimobiledevice-1.0 >= $LIBIMOBILE_REQS
glib-2.0 >= $GLIB2_REQS
libplist >= $LIBPLIST_REQS
gtk+-2.0 >= $GTK2_REQS)
gtk+-3.0 >= $GTK3_REQS)
PKG_CHECK_MODULES(libnautilusextension, libnautilus-extension >= $NAUTILUS_REQS)
PKG_CHECK_MODULES(libgpod, libgpod-1.0 >= $LIBGPOD_REQS, enable_libgpod=yes, enable_libgpod=no)
PKG_CHECK_MODULES(libgpod, libgpod-1.0 >= $LIBGPOD_REQS, enable_libgpod=no, enable_libgpod=no)
PKG_CHECK_MODULES(libxml, libxml-2.0 >= $LIBXML_REQS)
PKG_CHECK_MODULES(providerinfo, mobile-broadband-provider-info, enable_carrier_lookup=yes, enable_carrier_lookup=no)
......
......@@ -31,6 +31,7 @@
#include <libnautilus-extension/nautilus-property-page-provider.h>
#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/afc.h>
#include <libimobiledevice/lockdown.h>
#include <libimobiledevice/installation_proxy.h>
......@@ -55,6 +56,9 @@
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/xpath.h>
#ifndef MOBILE_BROADBAND_PROVIDER_INFO
#define MOBILE_BROADBAND_PROVIDER_INFO DATADIR"/mobile-broadband-provider-info/serviceproviders.xml"
#endif
#endif
#include "rb-segmented-bar.h"
......@@ -83,14 +87,14 @@ typedef struct {
gboolean has_afc2; /* Whether AFC2 is available */
} CompletedMessage;
G_DEFINE_TYPE(NautilusIdeviceinfoPage, nautilus_ideviceinfo_page, GTK_TYPE_VBOX)
G_DEFINE_TYPE(NautilusIdeviceinfoPage, nautilus_ideviceinfo_page, GTK_TYPE_BOX)
static const char UIFILE[] = NAUTILUS_EXTENSION_DIR "/nautilus-ideviceinfo.ui";
static gchar *value_formatter(gdouble percent, gpointer user_data)
{
gsize total_size = GPOINTER_TO_SIZE(user_data);
return g_format_size_for_display (percent * total_size * 1048576);
return g_format_size (percent * total_size * 1048576);
}
#ifdef HAVE_MOBILE_PROVIDER_INFO
......@@ -513,7 +517,7 @@ end_phone:
/* set disk usage information */
char *storage_formatted_size = NULL;
char *markup = NULL;
storage_formatted_size = g_format_size_for_display (disk_total);
storage_formatted_size = g_format_size (disk_total);
markup = g_markup_printf_escaped ("<b>%s</b> (%s)", _("Storage"), storage_formatted_size);
gtk_label_set_markup(lbStorage, markup);
g_free(storage_formatted_size);
......@@ -617,7 +621,7 @@ static gpointer ideviceinfo_load_data(gpointer data)
goto leave;
}
if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(dev, &client, "nautilus-ideviceinfo")) {
if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(dev, &client, PACKAGE_NAME)) {
completed_message_free(msg);
client = NULL;
goto leave;
......@@ -641,12 +645,12 @@ static gpointer ideviceinfo_load_data(gpointer data)
}
/* get number of applications */
uint16_t iport = 0;
lockdownd_service_descriptor_t service = NULL;
if ((lockdownd_start_service(client, "com.apple.mobile.installation_proxy", &iport) == LOCKDOWN_E_SUCCESS) && iport) {
if ((lockdownd_start_service(client, INSTPROXY_SERVICE_NAME, &service) == LOCKDOWN_E_SUCCESS) && service) {
CHECK_CANCELLED;
instproxy_client_t ipc = NULL;
if (instproxy_client_new(dev, iport, &ipc) == INSTPROXY_E_SUCCESS) {
if (instproxy_client_new(dev, service, &ipc) == INSTPROXY_E_SUCCESS) {
plist_t opts = instproxy_client_options_new();
plist_t apps = NULL;
instproxy_client_options_add(opts, "ApplicationType", "User", NULL);
......@@ -661,11 +665,21 @@ static gpointer ideviceinfo_load_data(gpointer data)
}
}
if (service) {
lockdownd_service_descriptor_free(service);
service = NULL;
}
/* Detect whether AFC2 is available */
if ((lockdownd_start_service(client, "com.apple.afc2", &iport) == LOCKDOWN_E_SUCCESS) && iport) {
if ((lockdownd_start_service(client, AFC_SERVICE_NAME"2", &service) == LOCKDOWN_E_SUCCESS) && service) {
msg->has_afc2 = TRUE;
}
if (service) {
lockdownd_service_descriptor_free(service);
service = NULL;
}
g_idle_add((GSourceFunc) update_ui, msg);
leave:
......@@ -762,7 +776,7 @@ GtkWidget *nautilus_ideviceinfo_page_new(const char *uuid, const char *mount_pat
GtkLabel *lbUUIDText = GTK_LABEL(gtk_builder_get_object (di->priv->builder, "lbUUIDText"));
gtk_label_set_text(lbUUIDText, di->priv->uuid);
di->priv->thread = g_thread_create(ideviceinfo_load_data, di, TRUE, NULL);
di->priv->thread = g_thread_new("ideviceinfo-load", ideviceinfo_load_data, di);
return GTK_WIDGET (di);
}
......@@ -36,12 +36,12 @@ typedef struct NautilusIdeviceinfoPageClass NautilusIdeviceinfoPageClass;
typedef struct NautilusIdeviceinfoPagePrivate NautilusIdeviceinfoPagePrivate;
struct NautilusIdeviceinfoPage {
GtkVBox parent;
GtkBox parent;
NautilusIdeviceinfoPagePrivate *priv;
};
struct NautilusIdeviceinfoPageClass {
GtkVBoxClass parent_class;
GtkBoxClass parent_class;
};
GType nautilus_ideviceinfo_page_get_type(void);
......
......@@ -42,7 +42,7 @@ enum {
LAST_SIGNAL
};
G_DEFINE_TYPE (NautilusAfc2WarningBar, nautilus_afc2_warning_bar, GTK_TYPE_HBOX)
G_DEFINE_TYPE (NautilusAfc2WarningBar, nautilus_afc2_warning_bar, GTK_TYPE_BOX)
static void
nautilus_afc2_warning_bar_class_init (NautilusAfc2WarningBarClass *klass)
......@@ -57,7 +57,7 @@ nautilus_afc2_warning_bar_class_init (NautilusAfc2WarningBarClass *klass)
static void
nautilus_afc2_warning_bar_init (NautilusAfc2WarningBar *bar)
{
GtkWidget *label;
GtkWidget *label;
GtkWidget *hbox;
GtkWidget *vbox;
GtkWidget *image;
......@@ -69,16 +69,17 @@ nautilus_afc2_warning_bar_init (NautilusAfc2WarningBar *bar)
gtk_box_set_spacing (GTK_BOX (bar), 6);
gtk_widget_show (hbox);
image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
image = gtk_image_new_from_icon_name ("dialog-warning", GTK_ICON_SIZE_DIALOG);
gtk_widget_show (image);
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, TRUE, 4);
vbox = gtk_vbox_new (FALSE, 6);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_widget_show (vbox);
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
label = gtk_label_new (_("Jailbroken filesystem browsing is unsupported"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_widget_set_halign (label, GTK_ALIGN_START);
gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
gtk_widget_show (label);
gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
......@@ -86,7 +87,8 @@ nautilus_afc2_warning_bar_init (NautilusAfc2WarningBar *bar)
hint = g_strdup_printf ("<i>%s</i>", _("Accessing the root filesystem of the device can cause damage. If problems occur, a restore will be necessary."));
gtk_label_set_markup (GTK_LABEL (label), hint);
g_free (hint);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_widget_set_halign (label, GTK_ALIGN_START);
gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
gtk_widget_show (label);
gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
}
......
......@@ -38,14 +38,14 @@ typedef struct NautilusAfc2WarningBarPrivate NautilusAfc2WarningBarPrivate;
typedef struct
{
GtkHBox box;
GtkBox box;
NautilusAfc2WarningBarPrivate *priv;
} NautilusAfc2WarningBar;
typedef struct
{
GtkHBoxClass parent_class;
GtkBoxClass parent_class;
} NautilusAfc2WarningBarClass;
GType nautilus_afc2_warning_bar_get_type (void);
......
<?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.2 -->
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy project-wide -->
<object class="GtkVBox" id="ideviceinfo">
<requires lib="gtk+" version="3.0"/>
<object class="GtkBox" id="ideviceinfo">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">12</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkVBox" id="vbGeneral">
<object class="GtkBox" id="vbGeneral">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">General</property>
<attributes>
......@@ -29,12 +32,14 @@
<child>
<object class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="top_padding">8</property>
<property name="left_padding">12</property>
<property name="right_padding">8</property>
<child>
<object class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="n_rows">3</property>
<property name="n_columns">4</property>
<property name="column_spacing">4</property>
......@@ -43,6 +48,7 @@
<object class="GtkLabel" id="lbDeviceName">
<property name="width_request">60</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">1</property>
<property name="ypad">1</property>
......@@ -53,6 +59,7 @@
<object class="GtkLabel" id="lbDeviceVersion">
<property name="width_request">120</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">1</property>
<property name="ypad">1</property>
......@@ -67,6 +74,7 @@
<object class="GtkLabel" id="lbDeviceModel">
<property name="width_request">60</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">1</property>
<property name="ypad">1</property>
......@@ -81,6 +89,7 @@
<object class="GtkLabel" id="lbDeviceSerial">
<property name="width_request">120</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">1</property>
<property name="ypad">1</property>
......@@ -97,6 +106,7 @@
<object class="GtkLabel" id="lbUUID">
<property name="width_request">59</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">1</property>
<property name="ypad">1</property>
......@@ -110,6 +120,7 @@
<child>
<object class="GtkLabel" id="lbDeviceNameText">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">1</property>
<property name="ypad">1</property>
......@@ -123,6 +134,7 @@
<child>
<object class="GtkLabel" id="lbDeviceModelText">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">1</property>
<property name="ypad">1</property>
......@@ -138,6 +150,7 @@
<child>
<object class="GtkLabel" id="lbDeviceVersionText">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">1</property>
<property name="ypad">1</property>
......@@ -151,6 +164,7 @@
<child>
<object class="GtkLabel" id="lbDeviceSerialText">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">1</property>
<property name="ypad">1</property>
......@@ -166,6 +180,7 @@
<child>
<object class="GtkLabel" id="lbUUIDText">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">1</property>
<property name="ypad">1</property>
......@@ -183,22 +198,26 @@
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="vbPhone">
<object class="GtkBox" id="vbPhone">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="label" translatable="yes">Phone</property>
......@@ -215,12 +234,14 @@
<child>
<object class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="top_padding">8</property>
<property name="left_padding">12</property>
<property name="right_padding">8</property>
<child>
<object class="GtkTable" id="table2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="n_rows">3</property>
<property name="n_columns">4</property>
<property name="column_spacing">4</property>
......@@ -229,6 +250,7 @@
<object class="GtkLabel" id="lbTelNo">
<property name="width_request">120</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="xpad">1</property>
......@@ -243,6 +265,7 @@
<object class="GtkLabel" id="lbCarrier">
<property name="width_request">110</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="xpad">1</property>
......@@ -259,6 +282,7 @@
<object class="GtkLabel" id="lbIMEI">
<property name="width_request">120</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">1</property>
<property name="ypad">1</property>
......@@ -274,6 +298,7 @@
<object class="GtkLabel" id="lbIMSI">
<property name="width_request">110</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">1</property>
<property name="ypad">1</property>
......@@ -291,6 +316,7 @@
<object class="GtkLabel" id="lbModemFw">
<property name="width_request">120</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="xpad">1</property>
......@@ -307,6 +333,7 @@
<object class="GtkLabel" id="lbICCID">
<property name="width_request">110</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">1</property>
<property name="ypad">1</property>
......@@ -323,6 +350,7 @@
<child>
<object class="GtkLabel" id="lbTelNoText">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">1</property>
<property name="ypad">1</property>
......@@ -336,6 +364,7 @@
<child>
<object class="GtkLabel" id="lbIMEIText">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">1</property>
<property name="ypad">1</property>
......@@ -351,6 +380,7 @@
<child>
<object class="GtkLabel" id="lbModemFwText">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="xpad">1</property>
......@@ -367,6 +397,7 @@
<child>
<object class="GtkLabel" id="lbICCIDText">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">1</property>
<property name="ypad">1</property>
......@@ -382,6 +413,7 @@
<child>
<object class="GtkLabel" id="lbIMSIText">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">1</property>
<property name="ypad">1</property>
......@@ -397,6 +429,7 @@
<child>
<object class="GtkLabel" id="lbCarrierText">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="selectable">True</property>
</object>
......@@ -409,22 +442,27 @@
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="vbNetwork">
<object class="GtkBox" id="vbNetwork">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Network</property>
<attributes>
......@@ -440,12 +478,14 @@
<child>
<object class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="top_padding">8</property>
<property name="left_padding">12</property>
<property name="right_padding">8</property>
<child>
<object class="GtkTable" id="table3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<property name="column_spacing">4</property>
......@@ -454,6 +494,7 @@
<object class="GtkLabel" id="lbBTMac">
<property name="width_request">130</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">1</property>
<property name="ypad">1</property>
......@@ -467,6 +508,7 @@
<object class="GtkLabel" id="lbWiFiMac">
<property name="width_request">130</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">1</property>
<property name="ypad">1</property>
......@@ -481,6 +523,7 @@
<child>
<object class="GtkLabel" id="lbBTMacText">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">1</property>
<property name="ypad">1</property>
......@@ -494,6 +537,7 @@
<child>
<object class="GtkLabel" id="lbWiFiMacText">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">1</property>
<property name="ypad">1</property>
......@@ -510,23 +554,28 @@
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="vbStorage">
<object class="GtkBox" id="vbStorage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">4</property>
<child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Storage</property>
</object>
......@@ -539,29 +588,37 @@
<child>
<object class="GtkAlignment" id="alignment4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="top_padding">8</property>
<property name="left_padding">8</property>
<property name="right_padding">8</property>
<child>
<object class="GtkVBox" id="vbox8">
<object class="GtkBox" id="vbox8">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkAlignment" id="disk_usage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lbiPodInfo">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
......@@ -569,12 +626,15 @@
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
......
......@@ -31,6 +31,7 @@
#include "config.h"
#endif
#include <math.h>
#include <locale.h>
#include <cairo/cairo.h>
#include <gtk/gtk.h>
#include "rb-segmented-bar.h"
......@@ -38,12 +39,9 @@
#define MINIMUM_HEIGHT 26
static void rb_segmented_bar_finalize (GObject *object);
static void rb_segmented_bar_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void rb_segmented_bar_size_allocate(GtkWidget *widget,
GtkAllocation *allocation);
static gboolean rb_segmented_bar_expose (GtkWidget *widget,
GdkEventExpose *event);
static gboolean rb_segmented_bar_draw (GtkWidget *widget, cairo_t *context);
static void rb_segmented_bar_get_property (GObject *object, guint param_id,
GValue *value, GParamSpec *pspec);
static void rb_segmented_bar_set_property (GObject *object, guint param_id,
......@@ -51,9 +49,17 @@ static void rb_segmented_bar_set_property (GObject *object, guint param_id,
static gchar *rb_segmented_bar_default_value_formatter (gdouble percent,
gpointer data);
static void rb_segmented_bar_get_preferred_height (GtkWidget *widget,
int *minimum_height,
int *natural_height);
static void rb_segmented_bar_get_preferred_width (GtkWidget *widget,
int *minimum_width,
int *natural_width);
static void compute_layout_size (RBSegmentedBar *bar);
static AtkObject * rb_segmented_bar_get_accessible (GtkWidget *widget);
enum
{
PROP_0,
......@@ -79,6 +85,9 @@ struct _RBSegmentedBarPrivate {
RBSegmentedBarValueFormatter value_formatter;
gpointer value_formatter_data;
char *a11y_description;
char *a11y_locale;
};
G_DEFINE_TYPE (RBSegmentedBar, rb_segmented_bar, GTK_TYPE_WIDGET)
......@@ -135,7 +144,7 @@ rb_segmented_bar_init (RBSegmentedBar *bar)
priv->segment_box_size = 12;
priv->segment_box_spacing = 6;
priv->value_formatter = rb_segmented_bar_default_value_formatter;
GTK_WIDGET_SET_FLAGS (GTK_WIDGET (bar), GTK_NO_WINDOW);
gtk_widget_set_has_window (GTK_WIDGET (bar), FALSE);
}
static void
......@@ -148,9 +157,11 @@ rb_segmented_bar_class_init (RBSegmentedBarClass *klass)
object_class->get_property = rb_segmented_bar_get_property;
object_class->set_property = rb_segmented_bar_set_property;
widget_class->expose_event = rb_segmented_bar_expose;
widget_class->size_request = rb_segmented_bar_size_request;
widget_class->draw = rb_segmented_bar_draw;
widget_class->get_preferred_width = rb_segmented_bar_get_preferred_width;
widget_class->get_preferred_height = rb_segmented_bar_get_preferred_height;
widget_class->size_allocate = rb_segmented_bar_size_allocate;
widget_class->get_accessible = rb_segmented_bar_get_accessible;
/**
* RBSegmentedBar::show-reflection
......@@ -263,29 +274,45 @@ rb_segmented_bar_default_value_formatter (gdouble percent,
}
static void
rb_segmented_bar_size_request (GtkWidget *widget,
GtkRequisition *requisition)
rb_segmented_bar_get_preferred_height (GtkWidget *widget, int *minimum_height, int *natural_height)
{
RBSegmentedBarPrivate *priv;
guint real_height;
unsigned int height;
g_return_if_fail (requisition != NULL);
priv = RB_SEGMENTED_BAR_GET_PRIVATE (RB_SEGMENTED_BAR (widget));
if (priv->reflect) {
real_height = MINIMUM_HEIGHT*1.75;
height = MINIMUM_HEIGHT * 1.75;
} else {
real_height = MINIMUM_HEIGHT;
height = MINIMUM_HEIGHT;
}
if (priv->show_labels) {
compute_layout_size (RB_SEGMENTED_BAR (widget));
requisition->height = MAX (MINIMUM_HEIGHT + priv->bar_label_spacing + priv->layout_height,
real_height);
} else {
requisition->height = real_height;
height = MAX (MINIMUM_HEIGHT + priv->bar_label_spacing + priv->layout_height, height);
}
requisition->width = MAX (priv->layout_width, 200);
if (minimum_height)
*minimum_height = height;
if (natural_height)
*natural_height = height;
}
static void
rb_segmented_bar_get_preferred_width (GtkWidget *widget, int *minimum_width, int *natural_width)
{
RBSegmentedBarPrivate *priv;
int width;
priv = RB_SEGMENTED_BAR_GET_PRIVATE (RB_SEGMENTED_BAR (widget));
compute_layout_size (RB_SEGMENTED_BAR (widget));
width = MAX (priv->layout_width, 200);
if (minimum_width)
*minimum_width = width;
if (natural_width)
*natural_width = width;
}
static PangoLayout *create_adapt_layout (GtkWidget *widget, PangoLayout *layout,
......@@ -389,6 +416,7 @@ rb_segmented_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
{