vinagre r497 - in trunk: . data src



Author: jwendell
Date: Mon Oct 20 19:31:50 2008
New Revision: 497
URL: http://svn.gnome.org/viewvc/vinagre?rev=497&view=rev

Log:
2008-10-20  Jonh Wendell <jwendell gnome org>

	* Lots of files: Added an 'original size' option in the menu.
	Closes #509948.


Modified:
   trunk/ChangeLog
   trunk/data/vinagre-ui.xml
   trunk/src/vinagre-commands.c
   trunk/src/vinagre-commands.h
   trunk/src/vinagre-connect.c
   trunk/src/vinagre-notebook.c
   trunk/src/vinagre-tab.c
   trunk/src/vinagre-tab.h
   trunk/src/vinagre-ui.h

Modified: trunk/data/vinagre-ui.xml
==============================================================================
--- trunk/data/vinagre-ui.xml	(original)
+++ trunk/data/vinagre-ui.xml	Mon Oct 20 19:31:50 2008
@@ -42,6 +42,7 @@
       <menuitem name="ViewSidePanelMenu" action="ViewSidePanel"/>
       <separator/>
       <menuitem name="ViewFullScreenMenu" action="ViewFullScreen"/>
+      <menuitem name="ViewOriginalSizeMenu" action="ViewOriginalSize"/>
       <menuitem name="ViewScalingMenu" action="ViewScaling"/>
       <menuitem name="ViewReadOnlyMenu" action="ViewReadOnly"/>
     </menu>

Modified: trunk/src/vinagre-commands.c
==============================================================================
--- trunk/src/vinagre-commands.c	(original)
+++ trunk/src/vinagre-commands.c	Mon Oct 20 19:31:50 2008
@@ -241,6 +241,15 @@
 }
 
 void
+vinagre_cmd_view_original_size (GtkAction     *action,
+				VinagreWindow *window)
+{
+  g_return_if_fail (VINAGRE_IS_WINDOW (window));
+
+  vinagre_tab_original_size (vinagre_window_get_active_tab (window));
+}
+
+void
 vinagre_cmd_view_scaling (GtkAction     *action,
 			  VinagreWindow *window)
 {

Modified: trunk/src/vinagre-commands.h
==============================================================================
--- trunk/src/vinagre-commands.h	(original)
+++ trunk/src/vinagre-commands.h	Mon Oct 20 19:31:50 2008
@@ -54,6 +54,8 @@
 						 VinagreWindow *window);
 void		vinagre_cmd_view_scaling	(GtkAction     *action,
 						 VinagreWindow *window);
+void		vinagre_cmd_view_original_size	(GtkAction     *action,
+						 VinagreWindow *window);
 void		vinagre_cmd_view_fullscreen	(GtkAction     *action,
 						 VinagreWindow *window);
 void		vinagre_cmd_view_readonly	(GtkAction     *action,

Modified: trunk/src/vinagre-connect.c
==============================================================================
--- trunk/src/vinagre-connect.c	(original)
+++ trunk/src/vinagre-connect.c	Mon Oct 20 19:31:50 2008
@@ -152,7 +152,7 @@
   content = g_string_new (NULL);
 
   for (i=0; i<history->len; i++)
-    g_string_append_printf (content, "%s\n", g_ptr_array_index (history, i));
+    g_string_append_printf (content, "%s\n", (char *) g_ptr_array_index (history, i));
 
   filename = history_filename ();
   path = g_path_get_dirname (filename);

Modified: trunk/src/vinagre-notebook.c
==============================================================================
--- trunk/src/vinagre-notebook.c	(original)
+++ trunk/src/vinagre-notebook.c	Mon Oct 20 19:31:50 2008
@@ -104,7 +104,7 @@
 }
 
 static void
