aboutsummaryrefslogtreecommitdiff
path: root/hildon
diff options
context:
space:
mode:
authorMukund Sivaraman <muks@banu.com>2012-01-23 17:39:05 +0530
committerTomasz Sterna <tomek@xiaoka.com>2012-05-30 23:10:21 +0300
commit80d02c5eeda47e859ab839a19cafc528b57a5e52 (patch)
treefdb621115dc8402006b95f7dd9352330985b0308 /hildon
parent2603dde466c82ed60c41f9540a68f803d3510bf5 (diff)
Port to GTK+ 3
Diffstat (limited to 'hildon')
-rw-r--r--hildon/hildon-app-menu.c38
-rw-r--r--hildon/hildon-button.c27
-rw-r--r--hildon/hildon-gtk.c16
-rw-r--r--hildon/hildon-live-search.c18
-rw-r--r--hildon/hildon-text-view.c10
-rw-r--r--hildon/hildon-window.c5
6 files changed, 51 insertions, 63 deletions
diff --git a/hildon/hildon-app-menu.c b/hildon/hildon-app-menu.c
index 95dd3c9..d07e5f0 100644
--- a/hildon/hildon-app-menu.c
+++ b/hildon/hildon-app-menu.c
@@ -194,7 +194,7 @@ hildon_app_menu_insert (HildonAppMenu *menu,
/* Add the item to the menu */
g_object_ref_sink (item);
priv->buttons = g_list_insert (priv->buttons, item, position);
- if (gtk_widget_get_visible (item))
+ if (gtk_widget_get_visible (GTK_WIDGET (item)))
hildon_app_menu_repack_items (menu, position);
/* Enable accelerators */
@@ -304,7 +304,7 @@ hildon_app_menu_add_filter (HildonAppMenu *menu,
/* Add the filter to the menu */
g_object_ref_sink (filter);
priv->filters = g_list_append (priv->filters, filter);
- if (gtk_widget_get_visible (filter))
+ if (gtk_widget_get_visible (GTK_WIDGET (filter)))
hildon_app_menu_repack_filters (menu);
/* Enable accelerators */
@@ -379,7 +379,7 @@ hildon_app_menu_set_parent_window (HildonAppMenu *self,
priv->parent_window = parent_window;
- if (parent_window == NULL && gtk_widget_get_visible (self))
+ if (parent_window == NULL && gtk_widget_get_visible (GTK_WIDGET (self)))
gtk_widget_hide (GTK_WIDGET (self));
}
@@ -473,24 +473,6 @@ hildon_app_menu_show_all (GtkWidget *widget)
}
-static void
-hildon_app_menu_hide_all (GtkWidget *widget)
-{
- HildonAppMenu *menu = HILDON_APP_MENU (widget);
- HildonAppMenuPrivate *priv = HILDON_APP_MENU_GET_PRIVATE (widget);
-
- priv->inhibit_repack = TRUE;
-
- /* Hide children, but not self. */
- g_list_foreach (priv->buttons, (GFunc) gtk_widget_hide_all, NULL);
- g_list_foreach (priv->filters, (GFunc) gtk_widget_hide_all, NULL);
-
- priv->inhibit_repack = FALSE;
-
- hildon_app_menu_repack_items (menu, 0);
- hildon_app_menu_repack_filters (menu);
-}
-
/*
* There's a race condition that can freeze the UI if a dialog appears
* between a HildonAppMenu and its parent window, see NB#100468
@@ -640,14 +622,13 @@ hildon_app_menu_delete_event_handler (GtkWidget *widget,
}
static void
-hildon_app_menu_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
+hildon_app_menu_get_preferred_width (GtkWidget *widget,
+ gint *minimal_width,
+ gint *natural_width)
{
HildonAppMenuPrivate *priv = HILDON_APP_MENU_GET_PRIVATE (widget);
- GTK_WIDGET_CLASS (hildon_app_menu_parent_class)->size_request (widget, requisition);
-
- requisition->width = priv->width_request;
+ *minimal_width = *natural_width = priv->width_request;
}
static void
@@ -969,7 +950,7 @@ hildon_app_menu_init (HildonAppMenu *menu)
/* This should be treated like a normal, ref-counted widget */
g_object_force_floating (G_OBJECT (menu));
- GTK_WINDOW (menu)->has_user_ref_count = FALSE;
+ gtk_window_set_has_user_ref_count (GTK_WINDOW (menu), FALSE);
gtk_widget_show_all (GTK_WIDGET (priv->vbox));
}
@@ -1038,7 +1019,6 @@ hildon_app_menu_class_init (HildonAppMenuClass *klass)
gobject_class->dispose = hildon_app_menu_dispose;
gobject_class->finalize = hildon_app_menu_finalize;
widget_class->show_all = hildon_app_menu_show_all;
- widget_class->hide_all = hildon_app_menu_hide_all;
widget_class->map = hildon_app_menu_map;
widget_class->realize = hildon_app_menu_realize;
widget_class->unrealize = hildon_app_menu_unrealize;
@@ -1046,7 +1026,7 @@ hildon_app_menu_class_init (HildonAppMenuClass *klass)
widget_class->key_press_event = hildon_app_menu_key_press;
widget_class->style_set = hildon_app_menu_style_set;
widget_class->delete_event = hildon_app_menu_delete_event_handler;
- widget_class->size_request = hildon_app_menu_size_request;
+ widget_class->get_preferred_width = hildon_app_menu_get_preferred_width;
g_type_class_add_private (klass, sizeof (HildonAppMenuPrivate));
diff --git a/hildon/hildon-button.c b/hildon/hildon-button.c
index c25dc2f..6267c64 100644
--- a/hildon/hildon-button.c
+++ b/hildon/hildon-button.c
@@ -214,6 +214,7 @@ set_logical_color (GtkWidget *button)
const gchar *colorname;
HildonButtonPrivate *priv = HILDON_BUTTON_GET_PRIVATE (button);
GtkWidget *label = GTK_WIDGET (priv->value);
+ gboolean found;
switch (priv->style) {
case HILDON_BUTTON_STYLE_NORMAL:
@@ -227,7 +228,9 @@ set_logical_color (GtkWidget *button)
}
gtk_widget_ensure_style (label);
- if (gtk_style_lookup_color (label->style, colorname, &color) == TRUE) {
+ found = gtk_style_lookup_color (gtk_widget_get_style (label),
+ colorname, &color);
+ if (found) {
priv->setting_style = TRUE;
gtk_widget_modify_fg (label, GTK_STATE_NORMAL, &color);
gtk_widget_modify_fg (label, GTK_STATE_PRELIGHT, &color);
@@ -762,8 +765,12 @@ hildon_button_set_image (HildonButton *button,
if (image == priv->image)
return;
- if (priv->image && priv->image->parent)
- gtk_container_remove (GTK_CONTAINER (priv->image->parent), priv->image);
+ if (priv->image) {
+ GtkWidget *parent = gtk_widget_get_parent (priv->image);
+
+ if (parent)
+ gtk_container_remove (GTK_CONTAINER (parent), priv->image);
+ }
priv->image = image;
@@ -1011,6 +1018,7 @@ hildon_button_construct_child (HildonButton *button)
GtkWidget *child;
gint image_spacing;
const gchar *title, *value;
+ GtkWidget *lb_parent;
/* Don't do anything if the button is not constructed yet */
if (G_UNLIKELY (priv->label_box == NULL))
@@ -1024,15 +1032,18 @@ hildon_button_construct_child (HildonButton *button)
/* Save a ref to the image, and remove it from its container if necessary */
if (priv->image) {
+ GtkWidget *parent = gtk_widget_get_parent (priv->image);
+
g_object_ref (priv->image);
- if (priv->image->parent != NULL)
- gtk_container_remove (GTK_CONTAINER (priv->image->parent), priv->image);
- }
- if (priv->label_box->parent != NULL) {
- gtk_container_remove (GTK_CONTAINER (priv->label_box->parent), priv->label_box);
+ if (parent)
+ gtk_container_remove (GTK_CONTAINER (parent), priv->image);
}
+ lb_parent = gtk_widget_get_parent (priv->label_box);
+ if (lb_parent)
+ gtk_container_remove (GTK_CONTAINER (lb_parent), priv->label_box);
+
/* Remove the child from the container and add priv->alignment */
child = gtk_bin_get_child (GTK_BIN (button));
if (child != NULL && child != priv->alignment) {
diff --git a/hildon/hildon-gtk.c b/hildon/hildon-gtk.c
index 3b06bbe..a0fc1d1 100644
--- a/hildon/hildon-gtk.c
+++ b/hildon/hildon-gtk.c
@@ -43,10 +43,12 @@ image_visible_changed_cb (GtkWidget *image,
static void
parent_changed_cb (GtkWidget *image,
GParamSpec *arg1,
- gpointer oldparent)
+ gpointer oldparent)
{
+ GtkWidget *parent = gtk_widget_get_parent (image);
+
/* If the parent has really changed, remove the old signal handlers */
- if (image->parent != oldparent) {
+ if (parent != oldparent) {
g_signal_handlers_disconnect_by_func (image, parent_changed_cb, oldparent);
g_signal_handlers_disconnect_by_func (image, image_visible_changed_cb, NULL);
}
@@ -62,12 +64,14 @@ image_changed_cb (GtkButton *button,
g_return_if_fail (image == NULL || GTK_IS_WIDGET (image));
if (image != NULL) {
+ GtkWidget *parent = gtk_widget_get_parent (image);
+
/* If the button has a new image, show it */
gtk_widget_show (image);
/* Show the image no matter the value of gtk-button-images */
g_signal_connect (image, "notify::visible", G_CALLBACK (image_visible_changed_cb), NULL);
/* If the image is removed from the button, disconnect these handlers */
- g_signal_connect (image, "notify::parent", G_CALLBACK (parent_changed_cb), image->parent);
+ g_signal_connect (image, "notify::parent", G_CALLBACK (parent_changed_cb), parent);
}
}
@@ -372,7 +376,7 @@ hildon_gtk_window_take_screenshot (GtkWindow *window,
XEvent xev = { 0 };
g_return_if_fail (GTK_IS_WINDOW (window));
- g_return_if_fail (gtk_widget_get_mapped (window));
+ g_return_if_fail (gtk_widget_get_mapped (GTK_WIDGET (window)));
xev.xclient.type = ClientMessage;
xev.xclient.serial = 0;
@@ -422,9 +426,7 @@ hildon_gtk_window_take_screenshot_sync (GtkWindow *window,
gboolean take)
{
XEvent foo;
- GdkWindow *win;
- win = gtk_widget_get_window (GTK_WIDGET (window));
hildon_gtk_window_take_screenshot (window, take);
XIfEvent (GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (window))),
&foo, (void *)screenshot_done, (XPointer)window);
@@ -519,7 +521,7 @@ hildon_gtk_widget_set_theme_size (GtkWidget *widget,
}
if (widget_name)
- widget_name = g_strconcat (g_type_name (GTK_WIDGET_TYPE (widget)),
+ widget_name = g_strconcat (g_type_name (G_OBJECT_TYPE (widget)),
widget_name, NULL);
/* Requested width */
diff --git a/hildon/hildon-live-search.c b/hildon/hildon-live-search.c
index aae7d43..a41a8fb 100644
--- a/hildon/hildon-live-search.c
+++ b/hildon/hildon-live-search.c
@@ -200,7 +200,7 @@ convert_path_to_child_path (GtkTreeModel *model,
return gtk_tree_path_copy (path);
g_assert (GTK_IS_TREE_MODEL_SORT (model));
- g_assert (gtk_tree_model_sort_get_model (model) == base_model);
+ g_assert (gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (model)) == base_model);
return gtk_tree_model_sort_convert_path_to_child_path
(GTK_TREE_MODEL_SORT (model), path);
@@ -315,14 +315,12 @@ reference_row_has_path (GtkTreeRowReference *row_ref, gpointer value, GtkTreePat
static void
selection_map_update_selection_from_map (HildonLiveSearchPrivate *priv)
{
- GtkTreeModel *base_model;
GtkTreeSelection *selection;
GList *selected_list, *l_iter;
if (!GTK_IS_TREE_VIEW (priv->kb_focus_widget))
return;
- base_model = gtk_tree_model_filter_get_model (priv->filter);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->kb_focus_widget));
/* unselect things which are not in priv->selection_map */
@@ -559,24 +557,24 @@ on_key_press_event (GtkWidget *widget,
* passed to the focus widget, with the exception of
* Ctrl + Space, which is given to the entry, so that the input method
* is allowed to switch the keyboard layout. */
- if (gtk_widget_get_visible (live_search) ||
+ if (gtk_widget_get_visible (GTK_WIDGET (live_search)) ||
!(event->state & GDK_CONTROL_MASK ||
- event->keyval == GDK_Control_L ||
- event->keyval == GDK_Control_R) ||
+ event->keyval == GDK_KEY_Control_L ||
+ event->keyval == GDK_KEY_Control_R) ||
(event->state & GDK_CONTROL_MASK &&
- event->keyval == GDK_space)) {
+ event->keyval == GDK_KEY_space)) {
GdkEvent *new_event;
/* If the entry is realized and has focus, it is enough to catch events.
* This assumes that the toolbar is a child of the hook widget. */
gtk_widget_realize (priv->entry);
- if (!GTK_WIDGET_HAS_FOCUS (priv->entry))
+ if (!gtk_widget_has_focus (priv->entry))
gtk_widget_grab_focus (priv->entry);
new_event = gdk_event_copy ((GdkEvent *)event);
handled = gtk_widget_event (priv->entry, new_event);
gdk_event_free (new_event);
- } else if (!GTK_WIDGET_HAS_FOCUS (priv->kb_focus_widget)) {
+ } else if (!gtk_widget_has_focus (priv->kb_focus_widget)) {
gtk_widget_grab_focus (GTK_WIDGET (priv->kb_focus_widget));
}
}
@@ -818,7 +816,7 @@ hildon_live_search_init (HildonLiveSearch *self)
HILDON_ICON_SIZE_FINGER);
gtk_misc_set_padding (GTK_MISC (close), 0, 0);
close_button = gtk_tool_button_new (close, NULL);
- gtk_widget_set_can_focus (close_button, FALSE);
+ gtk_widget_set_can_focus (GTK_WIDGET (close_button), FALSE);
close_button_alignment = gtk_alignment_new (0.0f, 0.0f, 1.0f, 1.0f);
gtk_alignment_set_padding (GTK_ALIGNMENT (close_button_alignment),
diff --git a/hildon/hildon-text-view.c b/hildon/hildon-text-view.c
index 4a82cf3..0999674 100644
--- a/hildon/hildon-text-view.c
+++ b/hildon/hildon-text-view.c
@@ -90,12 +90,13 @@ hildon_text_view_button_press_event (GtkWidget *widget,
GdkEventButton *event)
{
HildonTextViewPrivate *priv = HILDON_TEXT_VIEW_GET_PRIVATE (widget);
+ GtkTextView *text_view = GTK_TEXT_VIEW (widget);
gtk_widget_grab_focus (widget);
- if (GTK_TEXT_VIEW (widget)->editable)
+ if (gtk_text_view_get_editable (text_view))
{
- GTK_TEXT_VIEW (widget)->need_im_reset = TRUE;
+ gtk_text_view_reset_im_context (text_view);
return TRUE;
}
@@ -108,7 +109,6 @@ hildon_text_view_button_press_event (GtkWidget *widget,
GtkTextWindowType window_type;
GtkTextIter iter;
gint x, y;
- GtkTextView *text_view = GTK_TEXT_VIEW (widget);
priv->selection_movement = TRUE;
@@ -143,9 +143,9 @@ hildon_text_view_button_release_event (GtkWidget *widget,
GtkTextIter iter;
gint x, y;
- if (text_view->editable)
+ if (gtk_text_view_get_editable (text_view))
{
- text_view->need_im_reset = TRUE;
+ gtk_text_view_reset_im_context (text_view);
return TRUE;
}
diff --git a/hildon/hildon-window.c b/hildon/hildon-window.c
index 78c1d74..5612c54 100644
--- a/hildon/hildon-window.c
+++ b/hildon/hildon-window.c
@@ -722,7 +722,7 @@ hildon_window_size_allocate (GtkWidget *widget,
tb = priv->toolbar_borders;
- gtk_widget_size_allocate (widget, allocation);
+ GTK_WIDGET_CLASS (hildon_window_parent_class)->size_allocate (widget, allocation);
/* Calculate allocation of edit toolbar */
if (priv->edit_toolbar != NULL && gtk_widget_get_visible (priv->edit_toolbar))
@@ -1102,10 +1102,7 @@ static gboolean
hildon_window_key_press_event (GtkWidget *widget,
GdkEventKey *event)
{
- HildonWindowPrivate *priv = HILDON_WINDOW_GET_PRIVATE (widget);
-
g_return_val_if_fail (HILDON_IS_WINDOW (widget),FALSE);
- g_assert (priv);
switch (event->keyval)
{