-tab_initialized_cb (VinagreTab *tab, VinagreNotebook *nb)
+tab_size_changed_cb (VinagreTab *tab, VinagreNotebook *nb)
 {
   char *str;
   GtkWidget *label;
@@ -217,9 +217,10 @@
   g_object_set_data (G_OBJECT (tab),  "close-button", close_button);
 
   g_signal_connect (tab,
-		    "tab-initialized",
-		    G_CALLBACK (tab_initialized_cb),
+		    "notify::original-width",
+		    G_CALLBACK (tab_size_changed_cb),
 		    nb);
+
   g_signal_connect (tab,
 		    "tab-disconnected",
 		    G_CALLBACK (tab_disconnected_cb),

Modified: trunk/src/vinagre-tab.c
==============================================================================
--- trunk/src/vinagre-tab.c	(original)
+++ trunk/src/vinagre-tab.c	Mon Oct 20 19:31:50 2008
@@ -71,6 +71,8 @@
   PROP_0,
   PROP_CONN,
   PROP_WINDOW,
+  PROP_ORIGINAL_WIDTH,
+  PROP_ORIGINAL_HEIGHT
 };
 
 static guint signals[LAST_SIGNAL] = { 0 };
@@ -140,6 +142,12 @@
       case PROP_WINDOW:
         g_value_set_object (value, tab->priv->window);
 	break;
+      case PROP_ORIGINAL_WIDTH:
+        g_value_set_int (value, vinagre_tab_get_original_width (tab));
+	break;
+      case PROP_ORIGINAL_HEIGHT:
+        g_value_set_int (value, vinagre_tab_get_original_height (tab));
+	break;
       default:
 	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 	break;			
@@ -222,6 +230,28 @@
 							G_PARAM_STATIC_NICK |
 							G_PARAM_STATIC_BLURB));
 
+  g_object_class_install_property (object_class,
+				   PROP_ORIGINAL_WIDTH,
+				   g_param_spec_int ("original-width",
+						     "Original width",
+						     "The original width of the remote screen",
+						     -1, G_MAXINT, 0,
+						      G_PARAM_READABLE |
+						      G_PARAM_STATIC_NAME |
+						      G_PARAM_STATIC_NICK |
+						      G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (object_class,
+				   PROP_ORIGINAL_HEIGHT,
+				   g_param_spec_int ("original-height",
+						     "Original height",
+						     "The original height of the remote screen",
+						     -1, G_MAXINT, 0,
+						      G_PARAM_READABLE |
+						      G_PARAM_STATIC_NAME |
+						      G_PARAM_STATIC_NICK |
+						      G_PARAM_STATIC_BLURB));
+
   signals[TAB_CONNECTED] =
 		g_signal_new ("tab-connected",
 			      G_OBJECT_CLASS_TYPE (object_class),
@@ -609,12 +639,20 @@
   vinagre_window_set_title (tab->priv->window);
 }
 
-static void vnc_bell_cb (VncDisplay *vnc, VinagreTab *tab)
+static void
+vnc_bell_cb (VncDisplay *vnc, VinagreTab *tab)
 {
   gdk_window_beep (GTK_WIDGET (tab->priv->window)->window);
 }
 
 static void
+vnc_desktop_resize_cb (VncDisplay *vnc, int x, int y, VinagreTab *tab)
+{
+  g_object_notify (G_OBJECT (tab), "original-width");
+  g_object_notify (G_OBJECT (tab), "original-height");
+}
+
+static void
 close_button_clicked (GtkToolButton *button,
 		      VinagreTab    *tab)
 {
@@ -637,7 +675,7 @@
 
 static void
 cad_button_clicked (GtkToolButton *button,
-			   VinagreTab    *tab)
+		    VinagreTab    *tab)
 {
   vinagre_tab_send_ctrlaltdel (tab);
 }
@@ -830,6 +868,11 @@
 		    G_CALLBACK (vnc_bell_cb),
 		    tab);
 
+  g_signal_connect (tab->priv->vnc,
+		    "vnc-desktop-resize",
+		    G_CALLBACK (vnc_desktop_resize_cb),
+		    tab);
+
   setup_layout (tab);
 
   gtk_box_pack_end (GTK_BOX(tab), tab->priv->layout, TRUE, TRUE, 0);
@@ -1025,7 +1068,7 @@
 
 gboolean
 vinagre_tab_get_scaling (VinagreTab *tab) {
-  g_return_if_fail (VINAGRE_IS_TAB (tab));
+  g_return_val_if_fail (VINAGRE_IS_TAB (tab), FALSE);
 
   return vnc_display_get_scaling (VNC_DISPLAY (tab->priv->vnc));
 }
@@ -1042,7 +1085,7 @@
 
 gboolean
 vinagre_tab_get_readonly (VinagreTab *tab) {
-  g_return_if_fail (VINAGRE_IS_TAB (tab));
+  g_return_val_if_fail (VINAGRE_IS_TAB (tab), FALSE);
 
   return vnc_display_get_read_only (VNC_DISPLAY (tab->priv->vnc));
 }
@@ -1050,7 +1093,7 @@
 VinagreTabState
 vinagre_tab_get_state (VinagreTab *tab)
 {
-  g_return_if_fail (VINAGRE_IS_TAB (tab));
+  g_return_val_if_fail (VINAGRE_IS_TAB (tab), VINAGRE_TAB_STATE_INVALID);
 
   return tab->priv->state;
 }
@@ -1068,10 +1111,90 @@
 }
 
 gboolean
-vinagre_tab_is_pointer_grab (VinagreTab *tab) {
-  g_return_if_fail (VINAGRE_IS_TAB (tab));
+vinagre_tab_is_pointer_grab (VinagreTab *tab)
+{
+  g_return_val_if_fail (VINAGRE_IS_TAB (tab), FALSE);
 
   return tab->priv->pointer_grab;
 }
 
+gint
+vinagre_tab_get_original_height (VinagreTab *tab)
+{
+  g_return_val_if_fail (VINAGRE_IS_TAB (tab), -1);
+
+  if (VNC_IS_DISPLAY (tab->priv->vnc))
+    return vnc_display_get_height (VNC_DISPLAY (tab->priv->vnc));
+  else
+    return -1;
+}
+
+gint
+vinagre_tab_get_original_width (VinagreTab *tab)
+{
+  g_return_val_if_fail (VINAGRE_IS_TAB (tab), -1);
+
+  if (VNC_IS_DISPLAY (tab->priv->vnc))
+    return vnc_display_get_width (VNC_DISPLAY (tab->priv->vnc));
+  else
+    return -1;
+}
+
+
+typedef struct _VinagrePrefSize {
+  gint width, height;
+  gulong sig_id;
+} VinagrePrefSize;
+
+static gboolean
+cb_unset_size (gpointer data)
+{
+  GtkWidget *widget = data;
+
+  gtk_widget_queue_resize_no_redraw (widget);
+
+  return FALSE;
+}
+
+static void
+cb_set_preferred_size (GtkWidget *widget, GtkRequisition *req,
+		       gpointer data)
+{
+  VinagrePrefSize *size = data;
+
+  req->width = size->width;
+  req->height = size->height;
+
+  g_signal_handler_disconnect (widget, size->sig_id);
+  g_free (size);
+  g_idle_add (cb_unset_size, widget);
+}
+
+void
+vinagre_widget_set_preferred_size (GtkWidget *widget, gint width,
+				 gint height)
+{
+  VinagrePrefSize *size = g_new (VinagrePrefSize, 1);
+
+  size->width = width;
+  size->height = height;
+  size->sig_id = g_signal_connect (widget, "size-request",
+				   G_CALLBACK (cb_set_preferred_size),
+				   size);
+
+  gtk_widget_queue_resize (widget);
+}
+
+void
+vinagre_tab_original_size (VinagreTab *tab)
+{
+  g_return_if_fail (VINAGRE_IS_TAB (tab));
+
+  gtk_window_unmaximize (GTK_WINDOW (tab->priv->window));
+  gtk_window_resize (GTK_WINDOW (tab->priv->window), 1, 1);
+  vinagre_widget_set_preferred_size (GTK_WIDGET (tab),
+				     vinagre_tab_get_original_width (tab),
+				     vinagre_tab_get_original_height (tab));
+}
+
 /* vim: set ts=8: */

Modified: trunk/src/vinagre-tab.h
==============================================================================
--- trunk/src/vinagre-tab.h	(original)
+++ trunk/src/vinagre-tab.h	Mon Oct 20 19:31:50 2008
@@ -94,6 +94,10 @@
 void	          vinagre_tab_set_readonly	(VinagreTab *tab, gboolean active);
 gboolean	  vinagre_tab_get_readonly	(VinagreTab *tab);
 
+gint		  vinagre_tab_get_original_width  (VinagreTab *tab);
+gint		  vinagre_tab_get_original_height (VinagreTab *tab);
+void		  vinagre_tab_original_size	  (VinagreTab *tab);
+
 VinagreTabState   vinagre_tab_get_state		(VinagreTab *tab);
 VinagreTab	  *vinagre_tab_get_from_connection (VinagreConnection *conn);
 

Modified: trunk/src/vinagre-ui.h
==============================================================================
--- trunk/src/vinagre-ui.h	(original)
+++ trunk/src/vinagre-ui.h	Mon Oct 20 19:31:50 2008
@@ -85,6 +85,10 @@
   /* View menu */
   { "ViewFullScreen", GTK_STOCK_FULLSCREEN, NULL, "F11",
     N_("View the current machine in full screen"), G_CALLBACK (vinagre_cmd_view_fullscreen) },
+
+  { "ViewOriginalSize", "zoom-original", N_("_Original size"), NULL,
+    N_("Adjusts the window to the remote desktop's size"), G_CALLBACK (vinagre_cmd_view_original_size) },
+
 };
 
 static const GtkToggleActionEntry vinagre_machine_connected_toggle_menu_entries[] =



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